Search in sources :

Example 46 with RestClient

use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.

the class RestServerResource method testMemory.

@Test
public void testMemory() {
    RestClient client = SERVER_TEST.rest().create();
    RestResponse restResponse = sync(client.server().memory());
    assertEquals(200, restResponse.getStatus());
    Json infoNode = Json.read(restResponse.getBody());
    Json memory = infoNode.at("heap");
    assertTrue(memory.at("used").asInteger() > 0);
    assertTrue(memory.at("committed").asInteger() > 0);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.junit.Test)

Example 47 with RestClient

use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.

the class RestServerResource method testConfig.

@Test
public void testConfig() {
    RestClient client = SERVER_TEST.rest().create();
    RestResponse restResponse = sync(client.server().configuration());
    assertEquals(200, restResponse.getStatus());
    Json configNode = Json.read(restResponse.getBody());
    Json server = configNode.at("server");
    Json interfaces = server.at("interfaces");
    Json security = server.at("security");
    Json endpoints = server.at("endpoints");
    Json endpoint = endpoints.at("endpoint");
    String inetAddress = SERVERS.getServerDriver() instanceof ContainerInfinispanServerDriver ? "SITE_LOCAL" : "127.0.0.1";
    assertEquals(inetAddress, interfaces.at(0).at("inet-address").at("value").asString());
    assertEquals("default", security.at("security-realms").at(0).at("name").asString());
    assertEquals("hotrod", endpoint.at("hotrod-connector").at("name").asString());
    assertEquals("rest", endpoint.at("rest-connector").at("name").asString());
    assertEquals("memcachedCache", endpoint.at("memcached-connector").at("cache").asString());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Json(org.infinispan.commons.dataconversion.internal.Json) ContainerInfinispanServerDriver(org.infinispan.server.test.core.ContainerInfinispanServerDriver) Test(org.junit.Test)

Example 48 with RestClient

use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.

the class RollingUpgradeDynamicStoreIT method testRollingUpgrade.

@Test
@Override
public void testRollingUpgrade() throws Exception {
    RestClient restClientSource = source.getClient();
    RestClient restClientTarget = target.getClient();
    // Create cache in the source cluster
    createSourceClusterCache();
    // Create cache in the target cluster identical to the source, without any store
    createTargetClusterWithoutStore();
    // Register proto schema
    addSchema(restClientSource);
    addSchema(restClientTarget);
    // Populate source cluster
    populateCluster(restClientSource);
    // Connect target cluster to the source cluster
    assertSourceDisconnected();
    connectTargetCluster();
    assertSourceConnected();
    // Make sure data is accessible from the target cluster
    assertEquals("name-13", getPersonName("13", restClientTarget));
    // Do a rolling upgrade from the target
    doRollingUpgrade(restClientTarget);
    // Do a second rolling upgrade, should be harmless and simply override the data
    doRollingUpgrade(restClientTarget);
    // Disconnect source from the remote store
    disconnectSource(restClientTarget);
    assertSourceDisconnected();
    // Stop source cluster
    stopSourceCluster();
    // Assert all nodes are disconnected and data was migrated successfully
    for (int i = 0; i < target.getMembers().size(); i++) {
        RestClient restClient = target.getClient(i);
        assertEquals(ENTRIES, getCacheSize(CACHE_NAME, restClient));
        assertEquals("name-35", getPersonName("35", restClient));
    }
}
Also used : RestClient(org.infinispan.client.rest.RestClient) Test(org.junit.Test)

Example 49 with RestClient

use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.

the class ConcurrentShutdownRestIT method testShutDown.

@Test
public void testShutDown() {
    RestClient client0 = SERVER_TEST.rest().create();
    RestClient client1 = SERVER_TEST.rest().get(1);
    CompletionStage<RestResponse> stop0 = client0.server().stop();
    CompletionStage<RestResponse> stop1 = client1.server().stop();
    sync(stop0);
    sync(stop1);
    eventually(() -> isServerShutdown(client0));
    eventually(() -> isServerShutdown(client1));
    eventually(() -> !SERVER.getServerDriver().isRunning(0));
    eventually(() -> !SERVER.getServerDriver().isRunning(1));
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Test(org.junit.Test)

Example 50 with RestClient

use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.

the class HotRodCacheQueries method testQueryViaRest.

@Test
public void testQueryViaRest() throws IOException {
    RemoteCache<Integer, User> remoteCache = ClusteredIT.createQueryableCache(SERVER_TEST, indexed);
    remoteCache.put(1, createUser1());
    remoteCache.put(2, createUser2());
    String query = "FROM sample_bank_account.User WHERE name='Adrian'";
    RestClient restClient = SERVER_TEST.newRestClient(new RestClientConfigurationBuilder());
    RestResponse response = sync(restClient.cache(SERVER_TEST.getMethodName()).query(query));
    Json results = Json.read(response.getBody());
    assertEquals(1, results.at("total_results").asInteger());
}
Also used : RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) User(org.infinispan.protostream.sampledomain.User) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.junit.Test)

Aggregations

RestClient (org.infinispan.client.rest.RestClient)65 Test (org.junit.Test)41 RestResponse (org.infinispan.client.rest.RestResponse)37 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)26 Json (org.infinispan.commons.dataconversion.internal.Json)15 RestCacheClient (org.infinispan.client.rest.RestCacheClient)11 Test (org.testng.annotations.Test)10 IOException (java.io.IOException)6 AbstractMultipleSitesTest (org.infinispan.xsite.AbstractMultipleSitesTest)6 ArrayList (java.util.ArrayList)4 RestServerHelper (org.infinispan.rest.helper.RestServerHelper)4 AbstractRestResourceTest (org.infinispan.rest.resources.AbstractRestResourceTest)4 InetSocketAddress (java.net.InetSocketAddress)3 List (java.util.List)3 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)3 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 TestUser (org.infinispan.server.test.api.TestUser)3 File (java.io.File)2 UncheckedIOException (java.io.UncheckedIOException)2