spec/outputs/newrelic_spec.rb in logstash-output-newrelic-1.0.1 vs spec/outputs/newrelic_spec.rb in logstash-output-newrelic-1.0.2
- old
+ new
@@ -81,12 +81,10 @@
@newrelic_output.multi_receive([event])
wait_for(a_request(:post, base_uri)
.with { |request|
data = multiple_gzipped_messages(request.body)[0]
- data.keys[0] == 'common' &&
- data.keys[1] == 'logs' &&
data['common']['attributes']['plugin']['type'] == 'logstash' &&
data['common']['attributes']['plugin']['version'] == LogStash::Outputs::NewRelicVersion::VERSION })
.to have_been_made
end
@@ -109,12 +107,13 @@
@newrelic_output.multi_receive([event])
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
+ puts message
message['message'] == 'Test message' &&
- message['other'] == 'Other value' })
+ message['attributes']['other'] == 'Other value' })
.to have_been_made
end
it "JSON object 'message' field is parsed, removed, and its data merged as attributes" do
stub_request(:any, base_uri).to_return(status: 200)
@@ -124,14 +123,14 @@
@newrelic_output.multi_receive([event])
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
- message['in-json-1'] == '1' &&
- message['in-json-2'] == '2' &&
- message['sub-object'] == {"in-json-3" => "3"} &&
- message['other'] == 'Other value' })
+ message['attributes']['in-json-1'] == '1' &&
+ message['attributes']['in-json-2'] == '2' &&
+ message['attributes']['sub-object'] == {"in-json-3" => "3"} &&
+ message['attributes']['other'] == 'Other value' })
.to have_been_made
end
it "JSON array 'message' field is not parsed, left as is" do
stub_request(:any, base_uri).to_return(status: 200)
@@ -142,11 +141,11 @@
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
message['message'] == message_json_array &&
- message['other'] == 'Other value' })
+ message['attributes']['other'] == 'Other value' })
.to have_been_made
end
it "JSON string 'message' field is not parsed, left as is" do
stub_request(:any, base_uri).to_return(status: 200)
@@ -157,11 +156,11 @@
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
message['message'] == message_json_string &&
- message['other'] == 'Other value' })
+ message['attributes']['other'] == 'Other value' })
.to have_been_made
end
it "other JSON fields are not parsed" do
stub_request(:any, base_uri).to_return(status: 200)
@@ -172,11 +171,11 @@
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
message['message'] == 'Test message' &&
- message['other'] == other_json })
+ message['attributes']['other'] == other_json })
.to have_been_made
end
it "handles messages without a 'message' field" do
stub_request(:any, base_uri).to_return(status: 200)
@@ -185,10 +184,10 @@
@newrelic_output.multi_receive([event])
wait_for(a_request(:post, base_uri)
.with { |request|
message = single_gzipped_message(request.body)
- message['other'] == 'Other value' })
+ message['attributes']['other'] == 'Other value' })
.to have_been_made
end
it "multiple events" do
stub_request(:any, base_uri).to_return(status: 200)