diff --git a/x-pack/spec/monitoring/inputs/metrics/stats_event_factory_spec.rb b/x-pack/spec/monitoring/inputs/metrics/stats_event_factory_spec.rb index c563306fc01..90387e5cb4e 100644 --- a/x-pack/spec/monitoring/inputs/metrics/stats_event_factory_spec.rb +++ b/x-pack/spec/monitoring/inputs/metrics/stats_event_factory_spec.rb @@ -50,6 +50,7 @@ let(:pipeline_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone.merge({ "pipeline.id" => "main", "config.string" => config, + "api.enabled" => webserver_enabled, }) } let(:agent) { LogStash::Agent.new(pipeline_settings) } @@ -70,14 +71,16 @@ # easily observable, feel free to refactor with a better "timing" test here. wait(60).for { collector.snapshot_metric.metric_store.size }.to be >= 72 - # Wait http server is up - wait(120).for { - begin - collector.snapshot_metric.metric_store.get_shallow(:http_address) - rescue LogStash::Instrument::MetricStore::MetricNotFound => e - nil - end - }.not_to be_nil + if webserver_enabled + # Wait http server is up + wait(120).for { + begin + collector.snapshot_metric.metric_store.get_shallow(:http_address) + rescue LogStash::Instrument::MetricStore::MetricNotFound => e + nil + end + }.not_to be_nil + end end after :each do @@ -86,14 +89,19 @@ LogStash::SETTINGS.set_value("monitoring.enabled", false) end - context "new model" do - it_behaves_like("new model monitoring event with webserver setting") do - let(:webserver_enabled) {false} - end - it_behaves_like("new model monitoring event with webserver setting") do - let(:webserver_enabled) {true} - end - end + context "new model" do + context "with webserver disabled" do + it_behaves_like("new model monitoring event with webserver setting") do + let(:webserver_enabled) {false} + end + end + + context "with webserver enabled" do + it_behaves_like("new model monitoring event with webserver setting") do + let(:webserver_enabled) {true} + end + end + end # TODO: fix issue https://github.com/elastic/logstash/issues/12711 xcontext "old model" do