You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2016/07/19 14:59:29 UTC

[2/3] cassandra git commit: Attempt to fix flaky CommitLogTest

Attempt to fix flaky CommitLogTest

Patch by jmckenzie; reviewed by slebresne for CASSANDRA-12206


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

Branch: refs/heads/trunk
Commit: 8049bc8869939a0b083377cf4c38f1274e9e1f3a
Parents: d4ced24
Author: Josh McKenzie <jm...@apache.org>
Authored: Fri Jul 15 12:40:39 2016 -0400
Committer: Josh McKenzie <jm...@apache.org>
Committed: Tue Jul 19 10:58:38 2016 -0400

----------------------------------------------------------------------
 .../cassandra/db/commitlog/CommitLogTest.java   | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8049bc88/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 eff972d..23ec58b 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
@@ -35,6 +35,7 @@ import org.junit.runners.Parameterized.Parameters;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.ParameterizedClass;
 import org.apache.cassandra.db.ColumnFamilyStore;
@@ -608,7 +609,7 @@ public class CommitLogTest
 
         CommitLog.instance.sync(true);
 
-        SimpleCountingReplayer replayer = new SimpleCountingReplayer(CommitLog.instance, CommitLogPosition.NONE);
+        SimpleCountingReplayer replayer = new SimpleCountingReplayer(CommitLog.instance, CommitLogPosition.NONE, cfs.metadata);
         List<String> activeSegments = CommitLog.instance.getActiveSegmentNames();
         Assert.assertFalse(activeSegments.isEmpty());
 
@@ -645,7 +646,7 @@ public class CommitLogTest
 
         CommitLog.instance.sync(true);
 
-        SimpleCountingReplayer replayer = new SimpleCountingReplayer(CommitLog.instance, commitLogPosition);
+        SimpleCountingReplayer replayer = new SimpleCountingReplayer(CommitLog.instance, commitLogPosition, cfs.metadata);
         List<String> activeSegments = CommitLog.instance.getActiveSegmentNames();
         Assert.assertFalse(activeSegments.isEmpty());
 
@@ -658,15 +659,15 @@ public class CommitLogTest
     class SimpleCountingReplayer extends CommitLogReplayer
     {
         private final CommitLogPosition filterPosition;
-        private CommitLogReader reader;
+        private final CFMetaData metadata;
         int cells;
         int skipped;
 
-        SimpleCountingReplayer(CommitLog commitLog, CommitLogPosition filterPosition)
+        SimpleCountingReplayer(CommitLog commitLog, CommitLogPosition filterPosition, CFMetaData cfm)
         {
             super(commitLog, filterPosition, Collections.emptyMap(), ReplayFilter.create());
             this.filterPosition = filterPosition;
-            this.reader = new CommitLogReader();
+            this.metadata = cfm;
         }
 
         @SuppressWarnings("resource")
@@ -680,8 +681,15 @@ public class CommitLogTest
                 return;
             }
             for (PartitionUpdate partitionUpdate : m.getPartitionUpdates())
-                for (Row row : partitionUpdate)
-                    cells += Iterables.size(row.cells());
+            {
+                // Only process mutations for the CF's we're testing against, since we can't deterministically predict
+                // whether or not system keyspaces will be mutated during a test.
+                if (partitionUpdate.metadata().cfName.equals(metadata.cfName))
+                {
+                    for (Row row : partitionUpdate)
+                        cells += Iterables.size(row.cells());
+                }
+            }
         }
     }
 }