You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by di...@apache.org on 2016/11/14 21:52:25 UTC

[2/3] cassandra git commit: Add the range limit for the split ratio in PartitionerTestCase.

Add the range limit for the split ratio in PartitionerTestCase.

Patch by Dikang Gu; Reviewed by Branimir Lambov for CASSANDRA-12858


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

Branch: refs/heads/trunk
Commit: 4fd05e5b5caa8403a1e3ba1318d5eed817c24ba9
Parents: 2f3e07a
Author: Dikang Gu <di...@gmail.com>
Authored: Tue Nov 8 14:06:12 2016 -0800
Committer: Dikang Gu <di...@gmail.com>
Committed: Mon Nov 14 13:04:05 2016 -0800

----------------------------------------------------------------------
 CHANGES.txt                                      |  9 +++------
 .../dht/ByteOrderedPartitionerTest.java          |  5 +++++
 .../cassandra/dht/Murmur3PartitionerTest.java    |  5 +++++
 .../dht/OrderPreservingPartitionerTest.java      |  5 +++++
 .../cassandra/dht/PartitionerTestCase.java       | 19 +++++++++++++++----
 .../cassandra/dht/RandomPartitionerTest.java     |  5 +++++
 6 files changed, 38 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a8ef42c..78d6325 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,10 +1,6 @@
-3.11
- * Move cqlsh syntax rules into separate module and allow easier customization (CASSANDRA-12897)
-Merged from 3.0:
- * Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535)
-
-
 3.10
+ * Fix Murmur3PartitionerTest (CASSANDRA-12858)
+ * Move cqlsh syntax rules into separate module and allow easier customization (CASSANDRA-12897)
  * Fix CommitLogSegmentManagerTest (CASSANDRA-12283)
  * Fix cassandra-stress truncate option (CASSANDRA-12695)
  * Fix crossNode value when receiving messages (CASSANDRA-12791)
@@ -107,6 +103,7 @@ Merged from 3.0:
  * Restore resumable hints delivery (CASSANDRA-11960)
  * Properly report LWT contention (CASSANDRA-12626)
 Merged from 3.0:
+ * Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535)
  * Pass root cause to CorruptBlockException when uncompression failed (CASSANDRA-12889)
  * Batch with multiple conditional updates for the same partition causes AssertionError (CASSANDRA-12867)
  * Make AbstractReplicationStrategy extendable from outside its package (CASSANDRA-12788)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java b/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
index c4896a3..f40c284 100644
--- a/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
@@ -23,4 +23,9 @@ public class ByteOrderedPartitionerTest extends PartitionerTestCase
     {
         partitioner = ByteOrderedPartitioner.instance;
     }
+
+    protected boolean shouldStopRecursion(Token left, Token right)
+    {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java b/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
index ad81f7f..83f3dda 100644
--- a/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
@@ -37,6 +37,11 @@ public class Murmur3PartitionerTest extends PartitionerTestCase
         assertMidpoint(tok("a"), mintoken, 16);
     }
 
+    protected boolean shouldStopRecursion(Token left, Token right)
+    {
+        return left.size(right) < Math.scalb(1, -48);
+    }
+
     @Test
     public void testSplit()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java b/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
index 57f33e7..6ab5b45 100644
--- a/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
@@ -39,6 +39,11 @@ public class OrderPreservingPartitionerTest extends PartitionerTestCase
         partitioner = OrderPreservingPartitioner.instance;
     }
 
+    protected boolean shouldStopRecursion(Token left, Token right)
+    {
+        return false;
+    }
+
     @Test
     public void testCompare()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java b/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
index c411695..33e9d60 100644
--- a/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
+++ b/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
@@ -36,6 +36,9 @@ import static org.junit.Assert.fail;
 
 public abstract class PartitionerTestCase
 {
+    private static final double SPLIT_RATIO_MIN = 0.10;
+    private static final double SPLIT_RATIO_MAX = 1 - SPLIT_RATIO_MIN;
+
     protected IPartitioner partitioner;
 
     public abstract void initPartitioner();
@@ -130,17 +133,25 @@ public abstract class PartitionerTestCase
         }
     }
 
+    protected abstract boolean shouldStopRecursion(Token left, Token right);
+
     private void assertSplit(Token left, Token right, Random rand, int depth)
     {
-        double ratio = rand.nextDouble();
-        Token newToken = partitioner.split(left, right, ratio);
+        if (shouldStopRecursion(left, right))
+        {
+            System.out.println("Stop assertSplit at depth: " + depth);
+            return;
+        }
 
-        assert new Range<Token>(left, right).contains(newToken)
-                : "For " + left + "," + right + ": range did not contain new token:" + newToken;
+        double ratio = SPLIT_RATIO_MIN + (SPLIT_RATIO_MAX - SPLIT_RATIO_MIN) * rand.nextDouble();
+        Token newToken = partitioner.split(left, right, ratio);
 
         assertEquals("For " + left + "," + right + ", new token: " + newToken,
                      ratio, left.size(newToken) / left.size(right), 0.1);
 
+        assert new Range<Token>(left, right).contains(newToken)
+            : "For " + left + "," + right + ": range did not contain new token:" + newToken;
+
         if (depth < 1)
             return;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4fd05e5b/test/unit/org/apache/cassandra/dht/RandomPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/RandomPartitionerTest.java b/test/unit/org/apache/cassandra/dht/RandomPartitionerTest.java
index d7fe602..273fe21 100644
--- a/test/unit/org/apache/cassandra/dht/RandomPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/RandomPartitionerTest.java
@@ -29,6 +29,11 @@ public class RandomPartitionerTest extends PartitionerTestCase
         partitioner = RandomPartitioner.instance;
     }
 
+    protected boolean shouldStopRecursion(Token left, Token right)
+    {
+        return left.size(right) < Math.scalb(1, -112);
+    }
+
     @Test
     public void testSplit()
     {