Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PH] Performance harness graceful shutdown #237

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/performance_tests/log_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(", "))
Expand Down
38 changes: 23 additions & 15 deletions tests/performance_tests/performance_test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a candidate for replacing with explicit subprocess control, but we'll wait on that until the regression test harness has support for it.

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)
2 changes: 1 addition & 1 deletion tests/performance_tests/read_log_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)