kezhuw commented on code in PR #460:
URL: https://github.com/apache/curator/pull/460#discussion_r1200119273
##########
curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java:
##########
@@ -436,6 +439,51 @@ public void testNewMembers() throws Exception
}
}
+ @Test
+ public void testRemoveWithChroot() throws Exception
+ {
+ // Use a long chroot path to circumvent ZOOKEEPER-4565 and
ZOOKEEPER-4601
+ String chroot = "/pretty-long-chroot";
+
+ try (CuratorFramework client = newClient(cluster.getConnectString() +
chroot)) {
+ client.start();
+ client.create().forPath("/", "deadbeef".getBytes());
+
+ QuorumVerifier oldConfig =
toQuorumVerifier(client.getConfig().forEnsemble());
+ assertConfig(oldConfig, cluster.getInstances());
+
+ CountDownLatch latch = setChangeWaiter(client);
+
+ Collection<InstanceSpec> oldInstances = cluster.getInstances();
+ InstanceSpec us =
cluster.findConnectionInstance(client.getZookeeperClient().getZooKeeper());
+ InstanceSpec removeSpec = oldInstances.iterator().next();
+ if ( us.equals(removeSpec) ) {
+ Iterator<InstanceSpec> iterator = oldInstances.iterator();
+ iterator.next();
+ removeSpec = iterator.next();
+ }
+
+
client.reconfig().leaving(Integer.toString(removeSpec.getServerId())).fromConfig(oldConfig.getVersion()).forEnsemble();
+
+ assertTrue(timing.awaitLatch(latch));
+
+ byte[] newConfigData = client.getConfig().forEnsemble();
+ QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
+ List<InstanceSpec> newInstances =
Lists.newArrayList(cluster.getInstances());
+ newInstances.remove(removeSpec);
+ assertConfig(newConfig, newInstances);
+
+ assertTrue(timing.awaitLatch(ensembleLatch));
+ String connectString =
EnsembleTracker.configToConnectionString(newConfig) + chroot;
+ assertEquals(connectString,
ensembleProvider.getConnectionString());
+
+ client.getZookeeperClient().reset();
+ client.sync().forPath("/");
+ byte[] data = client.getData().forPath("/");
+ assertArrayEquals("deadbeef".getBytes(), data, () -> "expected
\"deedbeef\", got data: " + Arrays.toString(data));
Review Comment:
Fixed in fixup commit.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]