Skip to content

Commit

Permalink
Fixes #2350 Clustering tests: let cluster managers decide how to tear…
Browse files Browse the repository at this point in the history
… down clustered nodes

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
  • Loading branch information
tsegismont committed Mar 21, 2018
1 parent 0262913 commit 7b7ef32
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/test/java/io/vertx/test/core/VertxTestBase.java
Expand Up @@ -21,8 +21,8 @@
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.JksOptions;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.core.net.KeyCertOptions;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.core.net.PfxOptions;
import io.vertx.core.net.TCPSSLOptions;
import io.vertx.core.spi.cluster.ClusterManager;
Expand Down Expand Up @@ -82,21 +82,25 @@ protected void tearDown() throws Exception {
close(vertx);
}
if (created != null) {
CountDownLatch latch = new CountDownLatch(created.size());
for (Vertx v : created) {
v.close(ar -> {
if (ar.failed()) {
log.error("Failed to shutdown vert.x", ar.cause());
}
latch.countDown();
});
}
assertTrue(latch.await(180, TimeUnit.SECONDS));
closeClustered(created);
}
FakeClusterManager.reset(); // Bit ugly
super.tearDown();
}

protected void closeClustered(List<Vertx> clustered) throws Exception {
CountDownLatch latch = new CountDownLatch(clustered.size());
for (Vertx clusteredVertx : clustered) {
clusteredVertx.close(ar -> {
if (ar.failed()) {
log.error("Failed to shutdown vert.x", ar.cause());
}
latch.countDown();
});
}
assertTrue(latch.await(180, TimeUnit.SECONDS));
}

/**
* @return create a blank new Vert.x instance with no options closed when tear down executes.
*/
Expand Down

0 comments on commit 7b7ef32

Please sign in to comment.