@@ -257,7 +257,7 @@ def _handle_placeholders(self, spec: dict, current: dict, path: str) -> Any:
257257 current [key ] = self ._handle_placeholders (spec , value , subpath )
258258 return current
259259
260- async def _create_entity (self , entity_spec , uri = None ):
260+ async def _create_entity (self , entity_spec , uri = None , init_client = False ):
261261 if len (entity_spec ) != 1 :
262262 self .test .fail (f"Entity spec { entity_spec } did not contain exactly one top-level key" )
263263
@@ -303,6 +303,8 @@ async def _create_entity(self, entity_spec, uri=None):
303303 if uri :
304304 kwargs ["h" ] = uri
305305 client = await self .test .async_rs_or_single_client (** kwargs )
306+ if init_client :
307+ await client .aconnect ()
306308 self [spec ["id" ]] = client
307309 return
308310 elif entity_type == "database" :
@@ -390,9 +392,9 @@ async def drop(self: AsyncGridFSBucket, *args: Any, **kwargs: Any) -> None:
390392
391393 self .test .fail (f"Unable to create entity of unknown type { entity_type } " )
392394
393- async def create_entities_from_spec (self , entity_spec , uri = None ):
395+ async def create_entities_from_spec (self , entity_spec , uri = None , init_client = False ):
394396 for spec in entity_spec :
395- await self ._create_entity (spec , uri = uri )
397+ await self ._create_entity (spec , uri = uri , init_client = init_client )
396398
397399 def get_listener_for_client (self , client_name : str ) -> EventListenerUtil :
398400 client = self [client_name ]
@@ -1406,7 +1408,7 @@ async def run_scenario(self, spec, uri=None):
14061408 attempts = 3
14071409 for i in range (attempts ):
14081410 try :
1409- return await self ._run_scenario (spec , uri )
1411+ return await self ._run_scenario (spec , uri , init_client = True )
14101412 except (AssertionError , OperationFailure ) as exc :
14111413 if isinstance (exc , OperationFailure ) and (
14121414 _IS_SYNC or "failpoint" not in exc ._message
@@ -1426,7 +1428,7 @@ async def run_scenario(self, spec, uri=None):
14261428 await self ._run_scenario (spec , uri )
14271429 return None
14281430
1429- async def _run_scenario (self , spec , uri = None ):
1431+ async def _run_scenario (self , spec , uri = None , init_client = False ):
14301432 # maybe skip test manually
14311433 self .maybe_skip_test (spec )
14321434
@@ -1444,7 +1446,7 @@ async def _run_scenario(self, spec, uri=None):
14441446 self ._uri = uri
14451447 self .entity_map = EntityMapUtil (self )
14461448 await self .entity_map .create_entities_from_spec (
1447- self .TEST_SPEC .get ("createEntities" , []), uri = uri
1449+ self .TEST_SPEC .get ("createEntities" , []), uri = uri , init_client = init_client
14481450 )
14491451 self ._cluster_time = None
14501452 # process initialData
0 commit comments