From f07ab71ee12fd9de992fe317b790caaf8364d5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paolo=20Chil=C3=A0?= Date: Wed, 5 Mar 2025 12:25:57 +0100 Subject: [PATCH 1/2] Increase timeout for assertions in TestSetLogLevelFleetManaged (#7190) Fleet checkins may take up to 5 minutes so we need to increase timeouts for assertions in TestSetLogLevelFleetManaged to account for it as the agent may apply log level settings while there's already a Fleet check-in in progress. Settings timeouts for retrieving the correct log level in Fleet to 6 minutes should give enough time to agent to set the log level and communicate it to Fleet in a new check-in request. (cherry picked from commit 12fa5571af13be8c419a6401645867af518671c2) # Conflicts: # testing/integration/log_level_test.go --- testing/integration/log_level_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testing/integration/log_level_test.go b/testing/integration/log_level_test.go index acf7fe341ed..38070d7a7c0 100644 --- a/testing/integration/log_level_test.go +++ b/testing/integration/log_level_test.go @@ -40,9 +40,13 @@ func TestSetLogLevelFleetManaged(t *testing.T) { Sudo: true, }) +<<<<<<< HEAD t.Skip("Skipping due to https://github.com/elastic/elastic-agent/issues/5193") deadline := time.Now().Add(10 * time.Minute) +======= + deadline := time.Now().Add(30 * time.Minute) +>>>>>>> 12fa5571a (Increase timeout for assertions in TestSetLogLevelFleetManaged (#7190)) ctx, cancel := testcontext.WithDeadline(t, context.Background(), deadline) defer cancel() @@ -116,7 +120,7 @@ func testLogLevelSetViaFleet(ctx context.Context, f *atesting.Fixture, agentID s } t.Logf("Fleet metadata log level for agent %q: %q policy log level: %q", agentID, fleetMetadataLogLevel, policyLogLevel) return fleetMetadataLogLevel == policyLogLevel.String() - }, 30*time.Second, time.Second, "agent never communicated policy log level %q to Fleet", policyLogLevel) + }, 6*time.Minute, 30*time.Second, "agent never communicated policy log level %q to Fleet", policyLogLevel) // Step 2: set a different log level for the specific agent using Settings action // set agent log level and verify that it takes precedence over the policy one @@ -147,7 +151,7 @@ func testLogLevelSetViaFleet(ctx context.Context, f *atesting.Fixture, agentID s } t.Logf("Fleet metadata log level for agent %q: %q agent log level: %q", agentID, fleetMetadataLogLevel, agentLogLevel) return fleetMetadataLogLevel == agentLogLevel - }, 30*time.Second, time.Second, "agent never communicated agent-specific log level %q to Fleet", agentLogLevel) + }, 6*time.Minute, 30*time.Second, "agent never communicated agent-specific log level %q to Fleet", agentLogLevel) // Step 3: Clear the agent-specific log level override, verify that we revert to policy log level t.Logf("Clearing agent log level, expecting log level to revert back to %q", policyLogLevel) @@ -175,7 +179,7 @@ func testLogLevelSetViaFleet(ctx context.Context, f *atesting.Fixture, agentID s } t.Logf("Fleet metadata log level for agent %q: %q policy log level: %q", agentID, fleetMetadataLogLevel, policyLogLevel) return fleetMetadataLogLevel == policyLogLevel.String() - }, 30*time.Second, time.Second, "agent never communicated reverting to policy log level %q to Fleet", policyLogLevel) + }, 6*time.Minute, 30*time.Second, "agent never communicated reverting to policy log level %q to Fleet", policyLogLevel) // Step 4: Clear the log level in policy and verify that agent reverts to the initial log level t.Logf("Clearing policy log level, expecting log level to revert back to %q", initialLogLevel) @@ -203,7 +207,7 @@ func testLogLevelSetViaFleet(ctx context.Context, f *atesting.Fixture, agentID s } t.Logf("Fleet metadata log level for agent %q: %q initial log level: %q", agentID, fleetMetadataLogLevel, initialLogLevel) return fleetMetadataLogLevel == initialLogLevel - }, 30*time.Second, time.Second, "agent never communicated initial log level %q to Fleet", initialLogLevel) + }, 6*time.Minute, 30*time.Second, "agent never communicated initial log level %q to Fleet", initialLogLevel) } func waitForAgentAndFleetHealthy(ctx context.Context, t *testing.T, f *atesting.Fixture) bool { From 20beee2539189fcca5ee09aaed4c8e685c378e5a Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Wed, 5 Mar 2025 13:55:24 +0100 Subject: [PATCH 2/2] Fix conflicts --- testing/integration/log_level_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/testing/integration/log_level_test.go b/testing/integration/log_level_test.go index 38070d7a7c0..02b0806df75 100644 --- a/testing/integration/log_level_test.go +++ b/testing/integration/log_level_test.go @@ -40,13 +40,7 @@ func TestSetLogLevelFleetManaged(t *testing.T) { Sudo: true, }) -<<<<<<< HEAD - t.Skip("Skipping due to https://github.com/elastic/elastic-agent/issues/5193") - - deadline := time.Now().Add(10 * time.Minute) -======= deadline := time.Now().Add(30 * time.Minute) ->>>>>>> 12fa5571a (Increase timeout for assertions in TestSetLogLevelFleetManaged (#7190)) ctx, cancel := testcontext.WithDeadline(t, context.Background(), deadline) defer cancel()