You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "maoling (via GitHub)" <gi...@apache.org> on 2024/02/07 06:56:50 UTC
Re: [PR] Add test case to check node and children nodes exist in zookeeper cluster [zookeeper]
maoling commented on code in PR #1895:
URL: https://github.com/apache/zookeeper/pull/1895#discussion_r1480967766
##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/ZooKeeperServerMainTest.java:
##########
@@ -672,4 +676,70 @@ public void process(WatchedEvent event) {
}
}
+ private final static int SERVER_COUNT = 5;
+ private final QuorumPeerTestBase.MainThread[] threads = new QuorumPeerTestBase.MainThread[SERVER_COUNT];
+
+ @Test
+ public void checkNodeExistInCluster() throws Exception {
+ final int[] clientPorts = new int[SERVER_COUNT];
+ StringBuilder sb = new StringBuilder();
+ String server;
+
+ for (int i = 0; i < SERVER_COUNT; i++) {
+ clientPorts[i] = PortAssignment.unique();
+ server = "server." + i + "=127.0.0.1:" + PortAssignment.unique() + ":" + PortAssignment.unique()
+ + ":participant;127.0.0.1:" + clientPorts[i];
+ sb.append(server + "\n");
+ }
+ String currentQuorumCfgSection = sb.toString();
+ // start all the servers
+ for (int i = 0; i < SERVER_COUNT; i++) {
+ threads[i] = new QuorumPeerTestBase.MainThread(i, clientPorts[i], currentQuorumCfgSection, false) {
+ @Override
+ public QuorumPeerTestBase.TestQPMain getTestQPMain() {
+ return new QuorumPeerTestBase.TestQPMain();
+ }
+ };
+ threads[i].start();
+ }
+
+ // ensure all servers started
+ for (int i = 0; i < SERVER_COUNT; i++) {
+ assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i], CONNECTION_TIMEOUT),
+ "waiting for server " + i + " being up");
+ }
+ // create a zk client
+ ClientBase.CountdownWatcher watch = new ClientBase.CountdownWatcher();
+ ZooKeeper zk = new ZooKeeper("127.0.0.1:" + clientPorts[1], ClientBase.CONNECTION_TIMEOUT, watch);
+ watch.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
+
+ // zk client request to add node and children nodes
+ zk.create("/test", "10".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+ zk.create("/test/a", "11".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+ zk.create("/test/b", "12".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+ zk.create("/test/c", "13".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+
+ // get leadere
Review Comment:
A typo?
##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/ZooKeeperServerMainTest.java:
##########
@@ -344,11 +348,11 @@ public void testWithMinSessionTimeoutGreaterThanMaxSessionTimeout() throws Excep
final int minSessionTimeout = 20 * tickTime + 1000; // min is higher
final int maxSessionTimeout = tickTime * 2 - 100; // max is lower
final String configs = "maxSessionTimeout="
- + maxSessionTimeout
- + "\n"
- + "minSessionTimeout="
- + minSessionTimeout
- + "\n";
+ + maxSessionTimeout
Review Comment:
Don't change unrelated codes
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org