Skip to content

Commit 7e9fdae

Browse files
Remove pool subtest
1 parent 97d4821 commit 7e9fdae

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

x/mongo/driver/topology/pool_test.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -842,79 +842,6 @@ func TestPool_checkOut(t *testing.T) {
842842
assert.Containsf(t, err.Error(), "canceled", `expected error message to contain "canceled"`)
843843
}
844844

845-
p.close(context.Background())
846-
})
847-
t.Run("discards connections closed by the server side", func(t *testing.T) {
848-
t.Parallel()
849-
850-
cleanup := make(chan struct{})
851-
defer close(cleanup)
852-
853-
ncs := make(chan net.Conn, 2)
854-
addr := bootstrapConnections(t, 2, func(nc net.Conn) {
855-
// Send all "server-side" connections to a channel so we can
856-
// interact with them during the test.
857-
ncs <- nc
858-
859-
<-cleanup
860-
_ = nc.Close()
861-
})
862-
863-
d := newdialer(&net.Dialer{})
864-
p := newPool(poolConfig{
865-
Address: address.Address(addr.String()),
866-
}, WithDialer(func(Dialer) Dialer { return d }))
867-
err := p.ready()
868-
require.NoError(t, err)
869-
870-
// Add 1 idle connection to the pool by checking-out and checking-in
871-
// a connection.
872-
conn, err := p.checkOut(context.Background())
873-
require.NoError(t, err)
874-
err = p.checkIn(conn)
875-
require.NoError(t, err)
876-
assertConnectionsOpened(t, d, 1)
877-
assert.Equalf(t, 1, p.availableConnectionCount(), "should be 1 idle connections in pool")
878-
assert.Equalf(t, 1, p.totalConnectionCount(), "should be 1 total connection in pool")
879-
880-
// Make that connection appear as if it's been idle for a minute.
881-
conn.idleStart.Store(time.Now().Add(-1 * time.Minute))
882-
883-
// Close the "server-side" of the connection we just created. The idle
884-
// connection in the pool is now unusable because the "server-side"
885-
// closed it.
886-
nc := <-ncs
887-
err = nc.Close()
888-
require.NoError(t, err)
889-
890-
// In a separate goroutine, write a valid wire message to the 2nd
891-
// connection that's about to be created. Stop waiting for a 2nd
892-
// connection after 100ms to prevent leaking a goroutine.
893-
go func() {
894-
select {
895-
case nc := <-ncs:
896-
_, err := nc.Write([]byte{5, 0, 0, 0, 0})
897-
require.NoError(t, err, "Write error")
898-
case <-time.After(100 * time.Millisecond):
899-
}
900-
}()
901-
902-
// Check out a connection and try to read from it. Expect the pool to
903-
// discard the connection that was closed by the "server-side" and
904-
// return a newly created connection instead.
905-
conn, err = p.checkOut(context.Background())
906-
require.NoError(t, err)
907-
msg, err := conn.readWireMessage(context.Background())
908-
require.NoError(t, err)
909-
assert.Equal(t, []byte{5, 0, 0, 0, 0}, msg)
910-
911-
err = p.checkIn(conn)
912-
require.NoError(t, err)
913-
914-
assertConnectionsOpened(t, d, 2)
915-
assert.Equalf(t, 1, p.availableConnectionCount(), "should be 1 idle connections in pool")
916-
assert.Equalf(t, 1, p.totalConnectionCount(), "should be 1 total connection in pool")
917-
918845
p.close(context.Background())
919846
})
920847
}

0 commit comments

Comments
 (0)