Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | def main(self): | ||||
parser.add_argument("--coveragedir", dest="coveragedir", | parser.add_argument("--coveragedir", dest="coveragedir", | ||||
help="Write tested RPC commands into this directory") | help="Write tested RPC commands into this directory") | ||||
parser.add_argument("--configfile", dest="configfile", default=os.path.abspath(os.path.dirname(os.path.realpath( | parser.add_argument("--configfile", dest="configfile", default=os.path.abspath(os.path.dirname(os.path.realpath( | ||||
__file__)) + "/../../config.ini"), help="Location of the test framework config file (default: %(default)s)") | __file__)) + "/../../config.ini"), help="Location of the test framework config file (default: %(default)s)") | ||||
parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", | parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", | ||||
help="Attach a python debugger if test fails") | help="Attach a python debugger if test fails") | ||||
parser.add_argument("--usecli", dest="usecli", default=False, action="store_true", | parser.add_argument("--usecli", dest="usecli", default=False, action="store_true", | ||||
help="use bitcoin-cli instead of RPC for all commands") | help="use bitcoin-cli instead of RPC for all commands") | ||||
parser.add_argument("--perf", dest="perf", default=False, action="store_true", | |||||
help="profile running nodes with perf for the duration of the test") | |||||
parser.add_argument("--with-axionactivation", dest="axionactivation", default=False, action="store_true", | parser.add_argument("--with-axionactivation", dest="axionactivation", default=False, action="store_true", | ||||
help="Activate axion update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | help="Activate axion update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | ||||
self.add_options(parser) | self.add_options(parser) | ||||
self.options = parser.parse_args() | self.options = parser.parse_args() | ||||
self.set_test_params() | self.set_test_params() | ||||
assert hasattr( | assert hasattr( | ||||
self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | ||||
PortSeed.n = self.options.port_seed | PortSeed.n = self.options.port_seed | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | def main(self): | ||||
if self.nodes: | if self.nodes: | ||||
self.stop_nodes() | self.stop_nodes() | ||||
else: | else: | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.cleanup_on_exit = False | node.cleanup_on_exit = False | ||||
self.log.info( | self.log.info( | ||||
"Note: bitcoinds were not stopped and may still be running") | "Note: bitcoinds were not stopped and may still be running") | ||||
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED: | should_clean_up = ( | ||||
not self.options.nocleanup and | |||||
not self.options.noshutdown and | |||||
success != TestStatus.FAILED and | |||||
not self.options.perf | |||||
) | |||||
if should_clean_up: | |||||
self.log.info("Cleaning up {} on exit".format(self.options.tmpdir)) | self.log.info("Cleaning up {} on exit".format(self.options.tmpdir)) | ||||
cleanup_tree_on_exit = True | cleanup_tree_on_exit = True | ||||
elif self.options.perf: | |||||
self.log.warning( | |||||
"Not cleaning up dir {} due to perf data".format( | |||||
self.options.tmpdir)) | |||||
cleanup_tree_on_exit = False | |||||
else: | else: | ||||
self.log.warning( | self.log.warning( | ||||
"Not cleaning up dir {}".format(self.options.tmpdir)) | "Not cleaning up dir {}".format(self.options.tmpdir)) | ||||
cleanup_tree_on_exit = False | cleanup_tree_on_exit = False | ||||
if success == TestStatus.PASSED: | if success == TestStatus.PASSED: | ||||
self.log.info("Tests successful") | self.log.info("Tests successful") | ||||
exit_code = TEST_EXIT_PASSED | exit_code = TEST_EXIT_PASSED | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | def add_nodes(self, num_nodes, extra_args=None, | ||||
timewait=self.rpc_timeout, | timewait=self.rpc_timeout, | ||||
bitcoind=binary[i], | bitcoind=binary[i], | ||||
bitcoin_cli=self.options.bitcoincli, | bitcoin_cli=self.options.bitcoincli, | ||||
coverage_dir=self.options.coveragedir, | coverage_dir=self.options.coveragedir, | ||||
extra_conf=extra_confs[i], | extra_conf=extra_confs[i], | ||||
extra_args=extra_args[i], | extra_args=extra_args[i], | ||||
use_cli=self.options.usecli, | use_cli=self.options.usecli, | ||||
emulator=self.options.emulator, | emulator=self.options.emulator, | ||||
start_perf=self.options.perf, | |||||
)) | )) | ||||
if self.options.axionactivation: | if self.options.axionactivation: | ||||
self.nodes[i].extend_default_args( | self.nodes[i].extend_default_args( | ||||
["-axionactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ["-axionactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ||||
def start_node(self, i, *args, **kwargs): | def start_node(self, i, *args, **kwargs): | ||||
"""Start a bitcoind""" | """Start a bitcoind""" | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |