diff --git a/tests/performance_tests/log_reader.py b/tests/performance_tests/log_reader.py index 9d9e0b36f7..9dc7e0ab98 100644 --- a/tests/performance_tests/log_reader.py +++ b/tests/performance_tests/log_reader.py @@ -198,8 +198,9 @@ def scoreTransfersPerSecond(data: chainData, guide : chainBlocksGuide) -> stats: # Note: numpy array slicing in use -> [:,0] -> from all elements return index 0 return stats(int(np.min(npCBTAEC[:,0])), int(np.max(npCBTAEC[:,0])), float(np.average(npCBTAEC[:,0])), float(np.std(npCBTAEC[:,0])), int(np.sum(npCBTAEC[:,1])), len(prunedBlockDataLog)) -def createJSONReport(guide: chainBlocksGuide, tpsStats: stats, args) -> json: +def createJSONReport(guide: chainBlocksGuide, tpsStats: stats, args, completedRun) -> json: js = {} + js['completedRun'] = completedRun js['nodeosVersion'] = Utils.getNodeosVersion() js['env'] = {'system': system(), 'os': os.name, 'release': release()} js['args'] = dict(item.split("=") for item in f"{args}"[10:-1].split(", ")) diff --git a/tests/performance_tests/performance_test_basic.py b/tests/performance_tests/performance_test_basic.py index 89b5cb8954..767518dab9 100755 --- a/tests/performance_tests/performance_test_basic.py +++ b/tests/performance_tests/performance_test_basic.py @@ -60,6 +60,8 @@ def waitForEmptyBlocks(node): cluster.setWalletMgr(walletMgr) testSuccessful = False +completedRun = False + try: # Kill any existing instances and launch cluster TestHelper.printSystemInfo("BEGIN") @@ -119,6 +121,21 @@ def waitForEmptyBlocks(node): # Get stats after transaction generation stops data.ceaseBlock = waitForEmptyBlocks(validationNode) - emptyBlockGoal + 1 + completedRun = True + +except subprocess.CalledProcessError as err: + print(f"trx_generator return error code: {err.returncode}. Test aborted.") +finally: + TestHelper.shutdown( + cluster, + walletMgr, + testSuccessful, + killEosInstances, + killWallet, + keepLogs, + killAll, + dumpErrorDetails + ) log_reader.scrapeLog(data, "var/lib/node_01/stderr.txt") print(data) @@ -132,27 +149,18 @@ def waitForEmptyBlocks(node): guide = log_reader.calcChainGuide(data, numAddlBlocksToPrune) tpsStats = log_reader.scoreTransfersPerSecond(data, guide) print(f"Blocks Guide: {guide}\nTPS: {tpsStats}") - report = log_reader.createJSONReport(guide, tpsStats, args) + report = log_reader.createJSONReport(guide, tpsStats, args, completedRun) print(report) if args.save_json: log_reader.exportAsJSON(report, args) - assert transactionsSent == data.totalTransactions , f"Error: Transactions received: {data.totalTransactions} did not match expected total: {transactionsSent}" + if completedRun: + assert transactionsSent == data.totalTransactions , f"Error: Transactions received: {data.totalTransactions} did not match expected total: {transactionsSent}" + else: + os.system("pkill trx_generator") + print("Test run cancelled early via SIGINT") testSuccessful = True -except subprocess.CalledProcessError as err: - print(f"trx_generator return error code: {err.returncode}. Test aborted.") -finally: - TestHelper.shutdown( - cluster, - walletMgr, - testSuccessful, - killEosInstances, - killWallet, - keepLogs, - killAll, - dumpErrorDetails - ) exitCode = 0 if testSuccessful else 1 exit(exitCode) diff --git a/tests/performance_tests/read_log_data.py b/tests/performance_tests/read_log_data.py index 164555a66e..4a5ff1f55e 100644 --- a/tests/performance_tests/read_log_data.py +++ b/tests/performance_tests/read_log_data.py @@ -22,7 +22,7 @@ guide = log_reader.calcChainGuide(data, args.num_blocks_to_prune) tpsStats = log_reader.scoreTransfersPerSecond(data, guide) print(f"Guide: {guide}\nTPS: {tpsStats}") -report = log_reader.createJSONReport(guide, tpsStats, args) +report = log_reader.createJSONReport(guide, tpsStats, args, True) print(report) if args.save_json: log_reader.exportAsJSON(report, args) \ No newline at end of file