cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [3/6] git commit: Fix MoveTest. Patch by Liu Yu, reviewed by brandonwilliams for CASSANDRA-4564
Date Fri, 04 Jan 2013 13:39:37 GMT
Fix MoveTest.
Patch by Liu Yu, reviewed by brandonwilliams for CASSANDRA-4564


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

Branch: refs/heads/trunk
Commit: e1206f3b8793b4dfa5b34815c4bf921da35e218a
Parents: 49cb690
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Fri Jan 4 07:38:43 2013 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Fri Jan 4 07:38:43 2013 -0600

----------------------------------------------------------------------
 .../org/apache/cassandra/service/MoveTest.java     |  147 ++++++++-------
 1 files changed, 76 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e1206f3b/test/unit/org/apache/cassandra/service/MoveTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/MoveTest.java b/test/unit/org/apache/cassandra/service/MoveTest.java
index cbdad15..1a33d7f 100644
--- a/test/unit/org/apache/cassandra/service/MoveTest.java
+++ b/test/unit/org/apache/cassandra/service/MoveTest.java
@@ -90,18 +90,15 @@ public class MoveTest
         Util.createInitialRing(ss, partitioner, endpointTokens, keyTokens, hosts, RING_SIZE);
 
         Map<Token, List<InetAddress>> expectedEndpoints = new HashMap<Token,
List<InetAddress>>();
-        for (String table : Schema.instance.getNonSystemTables())
+        for (Token token : keyTokens)
         {
-            for (Token token : keyTokens)
+            List<InetAddress> endpoints = new ArrayList<InetAddress>();
+            Iterator<Token> tokenIter = TokenMetadata.ringIterator(tmd.sortedTokens(),
token, false);
+            while (tokenIter.hasNext())
             {
-                List<InetAddress> endpoints = new ArrayList<InetAddress>();
-                Iterator<Token> tokenIter = TokenMetadata.ringIterator(tmd.sortedTokens(),
token, false);
-                while (tokenIter.hasNext())
-                {
-                    endpoints.add(tmd.getEndpoint(tokenIter.next()));
-                }
-                expectedEndpoints.put(token, endpoints);
+                endpoints.add(tmd.getEndpoint(tokenIter.next()));
             }
+            expectedEndpoints.put(token, endpoints);
         }
 
         // node LEAVING_NODE should move to this token
@@ -116,6 +113,7 @@ public class MoveTest
         for (String table : Schema.instance.getNonSystemTables())
         {
             strategy = getStrategy(table, tmd);
+            int numMoved = 0;
             for (Token token : keyTokens)
             {
                 int replicationFactor = strategy.getReplicationFactor();
@@ -128,8 +126,15 @@ public class MoveTest
                     expected.add(expectedEndpoints.get(token).get(i));
                 }
 
-                assertEquals("mismatched endpoint sets", expected, actual);
+                if (expected.size() == actual.size()) {
+                	assertEquals("mismatched endpoint sets", expected, actual);
+                } else {
+                	expected.add(hosts.get(MOVING_NODE));
+                	assertEquals("mismatched endpoint sets", expected, actual);
+                	numMoved++;
+                }
             }
+            assertEquals("mismatched number of moved token", numMoved, 1);
         }
 
         // moving endpoint back to the normal state
@@ -191,23 +196,23 @@ public class MoveTest
        /**
         *  Keyspace1 & Keyspace2 RF=1
         *  {
-        *      /127.0.0.1=[(92,0]],
+        *      /127.0.0.1=[(97,0]],
         *      /127.0.0.2=[(0,10]],
         *      /127.0.0.3=[(10,20]],
         *      /127.0.0.4=[(20,30]],
         *      /127.0.0.5=[(30,40]],
         *      /127.0.0.6=[(40,50]],
-        *      /127.0.0.7=[(50,62]],
-        *      /127.0.0.8=[(62,70]],
-        *      /127.0.0.9=[(70,82]],
-        *      /127.0.0.10=[(82,92]]
+        *      /127.0.0.7=[(50,67]],
+        *      /127.0.0.8=[(67,70]],
+        *      /127.0.0.9=[(70,87]],
+        *      /127.0.0.10=[(87,97]]
         *  }
         */
 
         Multimap<InetAddress, Range<Token>> keyspace1ranges = tableStrategyMap.get("Keyspace1").getAddressRanges();
         Collection<Range<Token>> ranges1 = keyspace1ranges.get(InetAddress.getByName("127.0.0.1"));
         assertEquals(collectionSize(ranges1), 1);
