Make TestConnCheckConn less timing sensitive for CI

pull/1651/head
Jack Christensen 2023-06-17 17:12:58 -05:00
parent bc8b1ca320
commit 5b7cc8e215
1 changed files with 6 additions and 4 deletions

View File

@ -2494,10 +2494,12 @@ func TestConnCheckConn(t *testing.T) {
_, err = c2.Exec(ctx, fmt.Sprintf("select pg_terminate_backend(%d)", c1.PID())).ReadAll()
require.NoError(t, err)
// Give a little time for the signal to actually kill the backend.
time.Sleep(500 * time.Millisecond)
err = c1.CheckConn()
// It may take a while for the server to kill the backend. Retry until the error is detected or the test context is
// canceled.
for err == nil && ctx.Err() == nil {
time.Sleep(50 * time.Millisecond)
err = c1.CheckConn()
}
require.Error(t, err)
}