Fix CommitLogTest.testDeleteIfNotDirty

patch by Stefania Alborghetti; reviewed by Branimir Lambov for CASSANDRA-12854


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ec64cdf4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ec64cdf4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ec64cdf4

Branch: refs/heads/cassandra-3.X
Commit: ec64cdf4c6b731a00bea8795247d865d6371157f
Parents: 817ba03
Author: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Authored: Fri Oct 28 17:25:15 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Committed: Mon Nov 7 10:30:15 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 src/java/org/apache/cassandra/schema/KeyspaceParams.java | 11 ++++++++++-
 .../org/apache/cassandra/db/commitlog/CommitLogTest.java |  5 +++++
 3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ec64cdf4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c80e045..51d571b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.10
+ * Fix CommitLogTest.testDeleteIfNotDirty (CASSANDRA-12854)
  * Avoid deadlock due to materialized view lock contention (CASSANDRA-12689)
  * Fix for KeyCacheCqlTest flakiness (CASSANDRA-12801)
  * Include SSTable filename in compacting large row message (CASSANDRA-12384)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ec64cdf4/src/java/org/apache/cassandra/schema/KeyspaceParams.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/KeyspaceParams.java 
b/src/java/org/apache/cassandra/schema/KeyspaceParams.java
index c0e8916..2ea18ca 100644
--- a/src/java/org/apache/cassandra/schema/KeyspaceParams.java
+++ b/src/java/org/apache/cassandra/schema/KeyspaceParams.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.schema;
 
 import java.util.Map;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
 
 /**
@@ -28,6 +29,14 @@ public final class KeyspaceParams
 {
     public static final boolean DEFAULT_DURABLE_WRITES = true;
 
+    /**
+     * This determines durable writes for the {@link 
org.apache.cassandra.db.SystemKeyspace#NAME}
+     * and {@link SchemaKeyspace#NAME} keyspaces, the only reason it is not 
final is for commitlog
+     * unit tests. It should only be changed for testing purposes.
+     */
+    @VisibleForTesting
+    public static boolean DEFAULT_LOCAL_DURABLE_WRITES = true;
+
     public enum Option
     {
         DURABLE_WRITES,
@@ -56,7 +65,7 @@ public final class KeyspaceParams
 
     public static KeyspaceParams local()
     {
-        return new KeyspaceParams(true, ReplicationParams.local());
+        return new KeyspaceParams(DEFAULT_LOCAL_DURABLE_WRITES, 
ReplicationParams.local());
     }
 
     public static KeyspaceParams simple(int replicationFactor)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ec64cdf4/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java 
b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
index 9a0ddb8..c4ab6ab 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
@@ -97,6 +97,11 @@ public class CommitLogTest
     @BeforeClass
     public static void defineSchema() throws ConfigurationException
     {
+        // Disable durable writes for system keyspaces to prevent system 
mutations, e.g. sstable_activity,
+        // to end up in CL segments and cause unexpected results in this test 
wrt counting CL segments,
+        // see CASSANDRA-12854
+        KeyspaceParams.DEFAULT_LOCAL_DURABLE_WRITES = false;
+
         SchemaLoader.prepareServer();
         SchemaLoader.createKeyspace(KEYSPACE1,
                                     KeyspaceParams.simple(1),

Reply via email to