From 0509053a69e7af4b88a6b0cdc90e6c493e65bb6b Mon Sep 17 00:00:00 2001 From: henrygd Date: Sat, 19 Sep 2026 00:02:29 -0400 Subject: [PATCH] test: wait for hub system status in agent WebSocket integration test --- internal/hub/agent_connect_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/hub/agent_connect_test.go b/internal/hub/agent_connect_test.go index c07849cb..13f57b28 100644 --- a/internal/hub/agent_connect_test.go +++ b/internal/hub/agent_connect_test.go @@ -978,11 +978,18 @@ func TestAgentWebSocketIntegration(t *testing.T) { } } - // Verify system status - updatedSystemRecord, err := testApp.FindRecordById("systems", systemRecord.Id) - require.NoError(t, err) - status := updatedSystemRecord.GetString("status") - assert.Equal(t, tc.expectSystemStatus, status, "System status should match expected value") + // A connected WebSocket does not mean the hub has finished verifying + // the agent and updating the system. Wait for the database state rather + // than assuming that work completes within a fixed sleep under load. + var status string + require.EventuallyWithT(t, func(c *assert.CollectT) { + updatedSystemRecord, err := testApp.FindRecordById("systems", systemRecord.Id) + if !assert.NoError(c, err) { + return + } + status = updatedSystemRecord.GetString("status") + assert.Equal(c, tc.expectSystemStatus, status, "System status should match expected value") + }, 5*time.Second, 20*time.Millisecond) t.Logf("%s - System status: %s, Fingerprint: %s", tc.description, status, finalFingerprint) })