6464 MONGODB_API_VERSION ,
6565 MULTI_MONGOS_LB_URI ,
6666 TEST_LOADBALANCER ,
67- TEST_SERVERLESS ,
6867 TLS_OPTIONS ,
6968 SystemCertsPatcher ,
7069 client_knobs ,
@@ -123,9 +122,8 @@ def __init__(self):
123122 self .conn_lock = threading .Lock ()
124123 self .is_data_lake = False
125124 self .load_balancer = TEST_LOADBALANCER
126- self .serverless = TEST_SERVERLESS
127125 self ._fips_enabled = None
128- if self .load_balancer or self . serverless :
126+ if self .load_balancer :
129127 self .default_client_options ["loadBalanced" ] = True
130128 if COMPRESSORS :
131129 self .default_client_options ["compressors" ] = COMPRESSORS
@@ -167,7 +165,7 @@ def uri(self):
167165 @property
168166 def hello (self ):
169167 if not self ._hello :
170- if self .serverless or self . load_balancer :
168+ if self .load_balancer :
171169 self ._hello = self .client .admin .command (HelloCompat .CMD )
172170 else :
173171 self ._hello = self .client .admin .command (HelloCompat .LEGACY_CMD )
@@ -222,24 +220,21 @@ def _init_client(self):
222220 if self .client :
223221 self .connected = True
224222
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
238231 else :
239- self .auth_enabled = self ._server_started_with_auth ()
232+ raise
233+ else :
234+ self .auth_enabled = self ._server_started_with_auth ()
240235
241236 if self .auth_enabled :
242- if not self . serverless and not IS_SRV :
237+ if not IS_SRV :
243238 # See if db_user already exists.
244239 if not self ._check_user_provided ():
245240 _create_user (self .client .admin , db_user , db_pwd )
@@ -259,13 +254,10 @@ def _init_client(self):
259254 # May not have this if OperationFailure was raised earlier.
260255 self .cmd_line = self .client .admin .command ("getCmdLineOpts" )
261256
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
269261
270262 hello = self .hello
271263 self .sessions_enabled = "logicalSessionTimeoutMinutes" in hello
@@ -302,42 +294,33 @@ def _init_client(self):
302294 self .w = len (hello .get ("hosts" , [])) or 1
303295 self .version = Version .from_client (self .client )
304296
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" ]:
310300 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 :
316304 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" :
320308 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 ()
326310
327311 self .is_mongos = (self .hello ).get ("msg" ) == "isdbgrid"
328312 if self .is_mongos :
329313 address = self .client .address
330314 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 ()
341324
342325 def init (self ):
343326 with self .conn_lock :
@@ -666,15 +649,9 @@ def require_no_load_balancer(self, func):
666649 lambda : not self .load_balancer , "Must not be connected to a load balancer" , func = func
667650 )
668651
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-
675652 def require_change_streams (self , func ):
676653 """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 ))
678655
679656 def is_topology_type (self , topologies ):
680657 unknown = set (topologies ) - {
@@ -1195,8 +1172,6 @@ class IntegrationTest(PyMongoTestCase):
11951172 def setUp (self ) -> None :
11961173 if client_context .load_balancer and not getattr (self , "RUN_ON_LOAD_BALANCER" , False ):
11971174 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" )
12001175 self .client = client_context .client
12011176 self .db = self .client .pymongo_test
12021177 if client_context .auth_enabled :
0 commit comments