64
64
MONGODB_API_VERSION ,
65
65
MULTI_MONGOS_LB_URI ,
66
66
TEST_LOADBALANCER ,
67
- TEST_SERVERLESS ,
68
67
TLS_OPTIONS ,
69
68
SystemCertsPatcher ,
70
69
client_knobs ,
@@ -123,9 +122,8 @@ def __init__(self):
123
122
self .conn_lock = threading .Lock ()
124
123
self .is_data_lake = False
125
124
self .load_balancer = TEST_LOADBALANCER
126
- self .serverless = TEST_SERVERLESS
127
125
self ._fips_enabled = None
128
- if self .load_balancer or self . serverless :
126
+ if self .load_balancer :
129
127
self .default_client_options ["loadBalanced" ] = True
130
128
if COMPRESSORS :
131
129
self .default_client_options ["compressors" ] = COMPRESSORS
@@ -167,7 +165,7 @@ def uri(self):
167
165
@property
168
166
def hello (self ):
169
167
if not self ._hello :
170
- if self .serverless or self . load_balancer :
168
+ if self .load_balancer :
171
169
self ._hello = self .client .admin .command (HelloCompat .CMD )
172
170
else :
173
171
self ._hello = self .client .admin .command (HelloCompat .LEGACY_CMD )
@@ -222,24 +220,21 @@ def _init_client(self):
222
220
if self .client :
223
221
self .connected = True
224
222
225
- if self .serverless :
226
- self .auth_enabled = True
227
- else :
228
- try :
229
- self .cmd_line = self .client .admin .command ("getCmdLineOpts" )
230
- except pymongo .errors .OperationFailure as e :
231
- assert e .details is not None
232
- msg = e .details .get ("errmsg" , "" )
233
- if e .code == 13 or "unauthorized" in msg or "login" in msg :
234
- # Unauthorized.
235
- self .auth_enabled = True
236
- else :
237
- raise
223
+ try :
224
+ self .cmd_line = self .client .admin .command ("getCmdLineOpts" )
225
+ except pymongo .errors .OperationFailure as e :
226
+ assert e .details is not None
227
+ msg = e .details .get ("errmsg" , "" )
228
+ if e .code == 13 or "unauthorized" in msg or "login" in msg :
229
+ # Unauthorized.
230
+ self .auth_enabled = True
238
231
else :
239
- self .auth_enabled = self ._server_started_with_auth ()
232
+ raise
233
+ else :
234
+ self .auth_enabled = self ._server_started_with_auth ()
240
235
241
236
if self .auth_enabled :
242
- if not self . serverless and not IS_SRV :
237
+ if not IS_SRV :
243
238
# See if db_user already exists.
244
239
if not self ._check_user_provided ():
245
240
_create_user (self .client .admin , db_user , db_pwd )
@@ -259,13 +254,10 @@ def _init_client(self):
259
254
# May not have this if OperationFailure was raised earlier.
260
255
self .cmd_line = self .client .admin .command ("getCmdLineOpts" )
261
256
262
- if self .serverless :
263
- self .server_status = {}
264
- else :
265
- self .server_status = self .client .admin .command ("serverStatus" )
266
- if self .storage_engine == "mmapv1" :
267
- # MMAPv1 does not support retryWrites=True.
268
- self .default_client_options ["retryWrites" ] = False
257
+ self .server_status = self .client .admin .command ("serverStatus" )
258
+ if self .storage_engine == "mmapv1" :
259
+ # MMAPv1 does not support retryWrites=True.
260
+ self .default_client_options ["retryWrites" ] = False
269
261
270
262
hello = self .hello
271
263
self .sessions_enabled = "logicalSessionTimeoutMinutes" in hello
@@ -302,42 +294,33 @@ def _init_client(self):
302
294
self .w = len (hello .get ("hosts" , [])) or 1
303
295
self .version = Version .from_client (self .client )
304
296
305
- if self .serverless :
306
- self .server_parameters = {
307
- "requireApiVersion" : False ,
308
- "enableTestCommands" : True ,
309
- }
297
+ self .server_parameters = self .client .admin .command ("getParameter" , "*" )
298
+ assert self .cmd_line is not None
299
+ if self .server_parameters ["enableTestCommands" ]:
310
300
self .test_commands_enabled = True
311
- self .has_ipv6 = False
312
- else :
313
- self .server_parameters = self .client .admin .command ("getParameter" , "*" )
314
- assert self .cmd_line is not None
315
- if self .server_parameters ["enableTestCommands" ]:
301
+ elif "parsed" in self .cmd_line :
302
+ params = self .cmd_line ["parsed" ].get ("setParameter" , [])
303
+ if "enableTestCommands=1" in params :
316
304
self .test_commands_enabled = True
317
- elif "parsed" in self . cmd_line :
318
- params = self .cmd_line ["parsed" ].get ("setParameter" , [] )
319
- if "enableTestCommands=1" in params :
305
+ else :
306
+ params = self .cmd_line ["parsed" ].get ("setParameter" , {} )
307
+ if params . get ( "enableTestCommands" ) == "1" :
320
308
self .test_commands_enabled = True
321
- else :
322
- params = self .cmd_line ["parsed" ].get ("setParameter" , {})
323
- if params .get ("enableTestCommands" ) == "1" :
324
- self .test_commands_enabled = True
325
- self .has_ipv6 = self ._server_started_with_ipv6 ()
309
+ self .has_ipv6 = self ._server_started_with_ipv6 ()
326
310
327
311
self .is_mongos = (self .hello ).get ("msg" ) == "isdbgrid"
328
312
if self .is_mongos :
329
313
address = self .client .address
330
314
self .mongoses .append (address )
331
- if not self .serverless :
332
- # Check for another mongos on the next port.
333
- assert address is not None
334
- next_address = address [0 ], address [1 ] + 1
335
- mongos_client = self ._connect (* next_address , ** self .default_client_options )
336
- if mongos_client :
337
- hello = mongos_client .admin .command (HelloCompat .LEGACY_CMD )
338
- if hello .get ("msg" ) == "isdbgrid" :
339
- self .mongoses .append (next_address )
340
- mongos_client .close ()
315
+ # Check for another mongos on the next port.
316
+ assert address is not None
317
+ next_address = address [0 ], address [1 ] + 1
318
+ mongos_client = self ._connect (* next_address , ** self .default_client_options )
319
+ if mongos_client :
320
+ hello = mongos_client .admin .command (HelloCompat .LEGACY_CMD )
321
+ if hello .get ("msg" ) == "isdbgrid" :
322
+ self .mongoses .append (next_address )
323
+ mongos_client .close ()
341
324
342
325
def init (self ):
343
326
with self .conn_lock :
@@ -666,15 +649,9 @@ def require_no_load_balancer(self, func):
666
649
lambda : not self .load_balancer , "Must not be connected to a load balancer" , func = func
667
650
)
668
651
669
- def require_no_serverless (self , func ):
670
- """Run a test only if the client is not connected to serverless."""
671
- return self ._require (
672
- lambda : not self .serverless , "Must not be connected to serverless" , func = func
673
- )
674
-
675
652
def require_change_streams (self , func ):
676
653
"""Run a test only if the server supports change streams."""
677
- return self .require_no_mmap (self .require_no_standalone (self . require_no_serverless ( func ) ))
654
+ return self .require_no_mmap (self .require_no_standalone (func ))
678
655
679
656
def is_topology_type (self , topologies ):
680
657
unknown = set (topologies ) - {
@@ -1195,8 +1172,6 @@ class IntegrationTest(PyMongoTestCase):
1195
1172
def setUp (self ) -> None :
1196
1173
if client_context .load_balancer and not getattr (self , "RUN_ON_LOAD_BALANCER" , False ):
1197
1174
raise SkipTest ("this test does not support load balancers" )
1198
- if client_context .serverless and not getattr (self , "RUN_ON_SERVERLESS" , False ):
1199
- raise SkipTest ("this test does not support serverless" )
1200
1175
self .client = client_context .client
1201
1176
self .db = self .client .pymongo_test
1202
1177
if client_context .auth_enabled :
0 commit comments