Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,14 @@ public void testAddWithoutEnsembleTracker() throws Exception {

@Test
public void testAdd() throws Exception {
try (CuratorFramework client = newClient()) {
CountDownLatch ensembleLatch = new CountDownLatch(1);
try (CuratorFramework client = newClient(cluster.getConnectString(), ensembleLatch)) {
client.start();

QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
assertConfig(oldConfig, cluster.getInstances());

CountDownLatch latch = setChangeWaiter(client);
CountDownLatch eventLatch = setChangeWaiter(client);
try (TestingCluster newCluster = new TestingCluster(TestingCluster.makeSpecs(1, false))) {
newCluster.start();

Expand All @@ -271,7 +272,8 @@ public void testAdd() throws Exception {
.fromConfig(oldConfig.getVersion())
.forEnsemble();

assertTrue(timing.awaitLatch(latch));
assertTrue(timing.awaitLatch(eventLatch));
assertTrue(timing.awaitLatch(ensembleLatch));

byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
Expand All @@ -286,13 +288,14 @@ public void testAdd() throws Exception {

@Test
public void testAddAsync() throws Exception {
try (CuratorFramework client = newClient()) {
CountDownLatch ensembleLatch = new CountDownLatch(1);
try (CuratorFramework client = newClient(cluster.getConnectString(), ensembleLatch)) {
client.start();

QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
assertConfig(oldConfig, cluster.getInstances());

CountDownLatch latch = setChangeWaiter(client);
CountDownLatch eventLatch = setChangeWaiter(client);
try (TestingCluster newCluster = new TestingCluster(TestingCluster.makeSpecs(1, false))) {
newCluster.start();

Expand All @@ -312,7 +315,8 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex
.forEnsemble();

assertTrue(timing.awaitLatch(callbackLatch));
assertTrue(timing.awaitLatch(latch));
assertTrue(timing.awaitLatch(eventLatch));
assertTrue(timing.awaitLatch(ensembleLatch));

byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
Expand All @@ -327,13 +331,14 @@ public void processResult(CuratorFramework client, CuratorEvent event) throws Ex

@Test
public void testAddAndRemove() throws Exception {
try (CuratorFramework client = newClient()) {
CountDownLatch ensembleLatch = new CountDownLatch(1);
try (CuratorFramework client = newClient(cluster.getConnectString(), ensembleLatch)) {
client.start();

QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
assertConfig(oldConfig, cluster.getInstances());

CountDownLatch latch = setChangeWaiter(client);
CountDownLatch eventLatch = setChangeWaiter(client);

try (TestingCluster newCluster = new TestingCluster(TestingCluster.makeSpecs(1, false))) {
newCluster.start();
Expand All @@ -355,7 +360,8 @@ public void testAddAndRemove() throws Exception {
.fromConfig(oldConfig.getVersion())
.forEnsemble();

assertTrue(timing.awaitLatch(latch));
assertTrue(timing.awaitLatch(eventLatch));
assertTrue(timing.awaitLatch(ensembleLatch));

byte[] newConfigData = client.getConfig().forEnsemble();
QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
Expand Down