use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testBringAllCachesOnlineOffline.
@Test
public void testBringAllCachesOnlineOffline() {
RestClient restClient = clientPerSite.get(LON);
RestCacheManagerClient restCacheManagerClient = restClient.cacheManager(CACHE_MANAGER);
assertSuccessful(restCacheManagerClient.takeOffline(SFO));
Json json = jsonResponseBody(restCacheManagerClient.backupStatuses());
assertEquals(json.at(SFO).at("status").asString(), "offline");
assertSuccessful(restCacheManagerClient.bringBackupOnline(SFO));
json = jsonResponseBody(restCacheManagerClient.backupStatuses());
assertEquals(json.at(SFO).at("status").asString(), "online");
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testInvalidSite.
@Test
public void testInvalidSite() {
RestClient client = clientPerSite.get(LON);
RestCacheClient cache = client.cache(CACHE_1);
assertStatus(404, cache.backupStatus("invalid-site"));
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testPushAllCaches.
@Test
public void testPushAllCaches() {
RestClient restClientLon = clientPerSite.get(LON);
RestClient restClientSfo = clientPerSite.get(SFO);
RestCacheClient cache1Lon = restClientLon.cache(CACHE_1);
RestCacheClient cache2Lon = restClientLon.cache(CACHE_2);
RestCacheClient cache1Sfo = restClientSfo.cache(CACHE_1);
RestCacheClient cache2Sfo = restClientSfo.cache(CACHE_2);
// Take SFO offline for all caches
assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).takeOffline(SFO));
Json backupStatuses = jsonResponseBody(restClientLon.cacheManager(CACHE_MANAGER).backupStatuses());
assertEquals("offline", backupStatuses.at(SFO).at("status").asString());
// Write to the caches
int entries = 10;
IntStream.range(0, entries).forEach(i -> {
String key = String.valueOf(i);
String value = "value";
assertNoContent(cache1Lon.put(key, value));
assertNoContent(cache2Lon.put(key, value));
});
// Backups should be empty
assertEquals(0, getCacheSize(cache1Sfo));
assertEquals(0, getCacheSize(cache2Sfo));
// Start state push
assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).pushSiteState(SFO));
// Backups go online online immediately
assertEquals(ONLINE, getBackupStatus(LON, SFO));
// State push should eventually finish
eventuallyEquals("OK", () -> pushStateStatus(cache1Lon, SFO));
eventuallyEquals("OK", () -> pushStateStatus(cache2Lon, SFO));
// ... and with state
assertEquals(entries, getCacheSize(cache1Sfo));
assertEquals(entries, getCacheSize(cache2Sfo));
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testInvalidInputTakeOffline.
@Test
public void testInvalidInputTakeOffline() {
RestClient restClient = clientPerSite.get(LON);
String url = String.format("/rest/v2/caches/%s/x-site/backups/%s/take-offline-config", CACHE_1, NYC);
assertStatus(400, restClient.raw().putValue(url, new HashMap<>(), "invalid", "application/json"));
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testInvalidCache.
@Test
public void testInvalidCache() {
RestClient client = clientPerSite.get(LON);
assertStatus(404, client.cache("invalid-cache").xsiteBackups());
}
Aggregations