Skip to content

Commit

Permalink
Added FAILFAST for functional test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Jun 5, 2019
1 parent d4b23bf commit 95fd7d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis/test_06_script_b.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ fi

if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
BEGIN_FOLD functional-tests
DOCKER_EXEC LOCAL_NTP=1 ./qa/pull-tester/rpc-tests.py -parallel=1 --coverage
DOCKER_EXEC LOCAL_NTP=1 ./qa/pull-tester/rpc-tests.py -parallel=1 --coverage --failfast
END_FOLD
fi
8 changes: 7 additions & 1 deletion qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
'mnemonic.py',
'sendtoaddress.py',
'stakeimmaturebalance.py',
'rpc-help.py',
'rpc-help.py',
]
#if ENABLE_ZMQ:
# testScripts.append('zmq_test.py')
Expand Down Expand Up @@ -257,6 +257,12 @@ def runtests():
print('stderr:\n' if not stderr == '' else '', stderr)
results += "%s | %s | %s s\n" % (name.ljust(max_len_name), str(passed).ljust(6), duration)
print("Pass: %s%s%s, Duration: %s s\n" % (BOLD[1], passed, BOLD[0], duration))

# Check if we need to quit
if FAILFAST and not passed:
logging.debug("Early exiting after test failure")
break

results += BOLD[1] + "\n%s | %s | %s s (accumulated)" % ("ALL".ljust(max_len_name), str(all_passed).ljust(6), time_sum) + BOLD[0]
print(results)
print("\nRuntime: %s s" % (int(time.time() - time0)))
Expand Down
4 changes: 4 additions & 0 deletions qa/rpc-tests/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
stop_node,
wait_navcoinds,
enable_coverage,
failfast,
check_json_precision,
initialize_chain_clean,
PortSeed,
Expand Down Expand Up @@ -120,6 +121,9 @@ def main(self):
help="The seed to use for assigning port numbers (default: current process id)")
parser.add_option("--coveragedir", dest="coveragedir",
help="Write tested RPC commands into this directory")
parser.add_option('--failfast', action='store_true',
help='stop execution after the first test failure')

self.add_options(parser)
(self.options, self.args) = parser.parse_args()

Expand Down
8 changes: 7 additions & 1 deletion qa/rpc-tests/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .authproxy import AuthServiceProxy, JSONRPCException

COVERAGE_DIR = None
FAILFAST = False

# The maximum number of nodes a single test can spawn
MAX_NODES = 8
Expand All @@ -51,7 +52,7 @@ class PortSeed:

def enable_mocktime():
#For backwared compatibility of the python scripts
#with previous versions of the cache, set MOCKTIME
#with previous versions of the cache, set MOCKTIME
#to Jan 1, 2014 + (201 * 10 * 60)
global MOCKTIME
MOCKTIME = 1388534400 + (201 * 10 * 60)
Expand All @@ -68,6 +69,11 @@ def enable_coverage(dirname):
global COVERAGE_DIR
COVERAGE_DIR = dirname

def failfast():
"""Quit the test suite as soon as we have a failed test"""
global FAILFAST
FAILFAST = True


def get_rpc_proxy(url, node_number, timeout=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/wallet-hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run_test (self):
non_hd_add = self.nodes[0].getnewaddress()
self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add))

# This should be enough to keep the master key and the non-HD key
# This should be enough to keep the master key and the non-HD key
self.nodes[1].backupwallet(tmpdir + "hd.bak")
#self.nodes[1].dumpwallet(tmpdir + "hd.dump")

Expand Down

0 comments on commit 95fd7d6

Please sign in to comment.