Skip to content

Commit

Permalink
test: fix flaky TestAdd_Close_concurrent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oleg-jukovec committed Dec 10, 2024
1 parent ebdf986 commit e06977e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pool/connection_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,12 @@ func TestAdd_Close_concurrent(t *testing.T) {

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

Expand Down

0 comments on commit e06977e

Please sign in to comment.