@@ -143,12 +143,12 @@ func testPollingSRVRecordsSpec(t *testing.T, uri string) {
143
143
t .Run (tt .name , func (t * testing.T ) {
144
144
cfg , err := NewConfig (options .Client ().ApplyURI (uri ), nil )
145
145
require .NoError (t , err , "error constructing topology configs: %v" , err )
146
+ cfg .RescanSRVInterval = time .Millisecond * 5
146
147
147
148
topo , err := New (cfg )
148
149
require .NoError (t , err , "Could not create the topology: %v" , err )
149
150
mockRes := newMockResolver (tt .recordsToAdd , tt .recordsToRemove , tt .lookupFail , tt .lookupTimeout )
150
151
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
151
- topo .rescanSRVInterval = time .Millisecond * 5
152
152
err = topo .Connect ()
153
153
require .NoError (t , err , "Could not Connect to the topology: %v" , err )
154
154
@@ -172,12 +172,12 @@ func TestPollSRVRecords(t *testing.T) {
172
172
uri := "mongodb+srv://test1.test.build.10gen.cc/?heartbeatFrequencyMS=100"
173
173
cfg , err := NewConfig (options .Client ().ApplyURI (uri ), nil )
174
174
require .NoError (t , err , "error constructing topology config: %v" , err )
175
+ cfg .RescanSRVInterval = time .Millisecond * 5
175
176
176
177
topo , err := New (cfg )
177
178
require .NoError (t , err , "Could not create the topology: %v" , err )
178
179
mockRes := newMockResolver (nil , nil , false , false )
179
180
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
180
- topo .rescanSRVInterval = time .Millisecond * 5
181
181
err = topo .Connect ()
182
182
require .NoError (t , err , "Could not Connect to the topology: %v" , err )
183
183
topo .serversLock .Lock ()
@@ -214,12 +214,12 @@ func TestPollSRVRecords(t *testing.T) {
214
214
uri := "mongodb+srv://test1.test.build.10gen.cc/?heartbeatFrequencyMS=100"
215
215
cfg , err := NewConfig (options .Client ().ApplyURI (uri ), nil )
216
216
require .NoError (t , err , "error constructing topology config: %v" , err )
217
+ cfg .RescanSRVInterval = time .Millisecond * 5
217
218
218
219
topo , err := New (cfg )
219
220
require .NoError (t , err , "Could not create the topology: %v" , err )
220
221
mockRes := newMockResolver ([]* net.SRV {{"blah.bleh" , 27019 , 0 , 0 }, {"localhost.test.build.10gen.cc." , 27020 , 0 , 0 }}, nil , false , false )
221
222
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
222
- topo .rescanSRVInterval = time .Millisecond * 5
223
223
err = topo .Connect ()
224
224
require .NoError (t , err , "Could not Connect to the topology: %v" , err )
225
225
@@ -241,13 +241,13 @@ func TestPollSRVRecords(t *testing.T) {
241
241
uri := "mongodb+srv://test1.test.build.10gen.cc/?heartbeatFrequencyMS=100"
242
242
cfg , err := NewConfig (options .Client ().ApplyURI (uri ), nil )
243
243
require .NoError (t , err , "error constructing topology config: %v" , err )
244
+ cfg .RescanSRVInterval = time .Millisecond * 5
244
245
245
246
topo , err := New (cfg )
246
247
require .NoError (t , err , "Could not create the topology: %v" , err )
247
248
mockRes := newMockResolver (nil , nil , false , false )
248
249
mockRes .fail = 1
249
250
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
250
- topo .rescanSRVInterval = time .Millisecond * 5
251
251
err = topo .Connect ()
252
252
require .NoError (t , err , "Could not Connect to the topology: %v" , err )
253
253
@@ -272,6 +272,7 @@ func TestPollingSRVRecordsLoadBalanced(t *testing.T) {
272
272
273
273
cfg , err := NewConfig (options .Client ().ApplyURI (uri ).SetLoadBalanced (true ), nil )
274
274
require .NoError (t , err , "error constructing topology config: %v" , err )
275
+ cfg .RescanSRVInterval = time .Millisecond * 5
275
276
276
277
topo , err := New (cfg )
277
278
require .NoError (t , err , "Could not create the topology: %v" , err )
@@ -294,7 +295,6 @@ func TestPollingSRVRecordsLoadBalanced(t *testing.T) {
294
295
295
296
topo := createLBTopology (t , "mongodb+srv://test3.test.build.10gen.cc" )
296
297
topo .dnsResolver = dnsResolver
297
- topo .rescanSRVInterval = time .Millisecond * 5
298
298
err := topo .Connect ()
299
299
assert .Nil (t , err , "Connect error: %v" , err )
300
300
defer func () {
@@ -303,7 +303,7 @@ func TestPollingSRVRecordsLoadBalanced(t *testing.T) {
303
303
304
304
// Wait for 2*rescanInterval and assert that polling was not done and the final host list only contains the
305
305
// original host.
306
- time .Sleep (2 * topo .rescanSRVInterval )
306
+ time .Sleep (2 * topo .cfg . RescanSRVInterval )
307
307
lookupCalledTimes := atomic .LoadInt32 (& mockResolver .ranLookup )
308
308
assert .Equal (t , int32 (0 ), lookupCalledTimes , "expected SRV lookup to occur 0 times, got %d" , lookupCalledTimes )
309
309
expectedHosts := []string {"localhost.test.build.10gen.cc:27017" }
@@ -320,13 +320,13 @@ func TestPollSRVRecordsMaxHosts(t *testing.T) {
320
320
uri := "mongodb+srv://test1.test.build.10gen.cc/?heartbeatFrequencyMS=100"
321
321
cfg , err := NewConfig (options .Client ().ApplyURI (uri ).SetSRVMaxHosts (srvMaxHosts ), nil )
322
322
require .NoError (t , err , "error constructing topology config: %v" , err )
323
+ cfg .RescanSRVInterval = time .Millisecond * 5
323
324
324
325
topo , err := New (cfg )
325
326
require .NoError (t , err , "Could not create the topology: %v" , err )
326
327
327
328
mockRes := newMockResolver (recordsToAdd , recordsToRemove , false , false )
328
329
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
329
- topo .rescanSRVInterval = time .Millisecond * 5
330
330
err = topo .Connect ()
331
331
assert .Nil (t , err , "Connect error: %v" , err )
332
332
@@ -392,13 +392,13 @@ func TestPollSRVRecordsServiceName(t *testing.T) {
392
392
uri := "mongodb+srv://test22.test.build.10gen.cc/?heartbeatFrequencyMS=100&srvServiceName=customname"
393
393
cfg , err := NewConfig (options .Client ().ApplyURI (uri ).SetSRVServiceName (srvServiceName ), nil )
394
394
require .NoError (t , err , "error constructing topology config: %v" , err )
395
+ cfg .RescanSRVInterval = time .Millisecond * 5
395
396
396
397
topo , err := New (cfg )
397
398
require .NoError (t , err , "Could not create the topology: %v" , err )
398
399
399
400
mockRes := newMockResolver (recordsToAdd , recordsToRemove , false , false )
400
401
topo .dnsResolver = & dns.Resolver {mockRes .LookupSRV , mockRes .LookupTXT }
401
- topo .rescanSRVInterval = time .Millisecond * 5
402
402
err = topo .Connect ()
403
403
assert .Nil (t , err , "Connect error: %v" , err )
404
404
0 commit comments