107
107
db_user = res ['username' ] or db_user
108
108
db_pwd = res ['password' ] or db_pwd
109
109
elif TEST_SERVERLESS :
110
- res = parse_uri ( os . environ [ "MONGODB_URI" ])
111
- host , port = res [ 'nodelist' ]. pop ( 0 )
112
- additional_serverless_mongoses = res ['nodelist' ]
110
+ TEST_LOADBALANCER = True
111
+ res = parse_uri ( SINGLE_MONGOS_LB_URI )
112
+ host , port = res ['nodelist' ][ 0 ]
113
113
db_user = res ['username' ] or db_user
114
114
db_pwd = res ['password' ] or db_pwd
115
115
TLS_OPTIONS = {'tls' : True }
116
+ # Spec says serverless tests must be run with compression.
117
+ COMPRESSORS = COMPRESSORS or 'zlib'
116
118
117
119
118
120
def is_server_resolvable ():
@@ -236,7 +238,7 @@ def __init__(self):
236
238
self .version = Version (- 1 ) # Needs to be comparable with Version
237
239
self .auth_enabled = False
238
240
self .test_commands_enabled = False
239
- self .server_parameters = None
241
+ self .server_parameters = {}
240
242
self .is_mongos = False
241
243
self .mongoses = []
242
244
self .is_rs = False
@@ -251,7 +253,7 @@ def __init__(self):
251
253
self .is_data_lake = False
252
254
self .load_balancer = TEST_LOADBALANCER
253
255
self .serverless = TEST_SERVERLESS
254
- if self .load_balancer :
256
+ if self .load_balancer or self . serverless :
255
257
self .default_client_options ["loadBalanced" ] = True
256
258
if COMPRESSORS :
257
259
self .default_client_options ["compressors" ] = COMPRESSORS
@@ -402,7 +404,11 @@ def _init_client(self):
402
404
self .w = len (hello .get ("hosts" , [])) or 1
403
405
self .version = Version .from_client (self .client )
404
406
405
- if TEST_SERVERLESS :
407
+ if self .serverless :
408
+ self .server_parameters = {
409
+ 'requireApiVersion' : False ,
410
+ 'enableTestCommands' : True ,
411
+ }
406
412
self .test_commands_enabled = True
407
413
self .has_ipv6 = False
408
414
else :
@@ -422,14 +428,11 @@ def _init_client(self):
422
428
423
429
self .is_mongos = (self .hello .get ('msg' ) == 'isdbgrid' )
424
430
if self .is_mongos :
425
- if self .serverless :
426
- self .mongoses .append (self .client .address )
427
- self .mongoses .extend (additional_serverless_mongoses )
428
- else :
431
+ address = self .client .address
432
+ self .mongoses .append (address )
433
+ if not self .serverless :
429
434
# Check for another mongos on the next port.
430
- address = self .client .address
431
435
next_address = address [0 ], address [1 ] + 1
432
- self .mongoses .append (address )
433
436
mongos_client = self ._connect (
434
437
* next_address , ** self .default_client_options )
435
438
if mongos_client :
0 commit comments