Skip to content

Commit e06977e

Browse files
committed
test: fix flaky TestAdd_Close_concurrent
An error may appear in a test if a connection to an instance was canceled by a concurrent pool.Close() call: ``` failed to dial: dial tcp host:port: operation was canceled ``` It is expected behavior and we should to fix the test.
1 parent ebdf986 commit e06977e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pool/connection_pool_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,12 @@ func TestAdd_Close_concurrent(t *testing.T) {
676676

677677
err = connPool.Add(ctx, makeInstance(serv1, connOpts))
678678
if err != nil {
679-
assert.Equal(t, pool.ErrClosed, err)
679+
// Pool should be already closed or in-progress connect is
680+
// canceled.
681+
if err != pool.ErrClosed {
682+
// There is no constant in the `net` package for the error.
683+
assert.ErrorContains(t, err, "operation was canceled")
684+
}
680685
}
681686
}()
682687

0 commit comments

Comments
 (0)