Browse Source

test suite: remove datadir after stopping daemons

The MMGen Project 2 months ago
parent
commit
3f5ce98fda

+ 1 - 1
test/cmdtest_d/ct_autosign.py

@@ -186,7 +186,7 @@ class CmdTestAutosignBase(CmdTestBase):
 
 	def stop_daemons(self):
 		self.spawn('', msg_only=True)
-		stop_test_daemons(*self.network_ids)
+		stop_test_daemons(*self.network_ids, remove_datadir=True)
 		return 'ok'
 
 	def run_setup(

+ 1 - 1
test/cmdtest_d/ct_ethdev.py

@@ -1493,7 +1493,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 	def stop(self):
 		self.spawn('', msg_only=True)
 		if not cfg.no_daemon_stop:
-			if not stop_test_daemons(self.proto.coin+'_rt'):
+			if not stop_test_daemons(self.proto.coin+'_rt', remove_datadir=True):
 				return False
 		set_vt100()
 		return 'ok'

+ 1 - 1
test/cmdtest_d/ct_misc.py

@@ -141,7 +141,7 @@ class CmdTestMisc(CmdTestBase):
 		if cfg.pexpect_spawn:
 			t.send('q')
 		if not cfg.no_altcoin:
-			stop_test_daemons('ltc', 'eth')
+			stop_test_daemons('ltc', 'eth', remove_datadir=True)
 		return t
 
 	def term_echo(self):

+ 1 - 1
test/cmdtest_d/ct_ref_altcoin.py

@@ -113,7 +113,7 @@ class CmdTestRefAltcoin(CmdTestRef, CmdTestBase):
 				t.read()
 				t.ok()
 				if proto.sign_mode == 'daemon' and not proto.network_id == 'btc':
-					stop_test_daemons(proto.network_id)
+					stop_test_daemons(proto.network_id, remove_datadir=True)
 		return 'ok'
 
 	def ref_altcoin_addrgen(

+ 1 - 1
test/daemontest_d/ut_exec.py

@@ -113,4 +113,4 @@ class unit_tests:
 		return self._test_cmd(['start'], 'Checking status of coin daemons...')
 
 	def stop(self, name, ut):
-		return self._test_cmd(['stop'], 'Stopping coin daemons...')
+		return self._test_cmd(['stop', '--remove-datadir'], 'Stopping coin daemons...')

+ 1 - 1
test/daemontest_d/ut_msg.py

@@ -116,7 +116,7 @@ async def run_test(network_id, chksum, msghash_type='raw'):
 	msg(m.format(single_addr_coin))
 
 	if m.proto.sign_mode == 'daemon':
-		stop_test_daemons(network_id)
+		stop_test_daemons(network_id, remove_datadir=True)
 
 	msg('\n')
 

+ 5 - 1
test/include/coin_daemon_control.py

@@ -43,6 +43,7 @@ opts_data = {
 -m, --mainnet-only   Perform operations for mainnet daemons only
 -n, --no-daemonize   Don't fork daemon to background
 -p, --port-shift=    Shift the RPC port by this number
+-r, --remove-datadir Remove the datadir(s) after stopping the daemon(s)
 -s, --get-state      Get the state of the daemon(s) and exit
 -t, --testing        Testing mode.  Print commands but don't execute them
 -q, --quiet          Produce quieter output
@@ -99,7 +100,7 @@ def run(network_id=None, proto=None, daemon_id=None, missing_exec_ok=False):
 		return
 
 	d.debug = d.debug or cfg.debug
-	d.wait = not cfg.no_wait
+	d.wait = cfg.remove_datadir or not cfg.no_wait
 
 	if missing_exec_ok:
 		try:
@@ -121,6 +122,9 @@ def run(network_id=None, proto=None, daemon_id=None, missing_exec_ok=False):
 			async_run(d.rpc.stop_daemon(quiet=cfg.quiet))
 		else:
 			d.cmd(action, quiet=cfg.quiet)
+			if action == 'stop' and cfg.remove_datadir:
+				cfg._util.vmsg(f'Removing ‘{d.datadir}’')
+				d.remove_datadir()
 
 def main():
 

+ 1 - 1
test/include/common.py

@@ -296,7 +296,7 @@ def stop_test_daemons(*network_ids, force=False, remove_datadir=False):
 		return test_daemons_ops(*network_ids, op='stop', remove_datadir=remove_datadir)
 
 def restart_test_daemons(*network_ids, remove_datadir=False):
-	if not stop_test_daemons(*network_ids):
+	if not stop_test_daemons(*network_ids, remove_datadir=remove_datadir):
 		return False
 	return start_test_daemons(*network_ids, remove_datadir=remove_datadir)