Skip to content

Commit 12dbfcf

Browse files
committed
fix: use polling loop in async detach test to avoid CI flake
Replace fixed 200ms sleep with a polling loop (50ms interval, 5s timeout) in TestHooks_BidirectionalPrompt_AsyncDetach. The fixed sleep was insufficient on CI runners under load, causing consistent test failures. Signed-off-by: Meng Yan <myan@redhat.com>
1 parent c346d58 commit 12dbfcf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

internal/hooks/hooks_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,8 +1398,14 @@ echo "async_done" > `+markerFile+`
13981398
t.Error("async detach should not set PermissionAllow")
13991399
}
14001400

1401-
// Wait briefly for background goroutine to write the marker
1402-
time.Sleep(200 * time.Millisecond)
1401+
// Poll for the marker file with a generous timeout for CI
1402+
deadline := time.Now().Add(5 * time.Second)
1403+
for time.Now().Before(deadline) {
1404+
if _, err := os.Stat(markerFile); err == nil {
1405+
break
1406+
}
1407+
time.Sleep(50 * time.Millisecond)
1408+
}
14031409
if _, err := os.Stat(markerFile); os.IsNotExist(err) {
14041410
t.Error("expected async hook to have run in background")
14051411
}

0 commit comments

Comments
 (0)