From 1cf32d615def1b19aecd8e393b2c2593650dd360 Mon Sep 17 00:00:00 2001 From: Clayton Calabrese Date: Tue, 21 Feb 2023 15:42:48 -0600 Subject: [PATCH 1/5] give ability to cleanup transaction generator in TestHelper shutdown --- tests/TestHarness/TestHelper.py | 8 +++++++- tests/nodeos_contrl_c_test.py | 4 ++-- tests/nodeos_snapshot_diff_test.py | 2 +- tests/nodeos_startup_catchup.py | 2 +- tests/performance_tests/log_reader.py | 2 +- tests/performance_tests/performance_test_basic.py | 10 +++------- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/TestHarness/TestHelper.py b/tests/TestHarness/TestHelper.py index 01874c6be0..68e4d353b2 100644 --- a/tests/TestHarness/TestHelper.py +++ b/tests/TestHarness/TestHelper.py @@ -1,6 +1,7 @@ from .testUtils import Utils from .Cluster import Cluster from .WalletMgr import WalletMgr +from .launch_transaction_generators import TransactionGeneratorsLauncher from datetime import datetime import platform @@ -148,12 +149,14 @@ def printSystemInfo(prefix): @staticmethod # pylint: disable=too-many-arguments - def shutdown(cluster, walletMgr, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False): + def shutdown(cluster, walletMgr, trxGenLauncher=None, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False): """Cluster and WalletMgr shutdown and cleanup.""" assert(cluster) assert(isinstance(cluster, Cluster)) if walletMgr: assert(isinstance(walletMgr, WalletMgr)) + if trxGenLauncher is not None: + assert(isinstance(trxGenLauncher, TransactionGeneratorsLauncher)) assert(isinstance(testSuccessful, bool)) assert(isinstance(killEosInstances, bool)) assert(isinstance(killWallet, bool)) @@ -199,3 +202,6 @@ def reportProductionAnalysis(thresholdMs): Utils.Print("Cleanup wallet data.") walletMgr.cleanup() + if trxGenLauncher is not None: + Utils.Print("Shut down the TransactionGeneratorsLauncher and TransactionGenerators") + trxGenLauncher.killAll() diff --git a/tests/nodeos_contrl_c_test.py b/tests/nodeos_contrl_c_test.py index 2960b339ec..d71b7786ab 100755 --- a/tests/nodeos_contrl_c_test.py +++ b/tests/nodeos_contrl_c_test.py @@ -112,11 +112,11 @@ testSuccessful = nonProdNode.kill(signal.SIGTERM) if not testSuccessful: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) + TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) errorExit("Failed to kill the seed node") finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) + TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) errorCode = 0 if testSuccessful else 1 exit(errorCode) \ No newline at end of file diff --git a/tests/nodeos_snapshot_diff_test.py b/tests/nodeos_snapshot_diff_test.py index 13f2570d77..e46f30bf48 100755 --- a/tests/nodeos_snapshot_diff_test.py +++ b/tests/nodeos_snapshot_diff_test.py @@ -199,7 +199,7 @@ def waitForBlock(node, blockNum, blockType=BlockType.head, timeout=None, reportI testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) + TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file diff --git a/tests/nodeos_startup_catchup.py b/tests/nodeos_startup_catchup.py index a358057061..164ebd60e0 100755 --- a/tests/nodeos_startup_catchup.py +++ b/tests/nodeos_startup_catchup.py @@ -201,7 +201,7 @@ def waitForNodeStarted(node): testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) + TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file diff --git a/tests/performance_tests/log_reader.py b/tests/performance_tests/log_reader.py index 593d07a5f5..5448003f70 100644 --- a/tests/performance_tests/log_reader.py +++ b/tests/performance_tests/log_reader.py @@ -10,7 +10,7 @@ from pathlib import Path, PurePath sys.path.append(str(PurePath(PurePath(Path(__file__).absolute()).parent).parent)) -from TestHarness import Utils +from TestHarness import Utils, TransactionGeneratorsLauncher from dataclasses import dataclass, asdict, field from platform import release, system from datetime import datetime diff --git a/tests/performance_tests/performance_test_basic.py b/tests/performance_tests/performance_test_basic.py index b2d1df31bd..b9ae851999 100755 --- a/tests/performance_tests/performance_test_basic.py +++ b/tests/performance_tests/performance_test_basic.py @@ -370,13 +370,13 @@ def runTpsTest(self) -> PtbTpsTestResult: self.data.startBlock = self.waitForEmptyBlocks(self.validationNode, self.emptyBlockGoal) tpsTrxGensConfig = TpsTrxGensConfig(targetTps=self.ptbConfig.targetTps, tpsLimitPerGenerator=self.ptbConfig.tpsLimitPerGenerator) - trxGenLauncher = TransactionGeneratorsLauncher(chainId=chainId, lastIrreversibleBlockId=lib_id, contractOwnerAccount=self.clusterConfig.specifiedContract.accountName, + self.cluster.trxGenLauncher = TransactionGeneratorsLauncher(chainId=chainId, lastIrreversibleBlockId=lib_id, contractOwnerAccount=self.clusterConfig.specifiedContract.accountName, accts=','.join(map(str, self.accountNames)), privateKeys=','.join(map(str, self.accountPrivKeys)), trxGenDurationSec=self.ptbConfig.testTrxGenDurationSec, logDir=self.trxGenLogDirPath, abiFile=abiFile, actionsData=actionsDataJson, actionsAuths=actionsAuthsJson, peerEndpoint=self.producerNode.host, port=self.producerP2pPort, tpsTrxGensConfig=tpsTrxGensConfig) - trxGenExitCodes = trxGenLauncher.launch() + trxGenExitCodes = self.cluster.trxGenLauncher.launch() print(f"Transaction Generator exit codes: {trxGenExitCodes}") for exitCode in trxGenExitCodes: if exitCode != 0: @@ -460,7 +460,6 @@ def postTpsTestSteps(self): def runTest(self) -> bool: testSuccessful = False - completedRun = False try: # Kill any existing instances and launch cluster @@ -488,6 +487,7 @@ def runTest(self) -> bool: TestHelper.shutdown( self.cluster, self.walletMgr, + self.cluster.trxGenLauncher, testSuccessful, self.testHelperConfig._killEosInstances, self.testHelperConfig._killWallet, @@ -499,10 +499,6 @@ def runTest(self) -> bool: if not self.ptbConfig.delPerfLogs: self.captureLowLevelArtifacts() - if not completedRun: - os.system("pkill trx_generator") - print("Test run cancelled early via SIGINT") - if self.ptbConfig.delPerfLogs: print(f"Cleaning up logs directory: {self.loggingConfig.logDirPath}") self.testDirsCleanup(self.ptbConfig.delReport) From a2ee13ad39bb311a96874ff1de1523b4490e54e0 Mon Sep 17 00:00:00 2001 From: Clayton Calabrese Date: Tue, 21 Feb 2023 20:40:44 -0600 Subject: [PATCH 2/5] rearrange shutdown arguments to accomodate the 20 or so tests using shutdown without keyword arguments --- tests/TestHarness/TestHelper.py | 2 +- tests/nodeos_contrl_c_test.py | 4 ++-- tests/nodeos_snapshot_diff_test.py | 2 +- tests/nodeos_startup_catchup.py | 2 +- tests/performance_tests/performance_test_basic.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/TestHarness/TestHelper.py b/tests/TestHarness/TestHelper.py index 68e4d353b2..f1504f8a60 100644 --- a/tests/TestHarness/TestHelper.py +++ b/tests/TestHarness/TestHelper.py @@ -149,7 +149,7 @@ def printSystemInfo(prefix): @staticmethod # pylint: disable=too-many-arguments - def shutdown(cluster, walletMgr, trxGenLauncher=None, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False): + def shutdown(cluster, walletMgr, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False, trxGenLauncher=None): """Cluster and WalletMgr shutdown and cleanup.""" assert(cluster) assert(isinstance(cluster, Cluster)) diff --git a/tests/nodeos_contrl_c_test.py b/tests/nodeos_contrl_c_test.py index d71b7786ab..9ccaf631dd 100755 --- a/tests/nodeos_contrl_c_test.py +++ b/tests/nodeos_contrl_c_test.py @@ -112,11 +112,11 @@ testSuccessful = nonProdNode.kill(signal.SIGTERM) if not testSuccessful: - TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True, trxGenLauncher=cluster.trxGenLauncher) errorExit("Failed to kill the seed node") finally: - TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True, trxGenLauncher=cluster.trxGenLauncher) errorCode = 0 if testSuccessful else 1 exit(errorCode) \ No newline at end of file diff --git a/tests/nodeos_snapshot_diff_test.py b/tests/nodeos_snapshot_diff_test.py index e46f30bf48..caba2a91c4 100755 --- a/tests/nodeos_snapshot_diff_test.py +++ b/tests/nodeos_snapshot_diff_test.py @@ -199,7 +199,7 @@ def waitForBlock(node, blockNum, blockType=BlockType.head, timeout=None, reportI testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails, trxGenLauncher=cluster.trxGenLauncher) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file diff --git a/tests/nodeos_startup_catchup.py b/tests/nodeos_startup_catchup.py index 164ebd60e0..0660807da4 100755 --- a/tests/nodeos_startup_catchup.py +++ b/tests/nodeos_startup_catchup.py @@ -201,7 +201,7 @@ def waitForNodeStarted(node): testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, cluster.trxGenLauncher, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails, trxGenLauncher=cluster.trxGenLauncher) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file diff --git a/tests/performance_tests/performance_test_basic.py b/tests/performance_tests/performance_test_basic.py index b9ae851999..cb8cacd1c3 100755 --- a/tests/performance_tests/performance_test_basic.py +++ b/tests/performance_tests/performance_test_basic.py @@ -487,13 +487,13 @@ def runTest(self) -> bool: TestHelper.shutdown( self.cluster, self.walletMgr, - self.cluster.trxGenLauncher, testSuccessful, self.testHelperConfig._killEosInstances, self.testHelperConfig._killWallet, self.testHelperConfig.keepLogs, self.testHelperConfig.killAll, - self.testHelperConfig.dumpErrorDetails + self.testHelperConfig.dumpErrorDetails, + trxGenLauncher=self.cluster.trxGenLauncher ) if not self.ptbConfig.delPerfLogs: From 2fd6ad6057ce86df41f2e74bf810c87a9f604b15 Mon Sep 17 00:00:00 2001 From: Clayton Calabrese Date: Wed, 22 Feb 2023 12:37:52 -0600 Subject: [PATCH 3/5] Unwind shutdown changes as cluster killall will handle the transactiongeneratorlauncher now that it is set --- tests/TestHarness/TestHelper.py | 7 +------ tests/nodeos_contrl_c_test.py | 4 ++-- tests/nodeos_snapshot_diff_test.py | 2 +- tests/performance_tests/log_reader.py | 2 +- tests/performance_tests/performance_test_basic.py | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/TestHarness/TestHelper.py b/tests/TestHarness/TestHelper.py index f1504f8a60..2fac4e6919 100644 --- a/tests/TestHarness/TestHelper.py +++ b/tests/TestHarness/TestHelper.py @@ -149,14 +149,12 @@ def printSystemInfo(prefix): @staticmethod # pylint: disable=too-many-arguments - def shutdown(cluster, walletMgr, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False, trxGenLauncher=None): + def shutdown(cluster, walletMgr, testSuccessful=True, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=False): """Cluster and WalletMgr shutdown and cleanup.""" assert(cluster) assert(isinstance(cluster, Cluster)) if walletMgr: assert(isinstance(walletMgr, WalletMgr)) - if trxGenLauncher is not None: - assert(isinstance(trxGenLauncher, TransactionGeneratorsLauncher)) assert(isinstance(testSuccessful, bool)) assert(isinstance(killEosInstances, bool)) assert(isinstance(killWallet, bool)) @@ -202,6 +200,3 @@ def reportProductionAnalysis(thresholdMs): Utils.Print("Cleanup wallet data.") walletMgr.cleanup() - if trxGenLauncher is not None: - Utils.Print("Shut down the TransactionGeneratorsLauncher and TransactionGenerators") - trxGenLauncher.killAll() diff --git a/tests/nodeos_contrl_c_test.py b/tests/nodeos_contrl_c_test.py index 9ccaf631dd..2960b339ec 100755 --- a/tests/nodeos_contrl_c_test.py +++ b/tests/nodeos_contrl_c_test.py @@ -112,11 +112,11 @@ testSuccessful = nonProdNode.kill(signal.SIGTERM) if not testSuccessful: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True, trxGenLauncher=cluster.trxGenLauncher) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) errorExit("Failed to kill the seed node") finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True, trxGenLauncher=cluster.trxGenLauncher) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True) errorCode = 0 if testSuccessful else 1 exit(errorCode) \ No newline at end of file diff --git a/tests/nodeos_snapshot_diff_test.py b/tests/nodeos_snapshot_diff_test.py index caba2a91c4..13f2570d77 100755 --- a/tests/nodeos_snapshot_diff_test.py +++ b/tests/nodeos_snapshot_diff_test.py @@ -199,7 +199,7 @@ def waitForBlock(node, blockNum, blockType=BlockType.head, timeout=None, reportI testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails, trxGenLauncher=cluster.trxGenLauncher) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file diff --git a/tests/performance_tests/log_reader.py b/tests/performance_tests/log_reader.py index 5448003f70..593d07a5f5 100644 --- a/tests/performance_tests/log_reader.py +++ b/tests/performance_tests/log_reader.py @@ -10,7 +10,7 @@ from pathlib import Path, PurePath sys.path.append(str(PurePath(PurePath(Path(__file__).absolute()).parent).parent)) -from TestHarness import Utils, TransactionGeneratorsLauncher +from TestHarness import Utils from dataclasses import dataclass, asdict, field from platform import release, system from datetime import datetime diff --git a/tests/performance_tests/performance_test_basic.py b/tests/performance_tests/performance_test_basic.py index cb8cacd1c3..cb847f0f8a 100755 --- a/tests/performance_tests/performance_test_basic.py +++ b/tests/performance_tests/performance_test_basic.py @@ -492,8 +492,7 @@ def runTest(self) -> bool: self.testHelperConfig._killWallet, self.testHelperConfig.keepLogs, self.testHelperConfig.killAll, - self.testHelperConfig.dumpErrorDetails, - trxGenLauncher=self.cluster.trxGenLauncher + self.testHelperConfig.dumpErrorDetails ) if not self.ptbConfig.delPerfLogs: From 1935103562e6850a1d6bf16b44290f5fd5399198 Mon Sep 17 00:00:00 2001 From: Clayton Calabrese Date: Wed, 22 Feb 2023 12:42:38 -0600 Subject: [PATCH 4/5] remove shutdown change from nodeos_startup_catchup --- tests/nodeos_startup_catchup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/nodeos_startup_catchup.py b/tests/nodeos_startup_catchup.py index 0660807da4..a358057061 100755 --- a/tests/nodeos_startup_catchup.py +++ b/tests/nodeos_startup_catchup.py @@ -201,7 +201,7 @@ def waitForNodeStarted(node): testSuccessful=True finally: - TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails, trxGenLauncher=cluster.trxGenLauncher) + TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=killEosInstances, killWallet=killWallet, keepLogs=keepLogs, cleanRun=killAll, dumpErrorDetails=dumpErrorDetails) exitCode = 0 if testSuccessful else 1 exit(exitCode) \ No newline at end of file From c15ed53794df431e3c832a937e21e8226c74a01d Mon Sep 17 00:00:00 2001 From: Clayton Calabrese Date: Wed, 22 Feb 2023 12:43:10 -0600 Subject: [PATCH 5/5] remove unused import --- tests/TestHarness/TestHelper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TestHarness/TestHelper.py b/tests/TestHarness/TestHelper.py index 2fac4e6919..01874c6be0 100644 --- a/tests/TestHarness/TestHelper.py +++ b/tests/TestHarness/TestHelper.py @@ -1,7 +1,6 @@ from .testUtils import Utils from .Cluster import Cluster from .WalletMgr import WalletMgr -from .launch_transaction_generators import TransactionGeneratorsLauncher from datetime import datetime import platform