spec/inputs/elasticsearch_spec.rb in logstash-input-elasticsearch-2.0.5 vs spec/inputs/elasticsearch_spec.rb in logstash-input-elasticsearch-3.0.0

- old
+ new

@@ -69,11 +69,11 @@ event = input(config) do |pipeline, queue| queue.pop end insist { event }.is_a?(LogStash::Event) - insist { event["message"] } == [ "ohayo" ] + insist { event.get("message") } == [ "ohayo" ] end it "should retrieve json event from elasticseach with scan" do config = %q[ input { @@ -126,11 +126,11 @@ event = input(config) do |pipeline, queue| queue.pop end insist { event }.is_a?(LogStash::Event) - insist { event["message"] } == [ "ohayo" ] + insist { event.get("message") } == [ "ohayo" ] end context "with Elasticsearch document information" do let!(:response) do { @@ -206,14 +206,14 @@ event = input(config_metadata_with_hash) do |pipeline, queue| queue.pop end - expect(event[metadata_field]["_index"]).to eq('logstash-2014.10.12') - expect(event[metadata_field]["_type"]).to eq('logs') - expect(event[metadata_field]["_id"]).to eq('C5b2xLQwTZa76jBmHIbwHQ') - expect(event[metadata_field]["awesome"]).to eq("logstash") + expect(event.get("[#{metadata_field}][_index]")).to eq('logstash-2014.10.12') + expect(event.get("[#{metadata_field}][_type]")).to eq('logs') + expect(event.get("[#{metadata_field}][_id]")).to eq('C5b2xLQwTZa76jBmHIbwHQ') + expect(event.get("[#{metadata_field}][awesome]")).to eq("logstash") end it 'thows an exception if the `docinfo_target` exist but is not of type hash' do metadata_field = 'metadata_with_string' @@ -241,13 +241,13 @@ it "should move the document info to the @metadata field" do event = input(config_metadata) do |pipeline, queue| queue.pop end - expect(event["[@metadata][_index]"]).to eq('logstash-2014.10.12') - expect(event["[@metadata][_type]"]).to eq('logs') - expect(event["[@metadata][_id]"]).to eq('C5b2xLQwTZa76jBmHIbwHQ') + expect(event.get("[@metadata][_index]")).to eq('logstash-2014.10.12') + expect(event.get("[@metadata][_type]")).to eq('logs') + expect(event.get("[@metadata][_id]")).to eq('C5b2xLQwTZa76jBmHIbwHQ') end it 'should move the document information to the specified field' do config = %q[ input { @@ -262,13 +262,13 @@ ] event = input(config) do |pipeline, queue| queue.pop end - expect(event["[meta][_index]"]).to eq('logstash-2014.10.12') - expect(event["[meta][_type]"]).to eq('logs') - expect(event["[meta][_id]"]).to eq('C5b2xLQwTZa76jBmHIbwHQ') + expect(event.get("[meta][_index]")).to eq('logstash-2014.10.12') + expect(event.get("[meta][_type]")).to eq('logs') + expect(event.get("[meta][_id]")).to eq('C5b2xLQwTZa76jBmHIbwHQ') end it "should allow to specify which fields from the document info to save to the @metadata field" do fields = ["_index"] config = %Q[ @@ -284,14 +284,14 @@ event = input(config) do |pipeline, queue| queue.pop end - expect(event["@metadata"].keys).to eq(fields) - expect(event["[@metadata][_type]"]).to eq(nil) - expect(event["[@metadata][_index]"]).to eq('logstash-2014.10.12') - expect(event["[@metadata][_id]"]).to eq(nil) + expect(event.get("@metadata").keys).to eq(fields) + expect(event.get("[@metadata][_type]")).to eq(nil) + expect(event.get("[@metadata][_index]")).to eq('logstash-2014.10.12') + expect(event.get("[@metadata][_id]")).to eq(nil) end end context "when not defining the docinfo" do it 'should keep the document information in the root of the event' do @@ -306,12 +306,12 @@ ] event = input(config) do |pipeline, queue| queue.pop end - expect(event["[@metadata][_index]"]).to eq(nil) - expect(event["[@metadata][_type]"]).to eq(nil) - expect(event["[@metadata][_id]"]).to eq(nil) + expect(event.get("[@metadata][_index]")).to eq(nil) + expect(event.get("[@metadata][_type]")).to eq(nil) + expect(event.get("[@metadata][_id]")).to eq(nil) end end end end