@@ -257,7 +257,7 @@ def _handle_placeholders(self, spec: dict, current: dict, path: str) -> Any:
257
257
current [key ] = self ._handle_placeholders (spec , value , subpath )
258
258
return current
259
259
260
- async def _create_entity (self , entity_spec , uri = None ):
260
+ async def _create_entity (self , entity_spec , uri = None , init_client = False ):
261
261
if len (entity_spec ) != 1 :
262
262
self .test .fail (f"Entity spec { entity_spec } did not contain exactly one top-level key" )
263
263
@@ -303,6 +303,8 @@ async def _create_entity(self, entity_spec, uri=None):
303
303
if uri :
304
304
kwargs ["h" ] = uri
305
305
client = await self .test .async_rs_or_single_client (** kwargs )
306
+ if init_client :
307
+ await client .aconnect ()
306
308
self [spec ["id" ]] = client
307
309
return
308
310
elif entity_type == "database" :
@@ -390,9 +392,9 @@ async def drop(self: AsyncGridFSBucket, *args: Any, **kwargs: Any) -> None:
390
392
391
393
self .test .fail (f"Unable to create entity of unknown type { entity_type } " )
392
394
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 ):
394
396
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 )
396
398
397
399
def get_listener_for_client (self , client_name : str ) -> EventListenerUtil :
398
400
client = self [client_name ]
@@ -1406,7 +1408,7 @@ async def run_scenario(self, spec, uri=None):
1406
1408
attempts = 3
1407
1409
for i in range (attempts ):
1408
1410
try :
1409
- return await self ._run_scenario (spec , uri )
1411
+ return await self ._run_scenario (spec , uri , init_client = True )
1410
1412
except (AssertionError , OperationFailure ) as exc :
1411
1413
if isinstance (exc , OperationFailure ) and (
1412
1414
_IS_SYNC or "failpoint" not in exc ._message
@@ -1426,7 +1428,7 @@ async def run_scenario(self, spec, uri=None):
1426
1428
await self ._run_scenario (spec , uri )
1427
1429
return None
1428
1430
1429
- async def _run_scenario (self , spec , uri = None ):
1431
+ async def _run_scenario (self , spec , uri = None , init_client = False ):
1430
1432
# maybe skip test manually
1431
1433
self .maybe_skip_test (spec )
1432
1434
@@ -1444,7 +1446,7 @@ async def _run_scenario(self, spec, uri=None):
1444
1446
self ._uri = uri
1445
1447
self .entity_map = EntityMapUtil (self )
1446
1448
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
1448
1450
)
1449
1451
self ._cluster_time = None
1450
1452
# process initialData
0 commit comments