@@ -15,15 +15,12 @@ import (
15
15
"runtime"
16
16
"strings"
17
17
"testing"
18
- "time"
19
18
20
19
"go.mongodb.org/mongo-driver/bson"
21
20
"go.mongodb.org/mongo-driver/internal/testutil/assert"
22
- "go.mongodb.org/mongo-driver/mongo"
23
21
"go.mongodb.org/mongo-driver/mongo/description"
24
22
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
25
23
"go.mongodb.org/mongo-driver/mongo/options"
26
- "go.mongodb.org/mongo-driver/mongo/readpref"
27
24
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
28
25
"go.mongodb.org/mongo-driver/x/mongo/driver/topology"
29
26
)
@@ -40,26 +37,19 @@ type seedlistTest struct {
40
37
NumHosts * int `bson:"numHosts"`
41
38
Error bool `bson:"error"`
42
39
Options bson.Raw `bson:"options"`
43
- Ping * bool `bson:"ping"`
44
40
}
45
41
46
42
func TestInitialDNSSeedlistDiscoverySpec (t * testing.T ) {
47
43
mt := mtest .New (t , noClientOpts )
48
44
defer mt .Close ()
49
45
50
46
mt .RunOpts ("replica set" , mtest .NewOptions ().Topologies (mtest .ReplicaSet ).CreateClient (false ), func (mt * mtest.T ) {
51
- mt .Parallel ()
52
-
53
47
runSeedlistDiscoveryDirectory (mt , "replica-set" )
54
48
})
55
49
mt .RunOpts ("sharded" , mtest .NewOptions ().Topologies (mtest .Sharded ).CreateClient (false ), func (mt * mtest.T ) {
56
- mt .Parallel ()
57
-
58
50
runSeedlistDiscoveryDirectory (mt , "sharded" )
59
51
})
60
52
mt .RunOpts ("load balanced" , mtest .NewOptions ().Topologies (mtest .LoadBalanced ).CreateClient (false ), func (mt * mtest.T ) {
61
- mt .Parallel ()
62
-
63
53
runSeedlistDiscoveryDirectory (mt , "load-balanced" )
64
54
})
65
55
}
@@ -73,24 +63,6 @@ func runSeedlistDiscoveryDirectory(mt *mtest.T, subdirectory string) {
73
63
}
74
64
}
75
65
76
- // runSeedlistDiscoveryPingTest will create a new connection using the test URI and attempt to "ping" the server.
77
- func runSeedlistDiscoveryPingTest (mt * mtest.T , clientOpts * options.ClientOptions ) {
78
- ctx := context .Background ()
79
-
80
- client , err := mongo .Connect (ctx , clientOpts )
81
- assert .Nil (mt , err , "Connect error: %v" , err )
82
-
83
- defer func () { _ = client .Disconnect (ctx ) }()
84
-
85
- // Create a context with a timeout to prevent the ping operation from blocking indefinitely.
86
- pingCtx , cancel := context .WithTimeout (ctx , 1 * time .Second )
87
- defer cancel ()
88
-
89
- // Ping the server.
90
- err = client .Ping (pingCtx , readpref .Nearest ())
91
- assert .Nil (mt , err , "Ping error: %v" , err )
92
- }
93
-
94
66
func runSeedlistDiscoveryTest (mt * mtest.T , file string ) {
95
67
content , err := ioutil .ReadFile (file )
96
68
assert .Nil (mt , err , "ReadFile error for %v: %v" , file , err )
@@ -159,10 +131,6 @@ func runSeedlistDiscoveryTest(mt *mtest.T, file string) {
159
131
_ , err := getServerByAddress (host , topo )
160
132
assert .Nil (mt , err , "error finding host %q: %v" , host , err )
161
133
}
162
-
163
- if ping := test .Ping ; ping == nil || * ping {
164
- runSeedlistDiscoveryPingTest (mt , opts )
165
- }
166
134
}
167
135
168
136
func buildSet (list []string ) map [string ]struct {} {
@@ -262,14 +230,6 @@ func getServerByAddress(address string, topo *topology.Topology) (description.Se
262
230
if err != nil {
263
231
return description.Server {}, err
264
232
}
265
-
266
- // If the selected server is a topology.SelectedServer, then we can get the description without creating a
267
- // connect pool.
268
- topologySelectedServer , ok := selectedServer .(* topology.SelectedServer )
269
- if ok {
270
- return topologySelectedServer .Description ().Server , nil
271
- }
272
-
273
233
selectedServerConnection , err := selectedServer .Connection (context .Background ())
274
234
if err != nil {
275
235
return description.Server {}, err
0 commit comments