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

jlewandowski pushed a commit to branch ds-trunk-5.0--2024-07-24
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git

commit 499af0a0b06488e082334f643e9e80613b27937c
Author: dan jatnieks <jatni...@pobox.com>
AuthorDate: Fri Jul 2 13:49:24 2021 -0700

    STAR-385 Retry cluster stop after exception stopping 'gently' (#36)
    
    Cluster stop requests in cleanup_cluster are made with "gently=True" when 
Jacoco code coverage is enabled to allow the jacoco agent to record results; 
however, some tests leave nodes in a state where this type of shutdown does not 
succeed, resulting in the test being marked failed regardless of it's true 
completion status.
    
    This change will retry these stop requests with "gently=False" so that the 
test completion status will not be altered due to shutdown not completing.
    
    (cherry picked from commit f6fc3d39cb448eb886734a5a6ec692a557c07bc3)
    (cherry picked from commit aff9d6e81b856671b4ef6e9c2f488c729b8a6427)
    (cherry picked from commit fe272305d58c11616e1fdb901af1b338b3daceaf)
    (cherry picked from commit f931d4385d1dba79913950cbdbedf17a488fc379)
    (cherry picked from commit 88c022c1cb1b967674d89d60b2456ccc4e45a392)
    (cherry picked from commit 56b468096bba12087c50426021d23160476c7933)
---
 dtest_setup.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/dtest_setup.py b/dtest_setup.py
index 863e7648..2aa7b0f4 100644
--- a/dtest_setup.py
+++ b/dtest_setup.py
@@ -17,7 +17,7 @@ from cassandra.cluster import NoHostAvailable
 from cassandra.cluster import EXEC_PROFILE_DEFAULT
 from cassandra.policies import WhiteListRoundRobinPolicy
 from ccmlib.common import is_win
-from ccmlib.cluster import Cluster
+from ccmlib.cluster import Cluster, NodeError
 
 from dtest import (get_ip_from_node, make_execution_profile, 
get_auth_provider, get_port_from_node,
                    get_eager_protocol_version, hack_legacy_parsing)
@@ -394,17 +394,35 @@ class DTestSetup(object):
         """
         self.log_watch_thread.join(timeout=60)
 
+    def stop_cluster(self, gently=False):
+        """
+        Stops the cluster; if 'gently' is requested and a NodeError occurs, 
then
+        try again without 'gently'.
+
+        Some tests, by design, leave the cluster in a state which prevents it 
from
+        being stopped using 'gently'. Retrying without 'gently' will avoid 
marking
+        the test as a failure, but may prevent jacoco results from being 
recorded.
+        """
+        try:
+            self.cluster.stop(gently)
+        except NodeError as e:
+            if gently:
+                logger.debug("Exception stopping cluster with gently=True, 
retrying with gently=False: {0}".format(e))
+                self.cluster.stop(gently=False)
+            else:
+                raise e
+
     def cleanup_cluster(self, request=None, failure=False):
         with log_filter('cassandra'):  # quiet noise from driver when nodes 
start going down
             test_failed = (request and hasattr(request.node, 'rep_call') and 
request.node.rep_call.failed) or failure
             if self.dtest_config.keep_test_dir or 
(self.dtest_config.keep_failed_test_dir and test_failed):
-                
self.cluster.stop(gently=self.dtest_config.enable_jacoco_code_coverage)
+                
self.stop_cluster(gently=self.dtest_config.enable_jacoco_code_coverage)
             else:
                 # when recording coverage the jvm has to exit normally
                 # or the coverage information is not written by the jacoco 
agent
                 # otherwise we can just kill the process
                 if self.dtest_config.enable_jacoco_code_coverage:
-                    self.cluster.stop(gently=True)
+                    self.stop_cluster(gently=True)
 
                 # Cleanup everything:
                 try:


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

Reply via email to