SOLR-11899 Fix a race condition when testing removal of ephemeral nodes.

This commit is contained in:
Andrzej Bialecki 2018-02-13 17:57:40 +01:00
parent dd08400a3d
commit 0231d5cdba
2 changed files with 25 additions and 2 deletions

View File

@ -82,6 +82,22 @@ public class TestDistribStateManager extends SolrTestCaseJ4 {
LOG.info("Using " + stateManager.getClass().getName());
}
private DistribStateManager createDistribStateManager() {
if (simulated) {
return new SimDistribStateManager(root);
} else {
SolrZkClient cli = new SolrZkClient(zkTestServer.getZkHost(), 30000);
return new ZkDistribStateManager(cli);
}
}
private void destroyDistribStateManager(DistribStateManager mgr) throws Exception {
mgr.close();
if (mgr instanceof ZkDistribStateManager) {
((ZkDistribStateManager)mgr).getZkClient().close();
}
}
@After
public void teardown() throws Exception {
if (solrZkClient != null) {
@ -248,10 +264,13 @@ public class TestDistribStateManager extends SolrTestCaseJ4 {
// watch should not fire now because it needs to be reset
stateManager.setData("/getData/persistentData", secondData, -1);
// create ephemeral node using another ZK connection
DistribStateManager ephemeralMgr = createDistribStateManager();
ephemeralMgr.createData("/getData/ephemeralData", firstData, CreateMode.EPHEMERAL);
nodeWatcher = new OnceWatcher();
stateManager.createData("/getData/ephemeralData", firstData, CreateMode.EPHEMERAL);
vd = stateManager.getData("/getData/ephemeralData", nodeWatcher);
reInit();
destroyDistribStateManager(ephemeralMgr);
if (!nodeWatcher.triggered.await(5, TimeUnit.SECONDS)) {
fail("Node watch should have fired!");
}

View File

@ -187,4 +187,8 @@ public class ZkDistribStateManager implements DistribStateManager {
public void close() throws IOException {
}
public SolrZkClient getZkClient() {
return zkClient;
}
}