@@ -226,7 +226,7 @@ def add_event(self, event):
226
226
if event_name in self ._event_types :
227
227
super (EventListenerUtil , self ).add_event (event )
228
228
for id in self ._event_mapping [event_name ]:
229
- self .entity_map [id ].append (event )
229
+ self .entity_map [id ].append (str ( event ) )
230
230
231
231
def _command_event (self , event ):
232
232
if event .command_name .lower () not in self ._ignore_commands :
@@ -284,7 +284,7 @@ def __setitem__(self, key, value):
284
284
285
285
self ._entities [key ] = value
286
286
287
- def _create_entity (self , entity_spec ):
287
+ def _create_entity (self , entity_spec , uri = None ):
288
288
if len (entity_spec ) != 1 :
289
289
self .test .fail (
290
290
"Entity spec %s did not contain exactly one top-level key" % (
@@ -315,6 +315,8 @@ def _create_entity(self, entity_spec):
315
315
kwargs ['server_api' ] = ServerApi (
316
316
server_api ['version' ], strict = server_api .get ('strict' ),
317
317
deprecation_errors = server_api .get ('deprecationErrors' ))
318
+ if uri :
319
+ kwargs ['h' ] = uri
318
320
client = rs_or_single_client (** kwargs )
319
321
self [spec ['id' ]] = client
320
322
self .test .addCleanup (client .close )
@@ -366,9 +368,9 @@ def _create_entity(self, entity_spec):
366
368
self .test .fail (
367
369
'Unable to create entity of unknown type %s' % (entity_type ,))
368
370
369
- def create_entities_from_spec (self , entity_spec ):
371
+ def create_entities_from_spec (self , entity_spec , uri = None ):
370
372
for spec in entity_spec :
371
- self ._create_entity (spec )
373
+ self ._create_entity (spec , uri = uri )
372
374
373
375
def get_listener_for_client (self , client_name ):
374
376
client = self [client_name ]
@@ -718,7 +720,6 @@ def insert_initial_data(self, initial_data):
718
720
def setUpClass (cls ):
719
721
# super call creates internal client cls.client
720
722
super (UnifiedSpecTestMixinV1 , cls ).setUpClass ()
721
-
722
723
# process file-level runOnRequirements
723
724
run_on_spec = cls .TEST_SPEC .get ('runOnRequirements' , [])
724
725
if not cls .should_run_on (run_on_spec ):
@@ -733,7 +734,6 @@ def setUpClass(cls):
733
734
734
735
def setUp (self ):
735
736
super (UnifiedSpecTestMixinV1 , self ).setUp ()
736
-
737
737
# process schemaVersion
738
738
# note: we check major schema version during class generation
739
739
# note: we do this here because we cannot run assertions in setUpClass
@@ -1080,40 +1080,39 @@ def _testOperation_loop(self, spec):
1080
1080
successes_key = spec .get ('storeSuccessesAsEntity' )
1081
1081
iteration_key = spec .get ('storeIterationsAsEntity' )
1082
1082
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
1091
1089
i = 0
1090
+ global IS_INTERRUPTED
1092
1091
while True :
1093
1092
if iteration_limiter_key and i >= iteration_limiter_key :
1094
1093
break
1095
1094
i += 1
1096
1095
if IS_INTERRUPTED :
1097
1096
break
1098
1097
try :
1098
+ if iteration_key :
1099
+ self .entity_map ._entities [iteration_key ] += 1
1099
1100
for op in spec ["operations" ]:
1100
1101
self .run_entity_operation (op )
1101
1102
if successes_key :
1102
1103
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
1111
1104
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
1115
1107
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
+ })
1117
1116
1118
1117
def run_special_operation (self , spec ):
1119
1118
opname = spec ['name' ]
@@ -1174,7 +1173,7 @@ def verify_outcome(self, spec):
1174
1173
self .assertListEqual (sorted_expected_documents ,
1175
1174
actual_documents )
1176
1175
1177
- def run_scenario (self , spec ):
1176
+ def run_scenario (self , spec , uri = None ):
1178
1177
# maybe skip test manually
1179
1178
self .maybe_skip_test (spec )
1180
1179
@@ -1191,8 +1190,7 @@ def run_scenario(self, spec):
1191
1190
# process createEntities
1192
1191
self .entity_map = EntityMapUtil (self )
1193
1192
self .entity_map .create_entities_from_spec (
1194
- self .TEST_SPEC .get ('createEntities' , []))
1195
-
1193
+ self .TEST_SPEC .get ('createEntities' , []), uri = uri )
1196
1194
# process initialData
1197
1195
self .insert_initial_data (self .TEST_SPEC .get ('initialData' , []))
1198
1196
0 commit comments