diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt index c00efcc18f..75a51afcae 100644 --- a/tests/performance_tests/CMakeLists.txt +++ b/tests/performance_tests/CMakeLists.txt @@ -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) diff --git a/tests/performance_tests/block_trx_data_log_2_0_14.txt.gz b/tests/performance_tests/block_trx_data_log_2_0_14.txt.gz new file mode 100644 index 0000000000..006f693786 Binary files /dev/null and b/tests/performance_tests/block_trx_data_log_2_0_14.txt.gz differ diff --git a/tests/performance_tests/log_reader.py b/tests/performance_tests/log_reader.py index 786e632d6b..1687a1a686 100644 --- a/tests/performance_tests/log_reader.py +++ b/tests/performance_tests/log_reader.py @@ -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)])) @@ -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 @@ -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): @@ -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) @@ -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): diff --git a/tests/performance_tests/log_reader_tests.py b/tests/performance_tests/log_reader_tests.py index fc9cdf8765..be4c09557f 100755 --- a/tests/performance_tests/log_reader_tests.py +++ b/tests/performance_tests/log_reader_tests.py @@ -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.gz", nodeosVers="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 diff --git a/tests/performance_tests/performance_test.py b/tests/performance_tests/performance_test.py index cf21169d32..0aff352dd4 100755 --- a/tests/performance_tests/performance_test.py +++ b/tests/performance_tests/performance_test.py @@ -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 @@ -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: @@ -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: diff --git a/tests/performance_tests/performance_test_basic.py b/tests/performance_tests/performance_test_basic.py index e665ed4ca9..b1fbf6364b 100755 --- a/tests/performance_tests/performance_test_basic.py +++ b/tests/performance_tests/performance_test_basic.py @@ -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: