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 3 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
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.
16 changes: 9 additions & 7 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, nodeosVers):
#blockTrxData.txt
selectedopen = selectedOpen(path)
with selectedopen(path, 'rt') as f:
if Utils.getNodeosVersion().split('.')[0] == "v2":
if nodeosVers == "v2":
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 Expand Up @@ -438,7 +438,8 @@ def calcTrxLatencyCpuNetStats(trxDict : dict, blockDict: dict):
basicStats(float(np.min(npLatencyCpuNetList[:,2])), float(np.max(npLatencyCpuNetList[:,2])), float(np.average(npLatencyCpuNetList[:,2])), float(np.std(npLatencyCpuNetList[:,2])), len(npLatencyCpuNetList))

def createReport(guide: chainBlocksGuide, tpsTestConfig: TpsTestConfig, tpsStats: stats, blockSizeStats: stats, trxLatencyStats: basicStats, trxCpuStats: basicStats,
trxNetStats: basicStats, forkedBlocks, droppedBlocks, prodWindows: productionWindows, notFound: dict, testStart: datetime, testFinish: datetime, argsDict: dict, completedRun: bool) -> dict:
trxNetStats: basicStats, forkedBlocks, droppedBlocks, prodWindows: productionWindows, notFound: dict, testStart: datetime, testFinish: datetime,
argsDict: dict, completedRun: bool, nodeosVers: str) -> dict:
report = {}
report['completedRun'] = completedRun
report['testStart'] = testStart
Expand All @@ -464,7 +465,7 @@ def createReport(guide: chainBlocksGuide, tpsTestConfig: TpsTestConfig, tpsStats
report['Analysis']['ForksCount'] = len(forkedBlocks)
report['args'] = argsDict
report['env'] = {'system': system(), 'os': os.name, 'release': release(), 'logical_cpu_count': os.cpu_count()}
report['nodeosVersion'] = Utils.getNodeosVersion()
report['nodeosVersion'] = nodeosVers
return report

class LogReaderEncoder(json.JSONEncoder):
Expand All @@ -489,14 +490,14 @@ def default(self, obj):
def reportAsJSON(report: dict) -> json:
return json.dumps(report, indent=2, cls=LogReaderEncoder)

def calcAndReport(data: chainData, tpsTestConfig: TpsTestConfig, artifacts: ArtifactPaths, argsDict: dict, testStart: datetime=None, completedRun: bool=True) -> dict:
def calcAndReport(data: chainData, tpsTestConfig: TpsTestConfig, artifacts: ArtifactPaths, argsDict: dict, testStart: datetime=None, completedRun: bool=True, nodeosVers: str="") -> dict:
scrapeLog(data, artifacts.nodeosLogPath)

trxSent = {}
scrapeTrxGenTrxSentDataLogs(trxSent, artifacts.trxGenLogDirPath, tpsTestConfig.quiet)

trxDict = {}
scrapeBlockTrxDataLog(trxDict, artifacts.blockTrxDataPath)
scrapeBlockTrxDataLog(trxDict, artifacts.blockTrxDataPath, nodeosVers)

blockDict = {}
scrapeBlockDataLog(blockDict, artifacts.blockDataPath)
Expand Down Expand Up @@ -531,7 +532,8 @@ def calcAndReport(data: chainData, tpsTestConfig: TpsTestConfig, artifacts: Arti

report = createReport(guide=guide, tpsTestConfig=tpsTestConfig, tpsStats=tpsStats, blockSizeStats=blkSizeStats, trxLatencyStats=trxLatencyStats,
trxCpuStats=trxCpuStats, trxNetStats=trxNetStats, forkedBlocks=data.forkedBlocks, droppedBlocks=data.droppedBlocks,
prodWindows=prodWindows, notFound=notFound, testStart=start, testFinish=finish, argsDict=argsDict, completedRun=completedRun)
prodWindows=prodWindows, notFound=notFound, testStart=start, testFinish=finish, argsDict=argsDict, completedRun=completedRun,
nodeosVers=nodeosVers)
return report

def exportReportAsJSON(report: json, exportPath):
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", nodeosVers="v2")
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved
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
7 changes: 4 additions & 3 deletions tests/performance_tests/performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def createTpsTestReport(self, tpsTestResult: TpsTestResult) -> dict:
report['LongRunningMaxTpsReport'] = tpsTestResult.longRunningSearchResults.maxTpsReport
return report

def createReport(self,producerThreadResult: PluginThreadOptResult=None, chainThreadResult: PluginThreadOptResult=None, netThreadResult: PluginThreadOptResult=None, tpsTestResult: dict=None) -> dict:
def createReport(self, producerThreadResult: PluginThreadOptResult=None, chainThreadResult: PluginThreadOptResult=None, netThreadResult: PluginThreadOptResult=None,
tpsTestResult: dict=None, nodeosVers: str="") -> dict:
report = {}
report['perfTestsBegin'] = self.testsStart
report['perfTestsFinish'] = self.testsFinish
Expand All @@ -299,7 +300,7 @@ def createReport(self,producerThreadResult: PluginThreadOptResult=None, chainThr

report['args'] = self.prepArgsDict()
report['env'] = {'system': system(), 'os': os.name, 'release': release(), 'logical_cpu_count': os.cpu_count()}
report['nodeosVersion'] = Utils.getNodeosVersion()
report['nodeosVersion'] = nodeosVers
return report

def reportAsJSON(self, report: dict) -> json:
Expand Down Expand Up @@ -431,7 +432,7 @@ def runTest(self):

self.testsFinish = datetime.utcnow()

self.report = self.createReport(producerThreadResult=prodResults, chainThreadResult=chainResults, netThreadResult=netResults, tpsTestResult=tpsTestResult)
self.report = self.createReport(producerThreadResult=prodResults, chainThreadResult=chainResults, netThreadResult=netResults, tpsTestResult=tpsTestResult, nodeosVers=self.clusterConfig.nodeosVers)
jsonReport = self.reportAsJSON(self.report)

if not self.ptConfig.quiet:
Expand Down
2 changes: 1 addition & 1 deletion tests/performance_tests/performance_test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def analyzeResultsAndReport(self, testResult: PtbTpsTestResult):
numBlocksToPrune=self.ptbConfig.numAddlBlocksToPrune, numTrxGensUsed=testResult.numGeneratorsUsed,
targetTpsPerGenList=testResult.targetTpsPerGenList, quiet=self.ptbConfig.quiet)
self.report = log_reader.calcAndReport(data=self.data, tpsTestConfig=tpsTestConfig, artifacts=artifactsLocate, argsDict=args, testStart=self.testStart,
completedRun=testResult.completedRun)
completedRun=testResult.completedRun,nodeosVers=self.clusterConfig.nodeosVers)

jsonReport = None
if not self.ptbConfig.quiet or not self.ptbConfig.delReport:
Expand Down