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] Update Log Reader Tests For scrapeBlockTrxDataLog #778

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions tests/performance_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ configure_file(read_log_data.py read_log_data.py COPYONLY)
configure_file(log_reader_tests.py log_reader_tests.py COPYONLY)
configure_file(nodeos_log_2_0_14.txt.gz nodeos_log_2_0_14.txt.gz COPYONLY)
configure_file(nodeos_log_3_2.txt.gz nodeos_log_3_2.txt.gz COPYONLY)
configure_file(block_trx_data_log_2_0_14.txt.gz block_trx_data_log_2_0_14.txt.gz COPYONLY)
configure_file(genesis.json genesis.json COPYONLY)
configure_file(validate_nodeos_plugin_args.py validate_nodeos_plugin_args.py COPYONLY)
configure_file(cpuTrxData.json cpuTrxData.json COPYONLY)
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/performance_tests/log_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def scrapeTrxGenLog(trxSent, path):
with selectedopen(path, 'rt') as f:
trxSent.update(dict([(x[0], x[1]) for x in (line.rstrip('\n').split(',') for line in f)]))

def scrapeBlockTrxDataLog(trxDict, path):
def scrapeBlockTrxDataLog(trxDict, path, nodeosVersion=None):
#blockTrxData.txt
selectedopen = selectedOpen(path)
with selectedopen(path, 'rt') as f:
if Utils.getNodeosVersion().split('.')[0] == "v2":
if Utils.getNodeosVersion().split('.')[0] == "v2" or nodeosVersion == "v2":
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved
trxDict.update(dict([(x[0], trxData(blockNum=x[1], cpuUsageUs=x[2], netUsageUs=x[3])) for x in (line.rstrip('\n').split(',') for line in f)]))
else:
trxDict.update(dict([(x[0], trxData(blockNum=x[1], blockTime=x[2], cpuUsageUs=x[3], netUsageUs=x[4])) for x in (line.rstrip('\n').split(',') for line in f)]))
Expand Down
8 changes: 8 additions & 0 deletions tests/performance_tests/log_reader_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@
expectedTpsStats = log_reader.stats(41, 41, 41, 0.0, 0, 2)
assert expectedTpsStats == stats , f"Error: Stats calculated: {stats} did not match expected stats: {expectedTpsStats}"

#ensure that scraping of trxDataLog is compatible with 2.0
trxDict = {}
log_reader.scrapeBlockTrxDataLog(trxDict=trxDict, path=Path("tests")/"performance_tests"/"block_trx_data_log_2_0_14.txt", nodeosVersion="v2")
expectedDict = {}
expectedDict["41c6dca250f9b74d9fa6a8177a9c8390cb1d01b2123d6f88354f571f0053df72"] = log_reader.trxData(blockNum='112',cpuUsageUs='1253',netUsageUs='19')
expectedDict["fa17f9033589bb8757be009af46d465f0d903e26b7d198ea0fb6a3cbed93c2e6"] = log_reader.trxData(blockNum='112',cpuUsageUs='1263',netUsageUs='19')
assert trxDict == expectedDict, f"Scraped transaction dictionary: {trxDict} did not match expected dictionary : {expectedDict}"

testSuccessful = True

exitCode = 0 if testSuccessful else 1
Expand Down