-        assertTrue(ranges1.iterator().next().equals(generateRange(92, 0)));
+        assertTrue(ranges1.iterator().next().equals(generateRange(97, 0)));
         Collection<Range<Token>> ranges2 = keyspace1ranges.get(InetAddress.getByName("127.0.0.2"));
         assertEquals(collectionSize(ranges2), 1);
         assertTrue(ranges2.iterator().next().equals(generateRange(0, 10)));
@@ -225,92 +230,92 @@ public class MoveTest
         assertTrue(ranges6.iterator().next().equals(generateRange(40, 50)));
         Collection<Range<Token>> ranges7 = keyspace1ranges.get(InetAddress.getByName("127.0.0.7"));
         assertEquals(collectionSize(ranges7), 1);
-        assertTrue(ranges7.iterator().next().equals(generateRange(50, 62)));
+        assertTrue(ranges7.iterator().next().equals(generateRange(50, 67)));
         Collection<Range<Token>> ranges8 = keyspace1ranges.get(InetAddress.getByName("127.0.0.8"));
         assertEquals(collectionSize(ranges8), 1);
-        assertTrue(ranges8.iterator().next().equals(generateRange(62, 70)));
+        assertTrue(ranges8.iterator().next().equals(generateRange(67, 70)));
         Collection<Range<Token>> ranges9 = keyspace1ranges.get(InetAddress.getByName("127.0.0.9"));
         assertEquals(collectionSize(ranges9), 1);
-        assertTrue(ranges9.iterator().next().equals(generateRange(70, 82)));
+        assertTrue(ranges9.iterator().next().equals(generateRange(70, 87)));
         Collection<Range<Token>> ranges10 = keyspace1ranges.get(InetAddress.getByName("127.0.0.10"));
         assertEquals(collectionSize(ranges10), 1);
-        assertTrue(ranges10.iterator().next().equals(generateRange(82, 92)));
+        assertTrue(ranges10.iterator().next().equals(generateRange(87, 97)));
 
 
         /**
         * Keyspace3 RF=5
         * {
-        *      /127.0.0.1=[(92,0], (70,82], (50,62], (82,92], (62,70]],
-        *      /127.0.0.2=[(92,0], (70,82], (82,92], (0,10], (62,70]],
-        *      /127.0.0.3=[(92,0], (70,82], (82,92], (0,10], (10,20]],
-        *      /127.0.0.4=[(92,0], (20,30], (82,92], (0,10], (10,20]],
-        *      /127.0.0.5=[(92,0], (30,40], (20,30], (0,10], (10,20]],
+        *      /127.0.0.1=[(97,0], (70,87], (50,67], (87,97], (67,70]],
+        *      /127.0.0.2=[(97,0], (70,87], (87,97], (0,10], (67,70]],
+        *      /127.0.0.3=[(97,0], (70,87], (87,97], (0,10], (10,20]],
+        *      /127.0.0.4=[(97,0], (20,30], (87,97], (0,10], (10,20]],
+        *      /127.0.0.5=[(97,0], (30,40], (20,30], (0,10], (10,20]],
         *      /127.0.0.6=[(40,50], (30,40], (20,30], (0,10], (10,20]],
-        *      /127.0.0.7=[(40,50], (30,40], (50,62], (20,30], (10,20]],
-        *      /127.0.0.8=[(40,50], (30,40], (50,62], (20,30], (62,70]],
-        *      /127.0.0.9=[(40,50], (70,82], (30,40], (50,62], (62,70]],
-        *      /127.0.0.10=[(40,50], (70,82], (50,62], (82,92], (62,70]]
+        *      /127.0.0.7=[(40,50], (30,40], (50,67], (20,30], (10,20]],
+        *      /127.0.0.8=[(40,50], (30,40], (50,67], (20,30], (67,70]],
+        *      /127.0.0.9=[(40,50], (70,87], (30,40], (50,67], (67,70]],
+        *      /127.0.0.10=[(40,50], (70,87], (50,67], (87,97], (67,70]]
         * }
         */
 
         Multimap<InetAddress, Range<Token>> keyspace3ranges = tableStrategyMap.get("Keyspace3").getAddressRanges();
         ranges1 = keyspace3ranges.get(InetAddress.getByName("127.0.0.1"));
         assertEquals(collectionSize(ranges1), 5);
