Search in sources :

Example 6 with RestCacheManagerClient

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);
}
Also used : HashMap(java.util.HashMap) RestCacheManagerClient(org.infinispan.client.rest.RestCacheManagerClient) RestResponse(org.infinispan.client.rest.RestResponse) List(java.util.List) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.junit.Test)

Example 7 with RestCacheManagerClient

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);
}
Also used : RestCacheManagerClient(org.infinispan.client.rest.RestCacheManagerClient) RestResponse(org.infinispan.client.rest.RestResponse) Test(org.junit.Test)

Example 8 with RestCacheManagerClient

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());
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) RestCacheManagerClient(org.infinispan.client.rest.RestCacheManagerClient) RestClient(org.infinispan.client.rest.RestClient) RestCacheClient(org.infinispan.client.rest.RestCacheClient)

Aggregations

RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)8 RestResponse (org.infinispan.client.rest.RestResponse)6 Test (org.junit.Test)6 RestClient (org.infinispan.client.rest.RestClient)4 HashMap (java.util.HashMap)2 List (java.util.List)2 Json (org.infinispan.commons.dataconversion.internal.Json)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)1 AbstractMultipleSitesTest (org.infinispan.xsite.AbstractMultipleSitesTest)1 Test (org.testng.annotations.Test)1