From 14ec763a51ba94ca236a5189a6addd506d79ba0d Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Thu, 6 Sep 2018 09:49:45 -0500 Subject: [PATCH] Cleanup of errorExit method. GH #5199 --- tests/Cluster.py | 4 ++-- tests/Node.py | 12 ++++++------ tests/WalletMgr.py | 2 +- tests/nodeos_under_min_avail_ram.py | 5 +++-- tests/nodeos_voting_test.py | 18 +++++++++--------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/Cluster.py b/tests/Cluster.py index a99879609..e71649c5f 100644 --- a/tests/Cluster.py +++ b/tests/Cluster.py @@ -446,10 +446,10 @@ class Cluster(object): def getNode(self, nodeId=0, exitOnError=True): if exitOnError and nodeId >= len(self.nodes): Utils.cmdError("cluster never created node %d" % (nodeId)) - errorExit("Failed to retrieve node %d" % (nodeId)) + Utils.errorExit("Failed to retrieve node %d" % (nodeId)) if exitOnError and self.nodes[nodeId] is None: Utils.cmdError("cluster has None value for node %d" % (nodeId)) - errorExit("Failed to retrieve node %d" % (nodeId)) + Utils.errorExit("Failed to retrieve node %d" % (nodeId)) return self.nodes[nodeId] def getNodes(self): diff --git a/tests/Node.py b/tests/Node.py index d0568daed..db90cef6d 100644 --- a/tests/Node.py +++ b/tests/Node.py @@ -289,7 +289,7 @@ class Node(object): errorMsg="Exception during get db node get trans in mongodb with transaction id=%s. %s" % (transId,msg) if exitOnError: Utils.cmdError("" % (errorMsg)) - errorExit("Failed to retrieve transaction in mongodb for transaction id=%s" % (transId)) + Utils.errorExit("Failed to retrieve transaction in mongodb for transaction id=%s" % (transId)) elif not silentErrors: Utils.Print("ERROR: %s" % (errorMsg)) return None @@ -469,7 +469,7 @@ class Node(object): msg=ex.output.decode("utf-8") if exitOnError: Utils.cmdError("Exception during get account from db for %s. %s" % (name, msg)) - errorExit("Failed during get account from db for %s. %s" % (name, msg)) + Utils.errorExit("Failed during get account from db for %s. %s" % (name, msg)) Utils.Print("ERROR: Exception during get account from db for %s. %s" % (name, msg)) return None @@ -596,12 +596,12 @@ class Node(object): Utils.Print("ERROR: Exception during funds transfer. %s" % (msg)) if exitOnError: Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination)) - errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination)) + Utils.errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination)) return None if trans is None: Utils.cmdError("could not transfer \"%s\" from %s to %s" % (amountStr, source, destination)) - errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination)) + Utils.errorExit("Failed to transfer \"%s\" from %s to %s" % (amountStr, source, destination)) return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError) @@ -901,7 +901,7 @@ class Node(object): exitMsg="" if exitOnError and trans is None: Utils.cmdError("could not %s - %s" % (cmdDesc,exitMsg)) - errorExit("Failed to %s" % (cmdDesc)) + Utils.errorExit("Failed to %s" % (cmdDesc)) return trans @@ -913,7 +913,7 @@ class Node(object): if not self.waitForTransInBlock(transId): if exitOnError: Utils.cmdError("transaction with id %s never made it to a block" % (transId)) - errorExit("Failed to find transaction with id %s in a block before timeout" % (transId)) + Utils.errorExit("Failed to find transaction with id %s in a block before timeout" % (transId)) return None return trans diff --git a/tests/WalletMgr.py b/tests/WalletMgr.py index 4edda77d7..870cd41a0 100644 --- a/tests/WalletMgr.py +++ b/tests/WalletMgr.py @@ -71,7 +71,7 @@ class WalletMgr(object): if m is None: if exitOnError: Utils.cmdError("could not create wallet %s" % (name)) - errorExit("Failed to create wallet %s" % (name)) + Utils.errorExit("Failed to create wallet %s" % (name)) Utils.Print("ERROR: wallet password parser failure") return None diff --git a/tests/nodeos_under_min_avail_ram.py b/tests/nodeos_under_min_avail_ram.py index 016dfbceb..d06c1fe9d 100755 --- a/tests/nodeos_under_min_avail_ram.py +++ b/tests/nodeos_under_min_avail_ram.py @@ -13,6 +13,9 @@ import decimal import math import re +Print=Utils.Print +errorExit=Utils.errorExit + class NamedAccounts: def __init__(self, cluster, numAccounts): @@ -50,8 +53,6 @@ class NamedAccounts: # --dump-error-details # --keep-logs ############################################################### -Print=Utils.Print -errorExit=Utils.errorExit args = TestHelper.parse_args({"--dump-error-details","--keep-logs","-v","--leave-running","--clean-run"}) Utils.Debug=args.v diff --git a/tests/nodeos_voting_test.py b/tests/nodeos_voting_test.py index dac5f8dd4..b560795b6 100755 --- a/tests/nodeos_voting_test.py +++ b/tests/nodeos_voting_test.py @@ -36,7 +36,7 @@ def getBlockProducer(node, blockNum): blockProducer=block["producer"] if blockProducer is None: Utils.cmdError("could not get producer for block number %s" % (blockNum)) - errorExit("Failed to get block's producer") + Utils.errorExit("Failed to get block's producer") return blockProducer def getNodeNum(cluster, node): @@ -55,10 +55,10 @@ def validBlockProducer(prodsActive, prodsSeen, blockNum, node): blockProducer=getBlockProducer(node, blockNum) if blockProducer not in prodsActive: Utils.cmdError("unexpected block producer %s at blockNum=%s" % (blockProducer,blockNum)) - errorExit("Failed because of invalid block producer") + Utils.errorExit("Failed because of invalid block producer") if not prodsActive[blockProducer]: Utils.cmdError("block producer %s for blockNum=%s not elected, belongs to node %s" % (blockProducer, blockNum, ProducerToNode.map[blockProducer])) - errorExit("Failed because of incorrect block producer") + Utils.errorExit("Failed because of incorrect block producer") prodsSeen[blockProducer]=True def getNextCleanProductionCycle(trans, node): @@ -149,7 +149,7 @@ def verifyProductionRounds(trans, node, prodsActive, rounds): # each new set of 12 blocks should have a different blockProducer if lastBlockProducer is not None and lastBlockProducer==getBlockProducer(node, blockNum): Utils.cmdError("expected blockNum %s to be produced by any of the valid producers except %s" % (blockNum, lastBlockProducer)) - errorExit("Failed because of incorrect block producer order") + Utils.errorExit("Failed because of incorrect block producer order") # make sure that the next set of 12 blocks all have the same blockProducer lastBlockProducer=getBlockProducer(node, blockNum) @@ -167,14 +167,14 @@ def verifyProductionRounds(trans, node, prodsActive, rounds): printStr+=" " newBlockNum+=1 Utils.cmdError("expected blockNum %s (started from %s) to be produced by %s, but produded by %s: round=%s, prod slot=%s, prod num=%s - %s" % (blockNum, startingFrom, lastBlockProducer, blockProducer, i, j, k, printStr)) - errorExit("Failed because of incorrect block producer order") + Utils.errorExit("Failed because of incorrect block producer order") blockNum+=1 # make sure that we have seen all 21 producers prodsSeenKeys=prodsSeen.keys() if len(prodsSeenKeys)!=21: Utils.cmdError("only saw %s producers of expected 21. At blockNum %s only the following producers were seen: %s" % (len(prodsSeenKeys), blockNum, ",".join(prodsSeenKeys))) - errorExit("Failed because of missing block producers") + Utils.errorExit("Failed because of missing block producers") Utils.Debug=temp @@ -211,14 +211,14 @@ try: Print("Stand up cluster") if cluster.launch(prodCount=prodCount, onlyBios=False, dontKill=dontKill, pnodes=totalNodes, totalNodes=totalNodes, totalProducers=totalNodes*21, p2pPlugin=p2pPlugin, useBiosBootFile=False) is False: Utils.cmdError("launcher") - errorExit("Failed to stand up eos cluster.") + Utils.errorExit("Failed to stand up eos cluster.") Print("Validating system accounts after bootstrap") cluster.validateAccounts(None) accounts=cluster.createAccountKeys(5) if accounts is None: - errorExit("FAILURE - create keys") + Utils.errorExit("FAILURE - create keys") accounts[0].name="tester111111" accounts[1].name="tester222222" accounts[2].name="tester333333" @@ -232,7 +232,7 @@ try: walletMgr.cleanup() if walletMgr.launch() is False: Utils.cmdError("%s" % (WalletdName)) - errorExit("Failed to stand up eos walletd.") + Utils.errorExit("Failed to stand up eos walletd.") testWallet=walletMgr.create(testWalletName, [cluster.eosioAccount,accounts[0],accounts[1],accounts[2],accounts[3],accounts[4]]) -- GitLab