-        assertTrue(ranges1.equals(generateRanges(92, 0, 70, 82, 50, 62, 82, 92, 62, 70)));
+        assertTrue(ranges1.equals(generateRanges(97, 0, 70, 87, 50, 67, 87, 97, 67, 70)));
         ranges2 = keyspace3ranges.get(InetAddress.getByName("127.0.0.2"));
         assertEquals(collectionSize(ranges2), 5);
-        assertTrue(ranges2.equals(generateRanges(92, 0, 70, 82, 82, 92, 0, 10, 62, 70)));
+        assertTrue(ranges2.equals(generateRanges(97, 0, 70, 87, 87, 97, 0, 10, 67, 70)));
         ranges3 = keyspace3ranges.get(InetAddress.getByName("127.0.0.3"));
         assertEquals(collectionSize(ranges3), 5);
-        assertTrue(ranges3.equals(generateRanges(92, 0, 70, 82, 82, 92, 0, 10, 10, 20)));
+        assertTrue(ranges3.equals(generateRanges(97, 0, 70, 87, 87, 97, 0, 10, 10, 20)));
         ranges4 = keyspace3ranges.get(InetAddress.getByName("127.0.0.4"));
         assertEquals(collectionSize(ranges4), 5);
-        assertTrue(ranges4.equals(generateRanges(92, 0, 20, 30, 82, 92, 0, 10, 10, 20)));
+        assertTrue(ranges4.equals(generateRanges(97, 0, 20, 30, 87, 97, 0, 10, 10, 20)));
         ranges5 = keyspace3ranges.get(InetAddress.getByName("127.0.0.5"));
         assertEquals(collectionSize(ranges5), 5);
-        assertTrue(ranges5.equals(generateRanges(92, 0, 30, 40, 20, 30, 0, 10, 10, 20)));
+        assertTrue(ranges5.equals(generateRanges(97, 0, 30, 40, 20, 30, 0, 10, 10, 20)));
         ranges6 = keyspace3ranges.get(InetAddress.getByName("127.0.0.6"));
         assertEquals(collectionSize(ranges6), 5);
         assertTrue(ranges6.equals(generateRanges(40, 50, 30, 40, 20, 30, 0, 10, 10, 20)));
         ranges7 = keyspace3ranges.get(InetAddress.getByName("127.0.0.7"));
         assertEquals(collectionSize(ranges7), 5);
-        assertTrue(ranges7.equals(generateRanges(40, 50, 30, 40, 50, 62, 20, 30, 10, 20)));
+        assertTrue(ranges7.equals(generateRanges(40, 50, 30, 40, 50, 67, 20, 30, 10, 20)));
         ranges8 = keyspace3ranges.get(InetAddress.getByName("127.0.0.8"));
         assertEquals(collectionSize(ranges8), 5);
-        assertTrue(ranges8.equals(generateRanges(40, 50, 30, 40, 50, 62, 20, 30, 62, 70)));
+        assertTrue(ranges8.equals(generateRanges(40, 50, 30, 40, 50, 67, 20, 30, 67, 70)));
         ranges9 = keyspace3ranges.get(InetAddress.getByName("127.0.0.9"));
         assertEquals(collectionSize(ranges9), 5);
-        assertTrue(ranges9.equals(generateRanges(40, 50, 70, 82, 30, 40, 50, 62, 62, 70)));
+        assertTrue(ranges9.equals(generateRanges(40, 50, 70, 87, 30, 40, 50, 67, 67, 70)));
         ranges10 = keyspace3ranges.get(InetAddress.getByName("127.0.0.10"));
         assertEquals(collectionSize(ranges10), 5);
