From 83ff993e957013776f50efd25f05f1d22304417b Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sat, 17 Aug 2019 12:05:33 +0530 Subject: [PATCH] qa/vstart_runner.py: add an option to teardown cluster Add "--teardown" option so that vstart_runner.py tears down Ceph cluster automatically after the batch of tests has completed running. Also delete build/dev and build/out directories, after running stop.sh. Update the doc for vstart_runner.py as well. Signed-off-by: Rishabh Dave --- doc/dev/developer_guide/index.rst | 2 ++ qa/tasks/vstart_runner.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/dev/developer_guide/index.rst b/doc/dev/developer_guide/index.rst index c113b3e7956..e799801873c 100644 --- a/doc/dev/developer_guide/index.rst +++ b/doc/dev/developer_guide/index.rst @@ -1636,6 +1636,8 @@ vstart_runner.py can take 3 options - --create-cluster-only creates the cluster and quits; tests can be issued later --interactive drops a Python shell when a test fails +--teardown tears Ceph cluster down after test(s) has finished + runnng Internal working of vstart_runner.py - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index d0b5f6f8aca..b2979e43d6a 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -987,12 +987,18 @@ class LocalContext(object): def __del__(self): shutil.rmtree(self.teuthology_config['test_path']) +def _teardown_cluster(): + log.info('\ntearing down the cluster...') + remote.run(args = [os.path.join(SRC_PREFIX, "stop.sh")]) + remote.run(args = ['rm', '-rf', './dev', './out']) + def exec_test(): # Parse arguments interactive_on_error = False create_cluster = False create_cluster_only = False ignore_missing_binaries = False + teardown_cluster = False args = sys.argv[1:] flags = [a for a in args if a.startswith("-")] @@ -1006,6 +1012,8 @@ def exec_test(): create_cluster_only = True elif f == "--ignore-missing-binaries": ignore_missing_binaries = True + elif f == '--teardown': + teardown_cluster = True else: log.error("Unknown option '{0}'".format(f)) sys.exit(-1) @@ -1022,6 +1030,7 @@ def exec_test(): max_required_mds, max_required_clients, \ max_required_mgr, require_memstore = scan_tests(modules) + global remote remote = LocalRemote() # Tolerate no MDSs or clients running at start @@ -1039,9 +1048,7 @@ def exec_test(): if create_cluster or create_cluster_only: log.info("Creating cluster with {0} MDS daemons".format( max_required_mds)) - remote.run([os.path.join(SRC_PREFIX, "stop.sh")], check_status=False) - remote.run(["rm", "-rf", "./out"]) - remote.run(["rm", "-rf", "./dev"]) + _teardown_cluster() vstart_env = os.environ.copy() vstart_env["FS"] = "0" vstart_env["MDS"] = max_required_mds.__str__() @@ -1211,6 +1218,9 @@ def exec_test(): verbosity=2, failfast=True).run(overall_suite) + if teardown_cluster: + _teardown_cluster() + if not result.wasSuccessful(): result.printErrors() # duplicate output at end for convenience -- 2.39.5