diff --git a/.travis.yml b/.travis.yml index 69dff69b363879ef66dfab7a3396269ef7f607dc..ed440a76727994ae5cd88359fca32d011a785d54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,10 +77,10 @@ script: - mkdir build && cd build - ${CMAKE_DIR}cmake -G Ninja -DWASM_LLVM_CONFIG=$TRAVIS_BUILD_DIR/ext/wasm-compiler/bin/llvm-config -DSecp256k1_ROOT_DIR=$TRAVIS_BUILD_DIR/ext -DBINARYEN_ROOT=$TRAVIS_BUILD_DIR/ext/wasm-compiler -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/ext -DCMAKE_BUILD_TYPE=Release $EOS_CMAKE_OPTIONS .. - ninja -j4 - - tests/eosd_run_test.py --host=localhost --port=8888 --dumpErrorDetails' + - tests/eosd_run_test.py --host=localhost --port=8888 --dump-error-details - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/p2p_tests/sync/test.sh' - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/p2p_tests/sync/test.sh -p 2 -d 10' - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/run_tests.sh' - - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/eosd_run_test.py --mongoDb --dumpErrorDetails' + - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/eosd_run_test.py --mongodb --dump-error-details' - ctest --output-on-failure - cpack diff --git a/tests/eosd_run_test.py b/tests/eosd_run_test.py index 680d3f76f0d4229cba7f4d058595f9760eec57d6..7eb78b5bf5a6bc0440c846688254af3b9cbf01a3 100755 --- a/tests/eosd_run_test.py +++ b/tests/eosd_run_test.py @@ -74,6 +74,7 @@ killEosInstances=True if amINoon: testUtils.Utils.iAmNoon() + testUtils.Utils.setMongoSyncTime(50) try: Print("BEGIN") @@ -332,7 +333,10 @@ try: if not enableMongo: transaction=node.getTransaction(transId) else: - transaction=node.getMessageFromDb(transId, retry=False) + if amINoon: + transaction=node.getActionFromDb(transId) + else: + transaction=node.getMessageFromDb(transId) if transaction is None: cmdError("eosc get transaction trans_id") errorExit("Failed to retrieve transaction details %s" % (transId)) @@ -397,7 +401,11 @@ try: Print("verify abi is set") account=node.getEosAccountFromDb(currencyAccount.name) abiName=account["abi"]["structs"][0]["name"] - abiActionName=account["abi"]["actions"][0]["action_name"] + abiActionName=None + if not amINoon: + abiActionName=account["abi"]["actions"][0]["action_name"] + else: + abiActionName=account["abi"]["actions"][0]["name"] abiType=account["abi"]["actions"][0]["type"] if abiName != "transfer" or abiActionName != "transfer" or abiType != "transfer": errorExit("FAILURE - get table currency account failed", raw=True) diff --git a/tests/testUtils.py b/tests/testUtils.py index 49b784ba2af11102dfcd3efb718003680186a394..bc9d487fa672aadfa40216d4a7967a4a6c9d9ff6 100755 --- a/tests/testUtils.py +++ b/tests/testUtils.py @@ -43,9 +43,12 @@ class Utils: SigKillTag="kill" SigTermTag="term" + # mongoSyncTime: eosiod mongodb plugin seems to sync with a 10-15 seconds delay. This will inject + # a wait period before the 2nd DB check (if first check fails) + mongoSyncTime=25 amINoon=False - # I am in the NOON branch + # Configure for the NOON branch @staticmethod def iAmNoon(): Utils.amINoon=True @@ -53,6 +56,10 @@ class Utils: Utils.EosWalletPath="programs/eosio-walletd/eosio-walletd" Utils.EosServerName="eosiod" Utils.EosServerPath="programs/eosiod/%s" % (Utils.EosServerName) + + @staticmethod + def setMongoSyncTime(syncTime): + Utils.mongoSyncTime=syncTime @staticmethod def getChainStrategies(): @@ -101,16 +108,14 @@ class Account(object): ########################################################################################### class Node(object): - # mongoSyncTime: eosiod mongodb plugin seems to sync with a 10-15 seconds delay. This will inject - # a wait period before the 2nd DB check (if first check fails) - def __init__(self, host, port, pid=None, cmd=None, alive=None, mongoSyncTime=25, enableMongo=False, mongoHost="localhost", mongoPort=27017, mongoDb="EOStest"): + def __init__(self, host, port, pid=None, cmd=None, alive=None, enableMongo=False, mongoHost="localhost", mongoPort=27017, mongoDb="EOStest"): self.host=host self.port=port self.pid=pid self.cmd=cmd self.alive=alive self.enableMongo=enableMongo - self.mongoSyncTime=None if mongoSyncTime < 1 else mongoSyncTime + self.mongoSyncTime=None if Utils.mongoSyncTime < 1 else Utils.mongoSyncTime self.mongoHost=mongoHost self.mongoPort=mongoPort self.mongoDb=mongoDb @@ -326,10 +331,33 @@ class Node(object): return None + + + def getActionFromDb(self, transId, retry=True, silentErrors=False): + for i in range(2): + cmd="%s %s" % (Utils.MongoPath, self.mongoEndpointArgs) + subcommand='db.Actions.findOne( { "transaction_id": "%s" } )' % (transId) + Utils.Debug and Utils.Print("cmd: echo '%s' | %s" % (subcommand, cmd)) + try: + trans=Node.runMongoCmdReturnJson(cmd.split(), subcommand) + if trans is not None: + return trans + except subprocess.CalledProcessError as ex: + if not silentErrors: + msg=ex.output.decode("utf-8") + Utils.Print("ERROR: Exception during get db node get message. %s" % (msg)) + return None + if not retry: + break + if self.mongoSyncTime is not None: + time.sleep(self.mongoSyncTime) + + return None + def getMessageFromDb(self, transId, retry=True, silentErrors=False): for i in range(2): cmd="%s %s" % (Utils.MongoPath, self.mongoEndpointArgs) - subcommand='db.Messages.findOne( { transaction_id: "%s" } )' % (transId) + subcommand='db.Messages.findOne( { "transaction_id": "%s" } )' % (transId) Utils.Debug and Utils.Print("cmd: echo '%s' | %s" % (subcommand, cmd)) try: trans=Node.runMongoCmdReturnJson(cmd.split(), subcommand) @@ -951,7 +979,6 @@ class Cluster(object): __chainSyncStrategies=Utils.getChainStrategies() __WalletName="MyWallet" __localHost="localhost" - #__portStart=8888 __lastTrans=None # init accounts @@ -983,9 +1010,8 @@ class Cluster(object): self.mongoUri="" if self.enableMongo: self.mongoUri="mongodb://%s:%d/%s" % (mongoHost, mongoPort, mongoDb) - #self.mongoEndpointArgs += "mongodb://%s:%d/%s" % (mongoHost, mongoPort, mongoDb) self.mongoEndpointArgs += "--host %s --port %d %s" % (mongoHost, mongoPort, mongoDb) - self.endpointArgs="" + #self.endpointArgs="" def setChainStrategy(self, chainSyncStrategy=Utils.SyncReplayTag): self.__chainSyncStrategy=self.__chainSyncStrategies.get(chainSyncStrategy)