spec/outputs/elasticsearch.rb in logstash-output-elasticsearch-0.1.5 vs spec/outputs/elasticsearch.rb in logstash-output-elasticsearch-0.1.6

- old
+ new

@@ -10,10 +10,11 @@ # register will try to load jars and raise if it cannot find jars expect {output.register}.to_not raise_error end + describe "ship lots of events w/ default index_type", :elasticsearch => true do # Generate a random index name index = 10.times.collect { rand(10).to_s }.join("") type = 10.times.collect { rand(10).to_s }.join("") @@ -252,9 +253,37 @@ result = LogStash::Json.load(data) result["hits"]["hits"].each do |doc| insist { doc["_type"] } == "generated" end end + end + end + + describe "wildcard substitution in index templates", :todo => true do + require "logstash/outputs/elasticsearch" + + let(:template) { '{"template" : "not important, will be updated by :index"}' } + + def settings_with_index(index) + return { + "manage_template" => true, + "template_overwrite" => true, + "protocol" => "http", + "host" => "localhost", + "index" => "#{index}" + } + end + + it "should substitude placeholders" do + IO.stub(:read).with(anything) { template } + es_output = LogStash::Outputs::ElasticSearch.new(settings_with_index("index-%{YYYY}")) + insist { es_output.get_template['template'] } == "index-*" + end + + it "should do nothing to an index with no placeholder" do + IO.stub(:read).with(anything) { template } + es_output = LogStash::Outputs::ElasticSearch.new(settings_with_index("index")) + insist { es_output.get_template['template'] } == "index" end end describe "index template expected behavior", :elasticsearch => true do ["node", "transport", "http"].each do |protocol|