@@ -226,7 +226,7 @@ def add_event(self, event):
226226 if event_name in self ._event_types :
227227 super (EventListenerUtil , self ).add_event (event )
228228 for id in self ._event_mapping [event_name ]:
229- self .entity_map [id ].append (event )
229+ self .entity_map [id ].append (str ( event ) )
230230
231231 def _command_event (self , event ):
232232 if event .command_name .lower () not in self ._ignore_commands :
@@ -284,7 +284,7 @@ def __setitem__(self, key, value):
284284
285285 self ._entities [key ] = value
286286
287- def _create_entity (self , entity_spec ):
287+ def _create_entity (self , entity_spec , uri = None ):
288288 if len (entity_spec ) != 1 :
289289 self .test .fail (
290290 "Entity spec %s did not contain exactly one top-level key" % (
@@ -315,6 +315,8 @@ def _create_entity(self, entity_spec):
315315 kwargs ['server_api' ] = ServerApi (
316316 server_api ['version' ], strict = server_api .get ('strict' ),
317317 deprecation_errors = server_api .get ('deprecationErrors' ))
318+ if uri :
319+ kwargs ['h' ] = uri
318320 client = rs_or_single_client (** kwargs )
319321 self [spec ['id' ]] = client
320322 self .test .addCleanup (client .close )
@@ -366,9 +368,9 @@ def _create_entity(self, entity_spec):
366368 self .test .fail (
367369 'Unable to create entity of unknown type %s' % (entity_type ,))
368370
369- def create_entities_from_spec (self , entity_spec ):
371+ def create_entities_from_spec (self , entity_spec , uri = None ):
370372 for spec in entity_spec :
371- self ._create_entity (spec )
373+ self ._create_entity (spec , uri = uri )
372374
373375 def get_listener_for_client (self , client_name ):
374376 client = self [client_name ]
@@ -718,7 +720,6 @@ def insert_initial_data(self, initial_data):
718720 def setUpClass (cls ):
719721 # super call creates internal client cls.client
720722 super (UnifiedSpecTestMixinV1 , cls ).setUpClass ()
721-
722723 # process file-level runOnRequirements
723724 run_on_spec = cls .TEST_SPEC .get ('runOnRequirements' , [])
724725 if not cls .should_run_on (run_on_spec ):
@@ -733,7 +734,6 @@ def setUpClass(cls):
733734
734735 def setUp (self ):
735736 super (UnifiedSpecTestMixinV1 , self ).setUp ()
736-
737737 # process schemaVersion
738738 # note: we check major schema version during class generation
739739 # note: we do this here because we cannot run assertions in setUpClass
@@ -1080,40 +1080,39 @@ def _testOperation_loop(self, spec):
10801080 successes_key = spec .get ('storeSuccessesAsEntity' )
10811081 iteration_key = spec .get ('storeIterationsAsEntity' )
10821082 iteration_limiter_key = spec .get ('numIterations' )
1083- if failure_key :
1084- self .entity_map [failure_key ] = []
1085- if error_key :
1086- self .entity_map [error_key ] = []
1087- if successes_key :
1088- self .entity_map [successes_key ] = 0
1089- if iteration_key :
1090- self .entity_map [iteration_key ] = 0
1083+ for i in [failure_key , error_key ]:
1084+ if i :
1085+ self .entity_map [i ] = []
1086+ for i in [successes_key , iteration_key ]:
1087+ if i :
1088+ self .entity_map [i ] = 0
10911089 i = 0
1090+ global IS_INTERRUPTED
10921091 while True :
10931092 if iteration_limiter_key and i >= iteration_limiter_key :
10941093 break
10951094 i += 1
10961095 if IS_INTERRUPTED :
10971096 break
10981097 try :
1098+ if iteration_key :
1099+ self .entity_map ._entities [iteration_key ] += 1
10991100 for op in spec ["operations" ]:
11001101 self .run_entity_operation (op )
11011102 if successes_key :
11021103 self .entity_map ._entities [successes_key ] += 1
1103- if iteration_key :
1104- self .entity_map ._entities [iteration_key ] += 1
1105- except AssertionError as exc :
1106- if failure_key or error_key :
1107- self .entity_map [failure_key or error_key ].append ({
1108- "error" : exc , "time" : time .time ()})
1109- else :
1110- raise exc
11111104 except Exception as exc :
1112- if error_key or failure_key :
1113- self .entity_map [error_key or failure_key ].append (
1114- {"error" : exc , "time" : time .time ()})
1105+ if isinstance (exc , AssertionError ):
1106+ key = failure_key or error_key
11151107 else :
1116- raise exc
1108+ key = error_key or failure_key
1109+ if not key :
1110+ raise
1111+ self .entity_map [key ].append ({
1112+ "error" : str (exc ),
1113+ "time" : time .time (),
1114+ "type" : type (exc ).__name__
1115+ })
11171116
11181117 def run_special_operation (self , spec ):
11191118 opname = spec ['name' ]
@@ -1174,7 +1173,7 @@ def verify_outcome(self, spec):
11741173 self .assertListEqual (sorted_expected_documents ,
11751174 actual_documents )
11761175
1177- def run_scenario (self , spec ):
1176+ def run_scenario (self , spec , uri = None ):
11781177 # maybe skip test manually
11791178 self .maybe_skip_test (spec )
11801179
@@ -1191,8 +1190,7 @@ def run_scenario(self, spec):
11911190 # process createEntities
11921191 self .entity_map = EntityMapUtil (self )
11931192 self .entity_map .create_entities_from_spec (
1194- self .TEST_SPEC .get ('createEntities' , []))
1195-
1193+ self .TEST_SPEC .get ('createEntities' , []), uri = uri )
11961194 # process initialData
11971195 self .insert_initial_data (self .TEST_SPEC .get ('initialData' , []))
11981196
0 commit comments