You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/01/13 21:18:02 UTC

[cassandra-dtest] branch master updated: Add new bootstrap test for race condition

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

brandonwilliams 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 fc5576e  Add new bootstrap test for race condition
fc5576e is described below

commit fc5576e2804bc7cecd80058b6880d2fbeb026245
Author: Ekaterina Dimitrova <ek...@datastax.com>
AuthorDate: Mon Dec 9 11:38:40 2019 -0500

    Add new bootstrap test for race condition
    
    Patch by Ekaterina Dimitrova, reviewed by brandonwilliams for CASSANDRA-14878
---
 bootstrap_test.py              | 28 +++++++++++++++++++++++++++-
 byteman/bootstrap_5s_sleep.btm | 13 +++++++++++++
 tools/misc.py                  |  5 +++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/bootstrap_test.py b/bootstrap_test.py
index 70d54a3..9a7567f 100644
--- a/bootstrap_test.py
+++ b/bootstrap_test.py
@@ -239,6 +239,32 @@ class TestBootstrap(Tester):
         new_rows = list(session.execute("SELECT * FROM %s" % (stress_table,)))
         assert original_rows == new_rows
 
+    @since('3.0')
+    def test_bootstrap_waits_for_streaming_to_finish(self):
+             """
+             Test that bootstrap completes and is marked as such after streaming finishes.
+             """
+
+             cluster = self.cluster
+
+             logger.debug("Create a cluster")
+             cluster.populate(1)
+             node1 = cluster.nodelist()[0]
+
+             logger.debug("Start node 1")
+             node1.start(wait_for_binary_proto=True, wait_other_notice=True)
+
+             logger.debug("Insert 10k rows")
+             node1.stress(['write', 'n=10K', 'no-warmup', '-rate', 'threads=8', '-schema', 'replication(factor=2)'])
+
+             logger.debug("Bootstrap node 2 with delay")
+             node2 = new_node(cluster, byteman_port='4200')
+             node2.update_startup_byteman_script('./byteman/bootstrap_5s_sleep.btm')
+             node2.start(wait_for_binary_proto=True, wait_other_notice=True)
+
+             assert_bootstrap_state(self, node2, 'COMPLETED')
+             assert node2.grep_log('Bootstrap completed', filename='debug.log')
+
     def test_consistent_range_movement_true_with_replica_down_should_fail(self):
         self._bootstrap_test_with_replica_down(True)
 
@@ -800,4 +826,4 @@ class TestBootstrap(Tester):
         node3.nodetool('join')
         self.assert_log_had_msg(node3, "Leaving write survey mode and joining ring at operator request", timeout=30)
         assert_bootstrap_state(self, node3, 'COMPLETED', user='cassandra', password='cassandra')
-        node3.wait_for_binary_interface(timeout=30)
\ No newline at end of file
+        node3.wait_for_binary_interface(timeout=30)
diff --git a/byteman/bootstrap_5s_sleep.btm b/byteman/bootstrap_5s_sleep.btm
new file mode 100644
index 0000000..6fa5996
--- /dev/null
+++ b/byteman/bootstrap_5s_sleep.btm
@@ -0,0 +1,13 @@
+#
+ # Sleep 5s when finishing bootstrap
+ #
+ RULE Sleep 5s when finishing bootstrap
+ CLASS org.apache.cassandra.service.StorageService
+ METHOD bootstrapFinished
+ AT ENTRY
+ # set flag to only run this rule once.
+ IF NOT flagged("done")
+ DO
+    flag("done");
+    Thread.sleep(5000)
+ ENDRULE
\ No newline at end of file
diff --git a/tools/misc.py b/tools/misc.py
index a4502f1..542a889 100644
--- a/tools/misc.py
+++ b/tools/misc.py
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
 
 
 # work for cluster started by populate
-def new_node(cluster, bootstrap=True, token=None, remote_debug_port='0', data_center=None):
+def new_node(cluster, bootstrap=True, token=None, remote_debug_port='0', data_center=None, byteman_port='0'):
     i = len(cluster.nodes) + 1
     node = Node('node%s' % i,
                 cluster,
@@ -24,7 +24,8 @@ def new_node(cluster, bootstrap=True, token=None, remote_debug_port='0', data_ce
                 str(7000 + i * 100),
                 remote_debug_port,
                 token,
-                binary_interface=('127.0.0.%s' % i, 9042))
+                binary_interface=('127.0.0.%s' % i, 9042),
+                                 byteman_port=byteman_port)
     cluster.add(node, not bootstrap, data_center=data_center)
     return node
 


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