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/10/14 14:56:20 UTC

[cassandra-dtest] branch master updated: Add test_truncate_failure

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 8cb6bd2  Add test_truncate_failure
8cb6bd2 is described below

commit 8cb6bd23e62c4d3b4e208d3909361d6812182bc6
Author: Ekaterina Dimitrova <ek...@datastax.com>
AuthorDate: Thu Oct 8 09:23:00 2020 -0400

    Add test_truncate_failure
    
    Patch by Ekaterina Dimitrova, reviewed by brandonwilliams for
    CASSANDRA-16208
---
 byteman/truncate_fail.btm |  8 ++++++++
 cql_test.py               | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/byteman/truncate_fail.btm b/byteman/truncate_fail.btm
new file mode 100644
index 0000000..fa9caba
--- /dev/null
+++ b/byteman/truncate_fail.btm
@@ -0,0 +1,8 @@
+RULE Throw during truncate operation
+CLASS org.apache.cassandra.db.ColumnFamilyStore
+METHOD truncateBlocking()
+AT ENTRY
+IF TRUE
+DO
+   throw new RuntimeException("Dummy failure");
+ENDRULE
\ No newline at end of file
diff --git a/cql_test.py b/cql_test.py
index eced21d..dde7b7d 100644
--- a/cql_test.py
+++ b/cql_test.py
@@ -1,4 +1,5 @@
 import itertools
+import re
 import struct
 import time
 import pytest
@@ -764,6 +765,38 @@ class TestMiscellaneousCQL(CQLTester):
                         [2, None, 2, None],
                         [3, None, 3, None]])
 
+    @since("4.0")
+    def test_truncate_failure(self):
+        """
+        @jira_ticket CASSANDRA-16208
+        Tests that if a TRUNCATE query fails on some replica, the coordinator will immediately return an error to the
+        client instead of waiting to time out because it couldn't get the necessary number of success acks.
+        """
+        cluster = self.cluster
+        cluster.populate(3, install_byteman=True).start()
+        node1, _, node3 = cluster.nodelist()
+        node3.byteman_submit(['./byteman/truncate_fail.btm'])
+
+        session = self.patient_exclusive_cql_connection(node1)
+        create_ks(session, 'ks', 3)
+
+        logger.debug("Creating data table")
+        session.execute("CREATE TABLE data (id int PRIMARY KEY, data text)")
+        session.execute("UPDATE data SET data = 'Awesome' WHERE id = 1")
+
+        self.fixture_dtest_setup.ignore_log_patterns = ['Dummy failure']
+        logger.debug("Truncating data table (error expected)")
+
+        thrown = False
+        exception = None
+        try:
+            session.execute("TRUNCATE data")
+        except Exception as e:
+            exception = e
+            thrown = True
+
+        assert thrown, "No exception has been thrown"
+        assert re.search("Truncate failed on replica /127.0.0.3", str(exception)) is not None
 
 @since('3.2')
 class AbortedQueryTester(CQLTester):


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