Skip to content

Commit

Permalink
DO NOTE MERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Jul 18, 2017
1 parent ca436ef commit aaf96f3
Showing 1 changed file with 59 additions and 23 deletions.
82 changes: 59 additions & 23 deletions logstash-core/spec/logstash/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TestPipeline < LogStash::Pipeline
let(:dead_letter_queue_path) { }
let(:pipeline_settings_obj) { LogStash::SETTINGS }
let(:pipeline_settings) { {} }
let(:max_retry) { 120.times }
let(:max_retry) { 120 }

before :each do
pipeline_workers_setting = LogStash::SETTINGS.get_setting("pipeline.workers")
Expand Down Expand Up @@ -813,63 +813,99 @@ class TestPipeline < LogStash::Pipeline
end

context "global metric" do
let(:collected_metric) { metric_store.get_with_path("stats/events") }
let(:collected_metric) {metric_store.get_with_path("stats/events")}

it "populates the different metrics" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
expect(collected_metric[:stats][:events][:duration_in_millis].value).not_to be_nil
expect(collected_metric[:stats][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:events][:filtered].value).to eq(number_of_events)
expect(collected_metric[:stats][:events][:out].value).to eq(number_of_events)
puts "************* populates the different metrics"
begin
expect(collected_metric[:stats][:events][:duration_in_millis].value).not_to be_nil
expect(collected_metric[:stats][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:events][:filtered].value).to eq(number_of_events)
expect(collected_metric[:stats][:events][:out].value).to eq(number_of_events)
rescue => exception
puts exception.backtrace
raise
end
end
end
end

context "pipelines" do
let(:collected_metric) { metric_store.get_with_path("stats/pipelines/") }
let(:collected_metric) {metric_store.get_with_path("stats/pipelines/")}

it "populates the pipelines core metrics" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
expect(collected_metric[:stats][:pipelines][:main][:events][:duration_in_millis].value).not_to be_nil
expect(collected_metric[:stats][:pipelines][:main][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:events][:filtered].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:events][:out].value).to eq(number_of_events)
puts "************* populates the pipelines core metrics"
begin
expect(collected_metric[:stats][:pipelines][:main][:events][:duration_in_millis].value).not_to be_nil
expect(collected_metric[:stats][:pipelines][:main][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:events][:filtered].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:events][:out].value).to eq(number_of_events)
rescue => exception
puts exception.backtrace
raise
end
end
end

it "populates the filter metrics" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
puts "************* populates the filter metrics"
[multiline_id, multiline_id_other].map(&:to_sym).each do |id|
[:in, :out].each do |metric_key|
plugin_name = id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:filters][plugin_name][:events][metric_key].value).to eq(number_of_events)
begin
plugin_name = id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:filters][plugin_name][:events][metric_key].value).to eq(number_of_events)
rescue => exception
puts exception.backtrace
raise
end
end
end
end
end

it "populates the output metrics" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
plugin_name = dummy_output_id.to_sym

expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:out].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:duration_in_millis].value).not_to be_nil
puts "************* populates the output metrics"
begin
plugin_name = dummy_output_id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:in].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:out].value).to eq(number_of_events)
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:events][:duration_in_millis].value).not_to be_nil
rescue => exception
puts exception.backtrace
raise
end
end
end

it "populates the name of the output plugin" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
plugin_name = dummy_output_id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:name].value).to eq(::LogStash::Outputs::DummyOutput.config_name)
puts "************* populates the name of the output plugin"
begin
plugin_name = dummy_output_id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:outputs][plugin_name][:name].value).to eq(::LogStash::Outputs::DummyOutput.config_name)
rescue => exception
puts exception.backtrace
raise
end

end
end

it "populates the name of the filter plugin" do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
[multiline_id, multiline_id_other].map(&:to_sym).each do |id|
plugin_name = id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:filters][plugin_name][:name].value).to eq(LogStash::Filters::Multiline.config_name)
puts "************* populates the name of the filter plugin"
begin
[multiline_id, multiline_id_other].map(&:to_sym).each do |id|
plugin_name = id.to_sym
expect(collected_metric[:stats][:pipelines][:main][:plugins][:filters][plugin_name][:name].value).to eq(LogStash::Filters::Multiline.config_name)
end
rescue => exception
puts exception.backtrace
raise
end
end
end
Expand Down

0 comments on commit aaf96f3

Please sign in to comment.