@Test(groups = "Integration") public void testEntitiesExistOnMasterPromotion() throws Exception { initHaCluster(HighAvailabilityMode.AUTO, HighAvailabilityMode.AUTO); assertEquals(getAppResponseCode(), 403); stopWriteNode(); assertEntityExists(new ReturnCodeNotRetryAndNodeIsMaster()); assertReadIsMaster(); }
@Test(groups = "Integration") public void testEntitiesExistOnDisabledHA() throws Exception { initHaCluster(HighAvailabilityMode.DISABLED, HighAvailabilityMode.DISABLED); assertReadIsMaster(); assertEntityExists(new ReturnCodeNotRetry()); }
private void initHaCluster(HighAvailabilityMode writeMode, HighAvailabilityMode readMode) throws InterruptedException, TimeoutException { mementoDir = Os.newTempDir(getClass()); writeMgmt = createManagementContext(mementoDir, writeMode); appId = createApp(writeMgmt); writeMgmt.getRebindManager().waitForPendingComplete(TIMEOUT, true); if (readMode == HighAvailabilityMode.DISABLED) { //no HA, one node only readMgmt = writeMgmt; } else { readMgmt = createManagementContext(mementoDir, readMode); } server = useServerForTest(baseLauncher() .securityProvider(AnyoneSecurityProvider.class) .managementContext(readMgmt) .forceUseOfDefaultCatalogWithJavaClassPath(true) .withoutJsgui() .disableHighAvailability(false) .start()); client = getClient(server); }
private int getAppResponseCode() { HttpToolResponse response = HttpTool.httpGet( client, URI.create(getBaseUriRest() + "applications/" + appId), ImmutableMap.<String,String>of()); return response.getResponseCode(); }
@Test(groups = "Integration") public void testEntitiesExistOnHotBackup() throws Exception { initHaCluster(HighAvailabilityMode.AUTO, HighAvailabilityMode.HOT_BACKUP); Asserts.continually( new ReturnCodeSupplier(), Predicates.or(Predicates.equalTo(200), Predicates.equalTo(403)), Duration.THIRTY_SECONDS, null, null); }
private HttpClient getClient(Server server) { HttpClient client = HttpTool.httpClientBuilder() .uri(getBaseUriRest(server)) .build(); return client; }
@Test(groups = "Integration") public void testEntitiesExistOnHotStandbyAndPromotion() throws Exception { initHaCluster(HighAvailabilityMode.AUTO, HighAvailabilityMode.HOT_STANDBY); assertEntityExists(new ReturnCodeNotRetry()); stopWriteNode(); // once the node claims master we should get a 200 assertEntityExists(new ReturnCodeNotRetryAndNodeIsMaster()); assertReadIsMaster(); }