Skip to content

Commit

Permalink
[test] Fix xpack test to check for http_address stats only if the web…
Browse files Browse the repository at this point in the history
…server is enabled (#16525)

Set the 'api.enabled' setting to reflect the flag webserver_enabled and consequently test for http_address presence in settings iff the web server is enabled.
  • Loading branch information
andsel authored Oct 10, 2024
1 parent dc24f02 commit 6484721
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions x-pack/spec/monitoring/inputs/metrics/stats_event_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6484721

Please sign in to comment.