-        assertTrue(ranges10.equals(generateRanges(40, 50, 70, 82, 50, 62, 82, 92, 62, 70)));
+        assertTrue(ranges10.equals(generateRanges(40, 50, 70, 87, 50, 67, 87, 97, 67, 70)));
 
 
         /**
          * Keyspace4 RF=3
          * {
-         *      /127.0.0.1=[(92,0], (70,82], (82,92]],
-         *      /127.0.0.2=[(92,0], (82,92], (0,10]],
-         *      /127.0.0.3=[(92,0], (0,10], (10,20]],
+         *      /127.0.0.1=[(97,0], (70,87], (87,97]],
+         *      /127.0.0.2=[(97,0], (87,97], (0,10]],
+         *      /127.0.0.3=[(97,0], (0,10], (10,20]],
          *      /127.0.0.4=[(20,30], (0,10], (10,20]],
          *      /127.0.0.5=[(30,40], (20,30], (10,20]],
          *      /127.0.0.6=[(40,50], (30,40], (20,30]],
-         *      /127.0.0.7=[(40,50], (30,40], (50,62]],
-         *      /127.0.0.8=[(40,50], (50,62], (62,70]],
-         *      /127.0.0.9=[(70,82], (50,62], (62,70]],
-         *      /127.0.0.10=[(70,82], (82,92], (62,70]]
+         *      /127.0.0.7=[(40,50], (30,40], (50,67]],
+         *      /127.0.0.8=[(40,50], (50,67], (67,70]],
+         *      /127.0.0.9=[(70,87], (50,67], (67,70]],
+         *      /127.0.0.10=[(70,87], (87,97], (67,70]]
          *  }
          */
         Multimap<InetAddress, Range<Token>> keyspace4ranges = tableStrategyMap.get("Keyspace4").getAddressRanges();
         ranges1 = keyspace4ranges.get(InetAddress.getByName("127.0.0.1"));
         assertEquals(collectionSize(ranges1), 3);
-        assertTrue(ranges1.equals(generateRanges(92, 0, 70, 82, 82, 92)));
+        assertTrue(ranges1.equals(generateRanges(97, 0, 70, 87, 87, 97)));
         ranges2 = keyspace4ranges.get(InetAddress.getByName("127.0.0.2"));
         assertEquals(collectionSize(ranges2), 3);
-        assertTrue(ranges2.equals(generateRanges(92, 0, 82, 92, 0, 10)));
+        assertTrue(ranges2.equals(generateRanges(97, 0, 87, 97, 0, 10)));
         ranges3 = keyspace4ranges.get(InetAddress.getByName("127.0.0.3"));
         assertEquals(collectionSize(ranges3), 3);
-        assertTrue(ranges3.equals(generateRanges(92, 0, 0, 10, 10, 20)));
+        assertTrue(ranges3.equals(generateRanges(97, 0, 0, 10, 10, 20)));
         ranges4 = keyspace4ranges.get(InetAddress.getByName("127.0.0.4"));
         assertEquals(collectionSize(ranges4), 3);
         assertTrue(ranges4.equals(generateRanges(20, 30, 0, 10, 10, 20)));
@@ -322,16 +327,16 @@ public class MoveTest
         assertTrue(ranges6.equals(generateRanges(40, 50, 30, 40, 20, 30)));
         ranges7 = keyspace4ranges.get(InetAddress.getByName("127.0.0.7"));
         assertEquals(collectionSize(ranges7), 3);
-        assertTrue(ranges7.equals(generateRanges(40, 50, 30, 40, 50, 62)));
+        assertTrue(ranges7.equals(generateRanges(40, 50, 30, 40, 50, 67)));
         ranges8 = keyspace4ranges.get(InetAddress.getByName("127.0.0.8"));
         assertEquals(collectionSize(ranges8), 3);
