use of org.infinispan.client.rest.RestCacheManagerClient in project infinispan by infinispan.
the class BackupManagerIT method testManagerRestoreParameters.
@Test
public void testManagerRestoreParameters() throws Exception {
String name = "testManagerRestoreParameters";
performTest(client -> {
// Create a backup of all container content
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.createBackup(name));
assertEquals(202, response.getStatus());
return awaitOk(() -> cm.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
// Request that only the 'test.js' script is restored
Map<String, List<String>> params = new HashMap<>();
params.put("tasks", Collections.singletonList("scripts/test.js"));
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.restore(name, zip, params));
assertEquals(202, response.getStatus());
return awaitCreated(() -> cm.getRestore(name));
}, client -> {
// Assert that the test.js task has been restored
List<Json> tasks = Json.read(await(client.tasks().list(RestTaskClient.ResultType.USER)).getBody()).asJsonList();
assertEquals(1, tasks.size());
assertEquals("scripts/test.js", tasks.iterator().next().at("name").asString());
// Assert that no other content has been restored
assertEquals("[\"___protobuf_metadata\",\"memcachedCache\",\"___script_cache\"]", await(client.caches()).getBody());
assertEquals("[]", await(client.counters()).getBody());
assertEquals(404, await(client.schemas().get("schema.proto")).getStatus());
}, false);
}
use of org.infinispan.client.rest.RestCacheManagerClient in project infinispan by infinispan.
the class BackupManagerIT method testManagerBackupUpload.
@Test
public void testManagerBackupUpload() throws Exception {
String name = "testManagerBackup";
performTest(client -> {
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.createBackup(name));
assertEquals(202, response.getStatus());
return awaitOk(() -> cm.getBackup(name, false));
}, client -> await(client.cacheManager("clustered").deleteBackup(name)), (zip, client) -> {
RestCacheManagerClient cm = client.cacheManager("clustered");
RestResponse response = await(cm.restore(name, zip));
assertEquals(202, response.getStatus());
return awaitCreated(() -> cm.getRestore(name));
}, this::assertWildcardContent, false);
}
use of org.infinispan.client.rest.RestCacheManagerClient in project infinispan by infinispan.
the class AbstractAuthorization method assertXSiteOps.
private void assertXSiteOps(TestUser user, int status, int noContentStatus, int notModifiedStatus) {
RestClientConfigurationBuilder userConfig = restBuilders.get(user);
RestClient client = getServerTest().rest().withClientConfiguration(userConfig).get();
RestCacheClient xsiteCache = client.cache("xsite");
assertStatus(status, xsiteCache.takeSiteOffline("NYC"));
assertStatus(status, xsiteCache.bringSiteOnline("NYC"));
assertStatus(status, xsiteCache.cancelPushState("NYC"));
assertStatus(status, xsiteCache.cancelReceiveState("NYC"));
assertStatus(status, xsiteCache.clearPushStateStatus());
assertStatus(status, xsiteCache.pushSiteState("NYC"));
assertStatus(status, xsiteCache.pushStateStatus());
assertStatus(status, xsiteCache.xsiteBackups());
assertStatus(status, xsiteCache.backupStatus("NYC"));
assertStatus(status, xsiteCache.getXSiteTakeOfflineConfig("NYC"));
assertStatus(noContentStatus, xsiteCache.updateXSiteTakeOfflineConfig("NYC", 10, 1000));
assertStatus(status, xsiteCache.xSiteStateTransferMode("NYC"));
assertStatus(notModifiedStatus, xsiteCache.xSiteStateTransferMode("NYC", XSiteStateTransferMode.MANUAL));
RestCacheManagerClient xsiteCacheManager = client.cacheManager("default");
assertStatus(status, xsiteCacheManager.bringBackupOnline("NYC"));
assertStatus(status, xsiteCacheManager.takeOffline("NYC"));
assertStatus(status, xsiteCacheManager.backupStatuses());
}
Aggregations