Skip to content

Commit

Permalink
Increase timeout for assertions in TestSetLogLevelFleetManaged (#7190)
Browse files Browse the repository at this point in the history
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 12fa557)
  • Loading branch information
pchila authored and mergify[bot] committed Mar 5, 2025
1 parent 16a0527 commit c81101a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions testing/integration/log_level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestSetLogLevelFleetManaged(t *testing.T) {
Sudo: true,
})

deadline := time.Now().Add(10 * time.Minute)
deadline := time.Now().Add(30 * time.Minute)
ctx, cancel := testcontext.WithDeadline(t, context.Background(), deadline)
defer cancel()

Expand Down Expand Up @@ -114,7 +114,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
Expand Down Expand Up @@ -145,7 +145,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)
Expand Down Expand Up @@ -173,7 +173,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)
Expand Down Expand Up @@ -201,7 +201,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 {
Expand Down

0 comments on commit c81101a

Please sign in to comment.