-        assertTrue(ranges8.equals(generateRanges(40, 50, 50, 62, 62, 70)));
+        assertTrue(ranges8.equals(generateRanges(40, 50, 50, 67, 67, 70)));
         ranges9 = keyspace4ranges.get(InetAddress.getByName("127.0.0.9"));
         assertEquals(collectionSize(ranges9), 3);
-        assertTrue(ranges9.equals(generateRanges(70, 82, 50, 62, 62, 70)));
+        assertTrue(ranges9.equals(generateRanges(70, 87, 50, 67, 67, 70)));
         ranges10 = keyspace4ranges.get(InetAddress.getByName("127.0.0.10"));
         assertEquals(collectionSize(ranges10), 3);
-        assertTrue(ranges10.equals(generateRanges(70, 82, 82, 92, 62, 70)));
+        assertTrue(ranges10.equals(generateRanges(70, 87, 87, 97, 67, 70)));
 
         // pre-calculate the results.
         Map<String, Multimap<Token, InetAddress>> expectedEndpoints = new HashMap<String,
Multimap<Token, InetAddress>>();
@@ -342,10 +347,10 @@ public class MoveTest
         expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("35"), makeAddrs("127.0.0.5"));
         expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("45"), makeAddrs("127.0.0.6"));
         expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("55"), makeAddrs("127.0.0.7",
"127.0.1.1"));
-        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.8"));
+        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.7"));
         expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("75"), makeAddrs("127.0.0.9",
"127.0.1.2"));
-        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.10"));
-        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.1"));
+        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.9"));
+        expectedEndpoints.get("Keyspace1").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.10"));
         expectedEndpoints.put("Keyspace2", HashMultimap.<Token, InetAddress>create());
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("5"), makeAddrs("127.0.0.2"));
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("15"), makeAddrs("127.0.0.3"));
@@ -353,10 +358,10 @@ public class MoveTest
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("35"), makeAddrs("127.0.0.5"));
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("45"), makeAddrs("127.0.0.6"));
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("55"), makeAddrs("127.0.0.7",
"127.0.1.1"));
-        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.8"));
+        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.7"));
         expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("75"), makeAddrs("127.0.0.9",
"127.0.1.2"));
-        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.10"));
-        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.1"));
+        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.9"));
+        expectedEndpoints.get("Keyspace2").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.10"));
         expectedEndpoints.put("Keyspace3", HashMultimap.<Token, InetAddress>create());
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("5"), makeAddrs("127.0.0.2",
"127.0.0.3", "127.0.0.4", "127.0.0.5", "127.0.0.6"));
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("15"), makeAddrs("127.0.0.3",
"127.0.0.4", "127.0.0.5", "127.0.0.6", "127.0.0.7", "127.0.1.1"));
@@ -364,10 +369,10 @@ public class MoveTest
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("35"), makeAddrs("127.0.0.5",
"127.0.0.6", "127.0.0.7", "127.0.0.8", "127.0.0.9", "127.0.1.1", "127.0.1.2"));
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("45"), makeAddrs("127.0.0.6",
"127.0.0.7", "127.0.0.8", "127.0.0.9", "127.0.0.10", "127.0.1.1", "127.0.1.2"));
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("55"), makeAddrs("127.0.0.7",
"127.0.0.8", "127.0.0.9", "127.0.0.10", "127.0.0.1", "127.0.1.1", "127.0.1.2"));
-        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.8",
"127.0.0.9", "127.0.0.10", "127.0.0.1", "127.0.0.2", "127.0.1.2"));
+        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.7",
"127.0.0.8", "127.0.0.9", "127.0.0.10", "127.0.0.1", "127.0.1.2"));
         expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("75"), makeAddrs("127.0.0.9",
"127.0.0.10", "127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.1.2"));
-        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.10",
"127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4"));
-        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.1",
"127.0.0.2", "127.0.0.3", "127.0.0.4", "127.0.0.5"));
+        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.9",
"127.0.0.10", "127.0.0.1", "127.0.0.2", "127.0.0.3"));
+        expectedEndpoints.get("Keyspace3").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.10",
"127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4"));
         expectedEndpoints.put("Keyspace4", HashMultimap.<Token, InetAddress>create());
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("5"), makeAddrs("127.0.0.2",
"127.0.0.3", "127.0.0.4"));
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("15"), makeAddrs("127.0.0.3",
"127.0.0.4", "127.0.0.5"));
@@ -375,10 +380,10 @@ public class MoveTest
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("35"), makeAddrs("127.0.0.5",
"127.0.0.6", "127.0.0.7", "127.0.1.1"));
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("45"), makeAddrs("127.0.0.6",
"127.0.0.7", "127.0.0.8", "127.0.1.1"));
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("55"), makeAddrs("127.0.0.7",
"127.0.0.8", "127.0.0.9", "127.0.1.1", "127.0.1.2"));
-        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.8",
"127.0.0.9", "127.0.0.10", "127.0.1.2"));
+        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("65"), makeAddrs("127.0.0.7",
"127.0.0.8", "127.0.0.9", "127.0.1.2"));
         expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("75"), makeAddrs("127.0.0.9",
"127.0.0.10", "127.0.0.1", "127.0.1.2"));
-        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.10",
"127.0.0.1", "127.0.0.2"));
-        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.1",
"127.0.0.2", "127.0.0.3"));
+        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("85"), makeAddrs("127.0.0.9",
"127.0.0.10", "127.0.0.1"));
+        expectedEndpoints.get("Keyspace4").putAll(new BigIntegerToken("95"), makeAddrs("127.0.0.10",
"127.0.0.1", "127.0.0.2"));
 
         for (Map.Entry<String, AbstractReplicationStrategy> tableStrategy : tableStrategyMap.entrySet())
         {
@@ -431,12 +436,12 @@ public class MoveTest
             assertTrue(endpoints.contains(boot1));
             assertTrue(endpoints.contains(boot2));
 
-            // token 65 should go to nodes 7, 8, 9 and boot2
+            // token 65 should go to nodes 6, 7, 8 and boot2
             endpoints = tmd.getWriteEndpoints(keyTokens.get(6), table, strategy.getNaturalEndpoints(keyTokens.get(6)));
             assertTrue(endpoints.size() == 4);
+            assertTrue(endpoints.contains(hosts.get(6)));
             assertTrue(endpoints.contains(hosts.get(7)));
             assertTrue(endpoints.contains(hosts.get(8)));
-            assertTrue(endpoints.contains(hosts.get(9)));
             assertTrue(endpoints.contains(boot2));
 
             // token 75 should to go nodes 8, 9, 0 and boot2
@@ -447,19 +452,19 @@ public class MoveTest
             assertTrue(endpoints.contains(hosts.get(0)));
             assertTrue(endpoints.contains(boot2));
 
-            // token 85 should go to nodes 9, 0, 1
+            // token 85 should go to nodes 8, 9 and 0
             endpoints = tmd.getWriteEndpoints(keyTokens.get(8), table, strategy.getNaturalEndpoints(keyTokens.get(8)));
             assertTrue(endpoints.size() == 3);
+            assertTrue(endpoints.contains(hosts.get(8)));
             assertTrue(endpoints.contains(hosts.get(9)));
             assertTrue(endpoints.contains(hosts.get(0)));
-            assertTrue(endpoints.contains(hosts.get(1)));
 
-            // token 95 should go to nodes 0, 1 and 2
+            // token 95 should go to nodes 9, 0 and 1
             endpoints = tmd.getWriteEndpoints(keyTokens.get(9), table, strategy.getNaturalEndpoints(keyTokens.get(9)));
             assertTrue(endpoints.size() == 3);
+            assertTrue(endpoints.contains(hosts.get(9)));
             assertTrue(endpoints.contains(hosts.get(0)));
             assertTrue(endpoints.contains(hosts.get(1)));
-            assertTrue(endpoints.contains(hosts.get(2)));
         }
 
         // all moving nodes are back to the normal state
@@ -529,7 +534,7 @@ public class MoveTest
 
     private Token positionToken(int position)
     {
-        return new BigIntegerToken(String.valueOf(10 * position + 2));
+        return new BigIntegerToken(String.valueOf(10 * position + 7));
     }
 
     private int collectionSize(Collection<?> collection)


Mime
View raw message