You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by GitBox <gi...@apache.org> on 2019/02/24 09:27:23 UTC

[GitHub] eolivelli commented on a change in pull request #832: ZOOKEEPER-2503:do a hard constraints on the number of myid which must be between 1 and 255

eolivelli commented on a change in pull request #832: ZOOKEEPER-2503:do a hard constraints on the number of myid which must be between 1 and 255
URL: https://github.com/apache/zookeeper/pull/832#discussion_r259610908
 
 

 ##########
 File path: zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
 ##########
 @@ -436,6 +438,35 @@ public void testElectionFraud() throws IOException, InterruptedException {
         Assert.assertTrue("falseLeader never rejoins the quorum", foundFollowing);
     }
 
+    @Test
+    public void testBadMyId() throws Exception {
+        ClientBase.setupTestEnv();
+
+        final int CLIENT_PORT_QP1 = PortAssignment.unique();
+        List<Integer> invalidMyidList = new ArrayList<>();
+        invalidMyidList.add(-1);
+        invalidMyidList.add(0);
+        invalidMyidList.add(256);
+        invalidMyidList.add(1024);
+        for (Integer myidForCheck : invalidMyidList) {
+            String quorumCfgSection = "server.1=127.0.0.1:"
+                    + PortAssignment.unique() + ":" + PortAssignment.unique()
+                    + "\nserver." + myidForCheck + "=127.0.0.1:" + PortAssignment.unique() + ":"
+                    + PortAssignment.unique();
+
+            MainThread q1 = new MainThread(myidForCheck, CLIENT_PORT_QP1, quorumCfgSection);
 
 Review comment:
   Do we really need to setup all of this stuff in order to test one simple validation?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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