Skip to content

Commit a2fea6a

Browse files
committed
Improve TestFlyDeployHAPlacement error logging
The test was failing with 'Condition never satisfied' but we couldn't see what the actual error was. This makes debugging impossible. Changes: - Capture the last error message so it appears in test output - Use t.Logf to log errors during retries instead of silently failing - Show the last error in the EventuallyWithT failure message - Use assert.Fail instead of f.Fatalf for unexpected errors so we see them This will help us understand whether: - The error message is different than expected - There's a different error we should handle - The retry logic is working correctly
1 parent 3173ddf commit a2fea6a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/preflight/fly_deploy_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ func TestFlyDeployHAPlacement(t *testing.T) {
9393
// Retry the deploy command to handle Corrosion replication lag race conditions
9494
// The backend may not have replicated the app record to all hosts yet when
9595
// creating the second machine for HA, resulting in "sql: no rows in result set" errors
96+
var lastError string
9697
require.EventuallyWithT(f, func(c *assert.CollectT) {
9798
result := f.FlyAllowExitFailure("deploy --buildkit --remote-only")
9899
if result.ExitCode() != 0 {
99100
stderr := result.StdErrString()
101+
lastError = stderr
100102
// Only retry if it's the known Corrosion replication lag error
101103
if strings.Contains(stderr, "failed to get app: sql: no rows in result set") {
104+
t.Logf("Corrosion replication lag detected, retrying... (error: %s)", stderr)
102105
assert.Fail(c, "Corrosion replication lag, retrying...")
103106
} else {
104-
// If it's a different error, fail immediately
105-
f.Fatalf("deploy failed with unexpected error: %s", stderr)
107+
// Log the unexpected error and fail without retrying
108+
t.Logf("Deploy failed with unexpected error (will not retry): %s", stderr)
109+
assert.Fail(c, fmt.Sprintf("deploy failed with unexpected error: %s", stderr))
106110
}
107111
}
108-
}, 30*time.Second, 5*time.Second, "deploy should succeed after Corrosion replication")
112+
}, 30*time.Second, 5*time.Second, "deploy should succeed after Corrosion replication, last error: %s", lastError)
109113

110114
assertHostDistribution(t, f, appName, 2)
111115
}

0 commit comments

Comments
 (0)