anmolnar 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_r262276762
########## 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: I think `MainThread` is not that big deal to use in tests, because it's more like an integration test rather than unit. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services