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);
}
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());
}
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));
}
}
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));
}
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());
}
Aggregations