@Test public void testQuorum() throws Exception { vertx1 = startVertx(2); DeploymentOptions options = new DeploymentOptions().setHa(true); JsonObject config = new JsonObject().put("foo", "bar"); options.setConfig(config); vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> { assertTrue(ar.succeeded()); assertTrue(vertx1.deploymentIDs().contains(ar.result())); testComplete(); }); // Shouldn't deploy until a quorum is obtained assertWaitUntil(() -> vertx1.deploymentIDs().isEmpty()); vertx2 = startVertx(2); // Now should be deployed await(); }
@Test public void testCleanCloseNoFailover() throws Exception { vertx1 = startVertx(); vertx2 = startVertx(); DeploymentOptions options = new DeploymentOptions().setHa(true); JsonObject config = new JsonObject().put("foo", "bar"); options.setConfig(config); CountDownLatch deployLatch = new CountDownLatch(1); vertx2.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> { assertTrue(ar.succeeded()); deployLatch.countDown(); }); awaitLatch(deployLatch); ((VertxInternal)vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not be called"); }); vertx2.close(ar -> { vertx.setTimer(500, tid -> { // Wait a bit in case failover happens testComplete(); }); }); await(); }
@Test public void testNoFailoverToNonHANode() throws Exception { vertx1 = startVertx(); // Create a non HA node vertx2 = startVertx(null, 0, false); CountDownLatch latch1 = new CountDownLatch(1); vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> { assertTrue(ar.succeeded()); assertTrue(vertx1.deploymentIDs().contains(ar.result())); latch1.countDown(); }); awaitLatch(latch1); ((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not failover here 2"); }); ((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not failover here 1"); }); ((VertxInternal) vertx1).simulateKill(); vertx2.close(ar -> { vertx.setTimer(500, tid -> { // Wait a bit in case failover happens testComplete(); }); }); await(); }
@Test public void testQuorum() throws Exception { vertx1 = startVertx(2); DeploymentOptions options = new DeploymentOptions().setHa(true); JsonObject config = new JsonObject().put("foo", "bar"); options.setConfig(config); vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> { assertTrue(ar.succeeded()); assertTrue(vertx1.deploymentIDs().contains(ar.result())); testComplete(); }); // Shouldn't deploy until a quorum is obtained assertWaitUntil(() -> vertx1.deploymentIDs().isEmpty()); vertx2 = startVertx(2); // Now should be deployed await(); }
@Test public void testCleanCloseNoFailover() throws Exception { vertx1 = startVertx(); vertx2 = startVertx(); DeploymentOptions options = new DeploymentOptions().setHa(true); JsonObject config = new JsonObject().put("foo", "bar"); options.setConfig(config); CountDownLatch deployLatch = new CountDownLatch(1); vertx2.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> { assertTrue(ar.succeeded()); deployLatch.countDown(); }); awaitLatch(deployLatch); ((VertxInternal)vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not be called"); }); vertx2.close(ar -> { vertx.setTimer(500, tid -> { // Wait a bit in case failover happens testComplete(); }); }); await(); }
@Test public void testNoFailoverToNonHANode() throws Exception { vertx1 = startVertx(); // Create a non HA node vertx2 = startVertx(null, 0, false); CountDownLatch latch1 = new CountDownLatch(1); vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> { assertTrue(ar.succeeded()); assertTrue(vertx1.deploymentIDs().contains(ar.result())); latch1.countDown(); }); awaitLatch(latch1); ((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not failover here 2"); }); ((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> { fail("Should not failover here 1"); }); ((VertxInternal) vertx1).simulateKill(); vertx2.close(ar -> { vertx.setTimer(500, tid -> { // Wait a bit in case failover happens testComplete(); }); }); await(); }