XComp commented on code in PR #430:
URL: https://github.com/apache/curator/pull/430#discussion_r958163715
##########
curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java:
##########
@@ -218,6 +218,30 @@ public void testWatchedNodeDeletedOnReconnect() throws
Exception
}
}
+ @Test
+ public void testOurPathDeletedOnReconnect() throws Exception
Review Comment:
What do you think of the following test:
```
@Test
public void
testLeadershipElectionWhenNodeDisappearsAfterChildrenAreRetrieved() throws
Exception
{
final String latchPath = "/foo/bar";
final Timing2 timing = new Timing2();
try (CuratorFramework client =
CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
timing.connection(), new RetryOneTime(1)))
{
client.start();
LeaderLatch latch0 = new LeaderLatch(client, latchPath, "0");
latch0.start();
waitForALeader(Collections.singletonList(latch0), new Timing());
LeaderLatch latch1 = new LeaderLatch(client, latchPath, "1");
LeaderLatch latch2 = new LeaderLatch(client, latchPath, "2");
latch1.debugCheckLeaderShipLatch = new CountDownLatch(1);
latch1.start();
timing.sleepABit();
latch2.start();
timing.sleepABit();
latch0.close();
latch1.debugCheckLeaderShipLatch.countDown();
waitForALeader(Arrays.asList(latch1, latch2), new Timing());
latch1.close();
latch2.close();
}
}
```
This test case describes the situation for CURATOR-645. I checked in a local
test run, that it will run forever when still using `reset()` in
[LeaderLatch:633](https://github.com/apache/curator/blob/425598cb6bf6a5b227a5fdd293fe46c7978d6578/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java#L633)
but would succeed when using `getChildren()`, instead.
##########
curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java:
##########
@@ -218,6 +218,30 @@ public void testWatchedNodeDeletedOnReconnect() throws
Exception
}
}
+ @Test
+ public void testOurPathDeletedOnReconnect() throws Exception
Review Comment:
What do you think of the following test:
```
@Test
public void
testLeadershipElectionWhenNodeDisappearsAfterChildrenAreRetrieved() throws
Exception
{
final String latchPath = "/foo/bar";
final Timing2 timing = new Timing2();
try (CuratorFramework client =
CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
timing.connection(), new RetryOneTime(1)))
{
client.start();
LeaderLatch latch0 = new LeaderLatch(client, latchPath, "0");
latch0.start();
waitForALeader(Collections.singletonList(latch0), new Timing());
LeaderLatch latch1 = new LeaderLatch(client, latchPath, "1");
LeaderLatch latch2 = new LeaderLatch(client, latchPath, "2");
latch1.debugCheckLeaderShipLatch = new CountDownLatch(1);
latch1.start();
timing.sleepABit();
latch2.start();
timing.sleepABit();
latch0.close();
latch1.debugCheckLeaderShipLatch.countDown();
waitForALeader(Arrays.asList(latch1, latch2), new Timing());
latch1.close();
latch2.close();
}
}
```
This test case describes the situation for CURATOR-645. I checked in a local
test run, that it will run forever when still using `reset()` in
[LeaderLatch:633](https://github.com/apache/curator/blob/425598cb6bf6a5b227a5fdd293fe46c7978d6578/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java#L633)
but would succeed when using `getChildren()`, instead.
--
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]