@@ -71,7 +71,7 @@ def usage(argv):
71
71
print ("-c,--run-vegeta-on-core <...> taskset format for vegeta (e.g. 0-1:2-3 or 0-2:3-4) [default: " + DEFAULT_DAEMON_VEGETA_ON_CORE + "]" )
72
72
print ("-T,--response-timeout <timeout>: vegeta response timeout [default: " + DEFAULT_VEGETA_RESPONSE_TIMEOUT + "]" )
73
73
print ("-M,--max-body-rsp <size>: max number of bytes to read from response bodies [default: " + DEFAULT_MAX_BODY_RSP + "]" )
74
- sys .exit (- 1 )
74
+ sys .exit (1 )
75
75
76
76
def get_process (process_name : str ):
77
77
""" Return the running process having specified name or None if not exists """
@@ -207,7 +207,7 @@ def __parse_args(self, argv):
207
207
# print help information and exit:
208
208
print (err )
209
209
usage (argv )
210
- sys .exit (- 1 )
210
+ sys .exit (1 )
211
211
212
212
213
213
class PerfTest :
@@ -240,7 +240,7 @@ def copy_and_extract_pattern_file(self):
240
240
""" Copy the vegeta pattern file into /tmp/run_tests_xyz/ and untar the file """
241
241
if os .path .exists (self .config .vegeta_pattern_tar_file ) == 0 :
242
242
print ("ERROR: invalid pattern file: " , self .config .vegeta_pattern_tar_file )
243
- sys .exit (- 1 )
243
+ sys .exit (1 )
244
244
cmd = "mkdir " + RUN_TEST_DIRNAME
245
245
status = os .system (cmd )
246
246
cmd = "/bin/cp -f " + self .config .vegeta_pattern_tar_file + " " + VEGETA_TAR_FILE_NAME
@@ -249,15 +249,15 @@ def copy_and_extract_pattern_file(self):
249
249
status = os .system (cmd )
250
250
if int (status ) != 0 :
251
251
print ("Vegeta pattern copy failed. Test Aborted!" )
252
- sys .exit (- 1 )
252
+ sys .exit (1 )
253
253
254
254
cmd = "cd " + RUN_TEST_DIRNAME + "; tar xvf " + VEGETA_TAR_FILE_NAME + " > /dev/null"
255
255
if self .config .tracing :
256
256
print (f"Extracting Vegeta pattern: { cmd } " )
257
257
status = os .system (cmd )
258
258
if int (status ) != 0 :
259
259
print ("Vegeta pattern untar failed. Test Aborted!" )
260
- sys .exit (- 1 )
260
+ sys .exit (1 )
261
261
262
262
# If address is provided substitute the address and port of daemon in the vegeta file
263
263
if self .config .rpc_daemon_address != "localhost" :
@@ -295,8 +295,8 @@ def execute(self, test_number, name, qps_value, duration):
295
295
sys .stdout .flush ()
296
296
status = os .system (cmd )
297
297
if int (status ) != 0 :
298
- print ("vegeta test fails: Test Aborted!" )
299
- return 0
298
+ print ("vegeta attach fails: Test Aborted!" )
299
+ return 1
300
300
301
301
while 1 :
302
302
time .sleep (3 )
@@ -309,13 +309,13 @@ def execute(self, test_number, name, qps_value, duration):
309
309
if pid == "" :
310
310
# the server is dead; kill vegeta and returns fails
311
311
os .system ("kill -2 $(ps aux | grep 'vegeta' | grep -v 'grep' | grep -v 'python' | awk '{print $2}') 2> /dev/null" )
312
- return 0
312
+ print ("test failed: server is Dead" )
313
+ return 1
313
314
314
315
pid = os .popen ("ps aux | grep 'vegeta report' | grep -v 'grep' | awk '{print $2}'" ).read ()
315
316
if pid == "" :
316
- # Vegeta has completed its works, generate report and return OK
317
- self .get_result (test_number , name , qps_value , duration )
318
- return 1
317
+ # Vegeta has completed its works, generate report
318
+ return self .get_result (test_number , name , qps_value , duration )
319
319
320
320
def execute_sequence (self , sequence , tag ):
321
321
""" Execute the sequence of tests """
@@ -327,13 +327,12 @@ def execute_sequence(self, sequence, tag):
327
327
test_name = "[{:d}.{:2d}] "
328
328
test_name_formatted = test_name .format (test_number , test_rep + 1 )
329
329
result = self .execute (test_name_formatted , tag , qps , duration )
330
- if result == 0 :
331
- print ("Server dead test Aborted!" )
332
- return 0
330
+ if result == 1 :
331
+ return 1
333
332
time .sleep (self .config .waiting_time )
334
333
test_number = test_number + 1
335
334
print ("" )
336
- return 1
335
+ return 0
337
336
338
337
def get_result (self , test_number , daemon_name , qps_value , duration ):
339
338
""" Processes the report file generated by vegeta and reads latency data """
@@ -348,7 +347,7 @@ def get_result(self, test_number, daemon_name, qps_value, duration):
348
347
newline = file_raws [5 ].replace ('\n ' , ' ' )
349
348
ratio = newline .split (' ' )[34 ]
350
349
if len (file_raws ) > 8 :
351
- error = file_raws [8 ]
350
+ error = file_raws [8 ]. rstrip ()
352
351
print (" [ Ratio=" + ratio + ", MaxLatency=" + max_latency + " Error: " + error + "]" )
353
352
else :
354
353
error = ""
@@ -357,11 +356,17 @@ def get_result(self, test_number, daemon_name, qps_value, duration):
357
356
finally :
358
357
file .close ()
359
358
359
+ if error != "" or ratio != "100.00%" :
360
+ print ("test failed: ratio is not 100.00%" )
361
+ return 1
362
+
360
363
if self .config .create_test_report :
361
364
self .test_report .write_test_report (daemon_name , test_number , threads , qps_value , duration , min_latency , latency_values [7 ], latency_values [8 ], \
362
365
latency_values [9 ], latency_values [10 ], latency_values [11 ], max_latency , ratio , error )
363
366
os .system ("/bin/rm " + test_report_filename )
364
367
368
+ return 0
369
+
365
370
366
371
class Hardware :
367
372
""" Extract hardware information from the underlying platform. """
@@ -517,27 +522,25 @@ def main(argv):
517
522
518
523
if config .test_mode in ("1" , "3" ):
519
524
result = perf_test .execute_sequence (current_sequence , SILKRPC )
520
- if result == 0 :
521
- print ("Server dead test Aborted!" )
525
+ if result == 1 :
522
526
if config .create_test_report :
523
527
test_report .close ()
524
- sys . exit ( - 1 )
528
+ return 1
525
529
if config .test_mode == "3" :
526
530
print ("--------------------------------------------------------------------------------------------\n " )
527
531
528
532
if config .test_mode in ("2" , "3" ):
529
533
result = perf_test .execute_sequence (current_sequence , RPCDAEMON )
530
- if result == 0 :
531
- print ("Server dead test Aborted!" )
534
+ if result == 1 :
532
535
if config .create_test_report :
533
536
test_report .close ()
534
- sys . exit ( - 1 )
537
+ return 1
535
538
536
539
if config .create_test_report :
537
540
test_report .close ()
538
541
perf_test .cleanup (0 )
539
542
print ("Performance Test completed successfully." )
540
-
543
+ return 0
541
544
542
545
#
543
546
# module as main
0 commit comments