You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2020/08/24 14:44:13 UTC

[cassandra-dtest] branch master updated: Add "--keep-failed-test-dir" option that only keeps the ccm test directory for failed tests

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git


The following commit(s) were added to refs/heads/master by this push:
     new cefddf8  Add "--keep-failed-test-dir" option that only keeps the ccm test directory for failed tests
cefddf8 is described below

commit cefddf845d63919c6e7b5efa35b28fe7a5ad1142
Author: Mick Semb Wever <mc...@apache.org>
AuthorDate: Sun Aug 23 23:26:31 2020 +0200

    Add "--keep-failed-test-dir" option that only keeps the ccm test directory for failed tests
    
     patch by Mick Semb Wever; reviewed by Brandon Williams
---
 conftest.py     | 12 +++++++++++-
 dtest_config.py |  2 ++
 dtest_setup.py  |  4 ++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/conftest.py b/conftest.py
index 1fa5e22..25cc791 100644
--- a/conftest.py
+++ b/conftest.py
@@ -81,6 +81,9 @@ def pytest_addoption(parser):
     parser.addoption("--keep-test-dir", action="store_true", default=False,
                      help="Do not remove/cleanup the test ccm cluster directory and it's artifacts "
                           "after the test completes")
+    parser.addoption("--keep-failed-test-dir", action="store_true", default=False,
+                     help="Do not remove/cleanup the test ccm cluster directory and it's artifacts "
+                          "after the test fails")
     parser.addoption("--enable-jacoco-code-coverage", action="store_true", default=False,
                      help="Enable JaCoCo Code Coverage Support")
     parser.addoption("--upgrade-version-selection", action="store", default="indev",
@@ -285,6 +288,13 @@ def fixture_dtest_create_cluster_func():
     """
     return DTestSetup.create_ccm_cluster
 
+@pytest.hookimpl(hookwrapper=True, tryfirst=True)
+def pytest_runtest_makereport(item, call):
+    outcome = yield
+    rep = outcome.get_result()
+    setattr(item, "rep_" + rep.when, rep)
+    return rep
+
 @pytest.fixture(scope='function', autouse=False)
 def fixture_dtest_setup(request,
                         dtest_config,
@@ -336,7 +346,7 @@ def fixture_dtest_setup(request,
         except Exception as e:
             logger.error("Error saving log:", str(e))
         finally:
-            dtest_setup.cleanup_cluster()
+            dtest_setup.cleanup_cluster(request)
 
 
 #Based on https://bugs.python.org/file25808/14894.patch
diff --git a/dtest_config.py b/dtest_config.py
index 25e9550..bb5ce8c 100644
--- a/dtest_config.py
+++ b/dtest_config.py
@@ -20,6 +20,7 @@ class DTestConfig:
         self.execute_upgrade_tests_only = False
         self.disable_active_log_watching = False
         self.keep_test_dir = False
+        self.keep_failed_test_dir = False
         self.enable_jacoco_code_coverage = False
         self.jemalloc_path = find_libjemalloc()
 
@@ -42,6 +43,7 @@ class DTestConfig:
         self.execute_upgrade_tests_only = request.config.getoption("--execute-upgrade-tests-only")
         self.disable_active_log_watching = request.config.getoption("--disable-active-log-watching")
         self.keep_test_dir = request.config.getoption("--keep-test-dir")
+        self.keep_failed_test_dir = request.config.getoption("--keep-failed-test-dir")
         self.enable_jacoco_code_coverage = request.config.getoption("--enable-jacoco-code-coverage")
 
     def get_version_from_build(self):
diff --git a/dtest_setup.py b/dtest_setup.py
index abc50b5..646bc23 100644
--- a/dtest_setup.py
+++ b/dtest_setup.py
@@ -347,9 +347,9 @@ class DTestSetup(object):
         """
         self.log_watch_thread.join(timeout=60)
 
-    def cleanup_cluster(self):
+    def cleanup_cluster(self, request):
         with log_filter('cassandra'):  # quiet noise from driver when nodes start going down
-            if self.dtest_config.keep_test_dir:
+            if self.dtest_config.keep_test_dir or (self.dtest_config.keep_failed_test_dir and request.node.rep_call.failed):
                 self.cluster.stop(gently=self.dtest_config.enable_jacoco_code_coverage)
             else:
                 # when recording coverage the jvm has to exit normally


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org