From 6064587bc48d2e542cf7be7022f4e7cbcd661afa Mon Sep 17 00:00:00 2001 From: Andrea Selva Date: Fri, 11 Oct 2024 15:26:53 +0200 Subject: [PATCH] Keeps global settings aligned across entities used in the test for StatsEventFactory Fixes a potential flaky test, due to shared (LogStash:SETTINGS) fixture across the test base. Forward port the commit 609155a61b693d7e38945b8e4a4aae4b7c27411b used to fix the non clean backport PR #16531 of #16525 to 8.x. LogStash:SETTINGS is used in the constructor of LogStash::Inputs::Metrics::StatsEventFactory to query the value of api.enabled. This PR keeps updated the value for the setting provided to the Agent constructor and to the StatsEventFactory. --- .../spec/monitoring/inputs/metrics/stats_event_factory_spec.rb | 3 +++ 1 file changed, 3 insertions(+) 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 90387e5cb4e..b37b13a26af 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 @@ -59,6 +59,8 @@ let(:agent_task) { start_agent(agent) } before :each do + @existing_api_enabled = LogStash::SETTINGS.get_value("api.enabled") + LogStash::SETTINGS.set_value("api.enabled", webserver_enabled) agent agent_task @@ -86,6 +88,7 @@ after :each do agent.shutdown agent_task.wait + LogStash::SETTINGS.set_value("api.enabled", @existing_api_enabled) LogStash::SETTINGS.set_value("monitoring.enabled", false) end