Skip to content

Commit

Permalink
Make TestConnCheckConn less timing sensitive for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jackc committed Jun 17, 2023
1 parent bc8b1ca commit 5b7cc8e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pgconn/pgconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 5b7cc8e

Please sign in to comment.