cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] aweisberg commented on a change in pull request #283: CASSANDRA-14459: DynamicEndpointSnitch should never prefer latent replicas
Date Fri, 22 Mar 2019 23:29:59 GMT
aweisberg commented on a change in pull request #283: CASSANDRA-14459: DynamicEndpointSnitch
should never prefer latent replicas
URL: https://github.com/apache/cassandra/pull/283#discussion_r268275203
 
 

 ##########
 File path: test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
 ##########
 @@ -60,57 +160,480 @@ private static EndpointsForRange full(InetAddressAndPort... endpoints)
     }
 
     @Test
-    public void testSnitch() throws InterruptedException, IOException, ConfigurationException
+    public void testSortedByProximity() throws InterruptedException, ConfigurationException
     {
-        // do this because SS needs to be initialized before DES can work properly.
-        StorageService.instance.unsafeInitialize();
-        SimpleSnitch ss = new SimpleSnitch();
-        DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(ss, String.valueOf(ss.hashCode()));
-        InetAddressAndPort self = FBUtilities.getBroadcastAddressAndPort();
-        InetAddressAndPort host1 = InetAddressAndPort.getByName("127.0.0.2");
-        InetAddressAndPort host2 = InetAddressAndPort.getByName("127.0.0.3");
-        InetAddressAndPort host3 = InetAddressAndPort.getByName("127.0.0.4");
-        InetAddressAndPort host4 = InetAddressAndPort.getByName("127.0.0.5");
-        List<InetAddressAndPort> hosts = Arrays.asList(host1, host2, host3);
+        InetAddressAndPort self = hosts[0];
+        List<InetAddressAndPort> allHosts = Arrays.asList(hosts[1], hosts[2], hosts[3]);
 
         // first, make all hosts equal
-        setScores(dsnitch, 1, hosts, 10, 10, 10);
-        EndpointsForRange order = full(host1, host2, host3);
-        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(host1, host2, host3)));
-
-        // make host1 a little worse
-        setScores(dsnitch, 1, hosts, 20, 10, 10);
-        order = full(host2, host3, host1);
-        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(host1, host2, host3)));
-
-        // make host2 as bad as host1
-        setScores(dsnitch, 2, hosts, 15, 20, 10);
-        order = full(host3, host1, host2);
-        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(host1, host2, host3)));
-
-        // make host3 the worst
-        setScores(dsnitch, 3, hosts, 10, 10, 30);
-        order = full(host1, host2, host3);
-        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(host1, host2, host3)));
-
-        // make host3 equal to the others
-        setScores(dsnitch, 5, hosts, 10, 10, 10);
-        order = full(host1, host2, host3);
-        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(host1, host2, host3)));
+        setScores(dsnitch, 1, allHosts, 10, 10, 10);
+        EndpointsForRange order = full(hosts[1], hosts[2], hosts[3]);
+        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(hosts[1], hosts[2],
hosts[3])));
+
+        // make hosts[1] a little worse
+        setScores(dsnitch, 2, allHosts, 20, 10, 10);
+        order = full(hosts[2], hosts[3], hosts[1]);
+        Util.assertRCEquals(order, dsnitch.sortedByProximity(self, full(hosts[1], hosts[2],
hosts[3])));
+
+        // make hosts[2] as bad as hosts[1]
+        setScores(dsnitch, 4, allHosts, 15, 20, 10);
 
 Review comment:
   Why did the number of rounds change in each of these test cases?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


Mime
View raw message