Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Clean tmp and TestLogs after test runs #915

Merged
merged 10 commits into from
Mar 31, 2023
2 changes: 2 additions & 0 deletions tests/TestHarness/WalletMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,5 @@ def cleanup():
dataDir=WalletMgr.__walletDataDir
if os.path.isdir(dataDir) and os.path.exists(dataDir):
shutil.rmtree(WalletMgr.__walletDataDir)
os.remove(WalletMgr.__walletLogOutFile)
os.remove(WalletMgr.__walletLogErrFile)
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions tests/auto_bp_peering_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def neigbors_in_schedule(name, schedule):
testSuccessful = (connection_check_failures == 0)

finally:
killAll=True
killWallet=True
killEosInstances=True
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved
TestHelper.shutdown(
cluster,
walletMgr,
Expand Down
4 changes: 2 additions & 2 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import shutil
import signal

from TestHarness import Account, Cluster, Node, ReturnType, Utils, WalletMgr
from TestHarness import Account, Node, ReturnType, Utils, WalletMgr

testSuccessful=False

Expand Down Expand Up @@ -403,7 +403,7 @@ def abi_file_with_nodeos_test():
os.kill(node.pid, signal.SIGKILL)
if testSuccessful:
Utils.Print("Cleanup nodeos data.")
shutil.rmtree(data_dir)
shutil.rmtree(Utils.DataPath)

if malicious_token_abi_path:
if os.path.exists(malicious_token_abi_path):
Expand Down
2 changes: 1 addition & 1 deletion tests/nodeos_contrl_c_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
errorExit("Failed to kill the seed node")

finally:
TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=True, cleanRun=True, dumpErrorDetails=True)
TestHelper.shutdown(cluster, walletMgr, testSuccessful=testSuccessful, killEosInstances=True, killWallet=True, keepLogs=False, cleanRun=True, dumpErrorDetails=True)

errorCode = 0 if testSuccessful else 1
exit(errorCode)
16 changes: 8 additions & 8 deletions tests/performance_tests/performance_test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,14 @@ def runTest(self) -> bool:

finally:
TestHelper.shutdown(
self.cluster,
self.walletMgr,
testSuccessful,
self.testHelperConfig._killEosInstances,
self.testHelperConfig._killWallet,
self.testHelperConfig.keepLogs,
self.testHelperConfig.killAll,
self.testHelperConfig.dumpErrorDetails
cluster=self.cluster,
walletMgr=self.walletMgr,
testSuccessful=testSuccessful,
killEosInstances=self.testHelperConfig._killEosInstances,
killWallet=self.testHelperConfig._killWallet,
keepLogs=not testSuccessful,
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved
cleanRun=self.testHelperConfig.killAll,
dumpErrorDetails=self.testHelperConfig.dumpErrorDetails
)

if self.ptbConfig.delPerfLogs:
Expand Down
4 changes: 2 additions & 2 deletions tests/plugin_http_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def cleanEnv(self) :
self.keosd.killall(True)
WalletMgr.cleanup()
Node.killAllNodeos()
if os.path.exists(self.data_dir):
shutil.rmtree(self.data_dir)
if os.path.exists(Utils.DataPath):
shutil.rmtree(Utils.DataPath)
if os.path.exists(self.config_dir):
shutil.rmtree(self.config_dir)
time.sleep(self.sleep_s)
Expand Down
6 changes: 5 additions & 1 deletion tests/trace_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from TestHarness import Cluster, Node, TestHelper, Utils, WalletMgr, CORE_SYMBOL

testSuccessful = True

class TraceApiPluginTest(unittest.TestCase):
sleep_s = 1
cluster=Cluster(walletd=True, defproduceraPrvtKey=None)
Expand Down Expand Up @@ -101,6 +103,8 @@ def test_TraceApi(self) :
self.assertIn('memo', prms)
break
self.assertTrue(isTrxInBlockFromTraceApi)
global testSuccessful
testSuccessful = True

@classmethod
def setUpClass(self):
Expand All @@ -109,7 +113,7 @@ def setUpClass(self):

@classmethod
def tearDownClass(self):
self.cleanEnv(self, shouldCleanup=False) # not cleanup to save log in case for further investigation
self.cleanEnv(self, shouldCleanup=testSuccessful)

if __name__ == "__main__":
unittest.main()
15 changes: 0 additions & 15 deletions unittests/restart_chain_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,4 @@ BOOST_AUTO_TEST_CASE(test_light_validation_restart_from_block_log) {
BOOST_CHECK_EQUAL(trace->action_traces.at(1).receipt->digest(), other_trace->action_traces.at(1).receipt->digest());
}

namespace{
struct scoped_temp_path {
boost::filesystem::path path;
scoped_temp_path() {
path = boost::filesystem::unique_path();
if (boost::unit_test::framework::master_test_suite().argc >= 2) {
path += boost::unit_test::framework::master_test_suite().argv[1];
}
}
~scoped_temp_path() {
boost::filesystem::remove_all(path);
}
};
}

BOOST_AUTO_TEST_SUITE_END()
7 changes: 4 additions & 3 deletions unittests/snapshot_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_compatible_versions, SNAPSHOT_SUITE, snapshot
bfs::copy_file(source_i, source_log_dir / "blocks.index", bfs::copy_option::overwrite_if_exists);
chain.close();
}

auto config = tester::default_config(fc::temp_directory(), legacy_default_max_inline_action_size).first;
fc::temp_directory temp_dir;
auto config = tester::default_config(temp_dir, legacy_default_max_inline_action_size).first;
auto genesis = eosio::chain::block_log::extract_genesis_state(source_log_dir);
bfs::create_directories(config.blocks_dir);
bfs::copy(source_log_dir / "blocks.log", config.blocks_dir / "blocks.log");
Expand Down Expand Up @@ -477,7 +477,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_pending_schedule_snapshot, SNAPSHOT_SUITE, sn
source_log_dir_str += "prod_sched";
const auto source_log_dir = bfs::path(source_log_dir_str.c_str());
const uint32_t legacy_default_max_inline_action_size = 4 * 1024;
auto config = tester::default_config(fc::temp_directory(), legacy_default_max_inline_action_size).first;
fc::temp_directory temp_dir;
auto config = tester::default_config(temp_dir, legacy_default_max_inline_action_size).first;
auto genesis = eosio::chain::block_log::extract_genesis_state(source_log_dir);
bfs::create_directories(config.blocks_dir);
bfs::copy(source_log_dir / "blocks.log", config.blocks_dir / "blocks.log");
Expand Down