use of org.infinispan.server.hotrod.test.TestResponse in project infinispan by infinispan.
the class HotRodDefaultCacheTest method testPutOnDefaultCache.
public void testPutOnDefaultCache(Method m) {
TestResponse resp = client().execute(0xA0, (byte) 0x01, "", k(m), 0, 0, v(m), 0, (byte) 1, 0);
assertStatus(resp, Success);
assertHotRodEquals(cacheManager, ANOTHER_CACHE, k(m), v(m));
assertFalse(cacheManager.getCache().containsKey(k(m)));
}
use of org.infinispan.server.hotrod.test.TestResponse in project infinispan by infinispan.
the class HotRodDistributionTest method testDistributedPutWithTopologyChanges.
public void testDistributedPutWithTopologyChanges(Method m) {
HotRodClient client1 = clients().get(0);
HotRodClient client2 = clients().get(1);
TestResponse resp = client1.ping(INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, servers(), cacheName(), currentServerTopologyId());
resp = client1.put(k(m), 0, 0, v(m), INTELLIGENCE_BASIC, 0);
assertStatus(resp, Success);
assertEquals(resp.topologyResponse, null);
assertSuccess(client2.get(k(m), 0), v(m));
resp = client1.put(k(m), 0, 0, v(m, "v1-"), INTELLIGENCE_TOPOLOGY_AWARE, 0);
assertStatus(resp, Success);
assertTopologyReceived(resp.topologyResponse, servers(), currentServerTopologyId());
resp = client2.put(k(m), 0, 0, v(m, "v2-"), INTELLIGENCE_TOPOLOGY_AWARE, 0);
assertStatus(resp, Success);
assertTopologyReceived(resp.topologyResponse, servers(), currentServerTopologyId());
resp = client1.put(k(m), 0, 0, v(m, "v3-"), INTELLIGENCE_TOPOLOGY_AWARE, ClusterCacheStatus.INITIAL_TOPOLOGY_ID + 2 * nodeCount());
assertStatus(resp, Success);
assertEquals(resp.topologyResponse, null);
assertSuccess(client2.get(k(m), 0), v(m, "v3-"));
resp = client1.put(k(m), 0, 0, v(m, "v4-"), INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, servers(), cacheName(), currentServerTopologyId());
assertSuccess(client2.get(k(m), 0), v(m, "v4-"));
resp = client2.put(k(m), 0, 0, v(m, "v5-"), INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, servers(), cacheName(), currentServerTopologyId());
assertSuccess(client2.get(k(m), 0), v(m, "v5-"));
HotRodServer newServer = startClusteredServer(servers().get(1).getPort() + 25);
HotRodClient newClient = new HotRodClient("127.0.0.1", newServer.getPort(), cacheName(), protocolVersion());
List<HotRodServer> allServers = Stream.concat(Stream.of(newServer), servers().stream()).collect(Collectors.toList());
try {
log.trace("New client started, modify key to be v6-*");
resp = newClient.put(k(m), 0, 0, v(m, "v6-"), INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, allServers, cacheName(), currentServerTopologyId());
log.trace("Get key and verify that's v6-*");
assertSuccess(client2.get(k(m), 0), v(m, "v6-"));
resp = client2.put(k(m), 0, 0, v(m, "v7-"), INTELLIGENCE_HASH_DISTRIBUTION_AWARE, 0);
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, allServers, cacheName(), currentServerTopologyId());
assertSuccess(newClient.get(k(m), 0), v(m, "v7-"));
} finally {
log.trace("Stopping new server");
killClient(newClient);
stopClusteredServer(newServer);
TestingUtil.waitForNoRebalance(cache(0, cacheName()), cache(1, cacheName()));
log.trace("New server stopped");
}
resp = client2.put(k(m), 0, 0, v(m, "v8-"), INTELLIGENCE_HASH_DISTRIBUTION_AWARE, ClusterCacheStatus.INITIAL_TOPOLOGY_ID + 2 * nodeCount());
assertStatus(resp, Success);
assertHashTopology20Received(resp.topologyResponse, servers(), cacheName(), currentServerTopologyId());
assertSuccess(client1.get(k(m), 0), v(m, "v8-"));
}
use of org.infinispan.server.hotrod.test.TestResponse in project infinispan by infinispan.
the class HotRodFunctionalTest method testBulkGetKeys.
public void testBulkGetKeys(Method m) {
int size = 100;
byte[][] keys = new byte[size][];
for (int i = 0; i < size; i++) {
keys[i] = k(m, i + "k-");
TestResponse resp = client().put(keys[i], 0, 0, v(m, i + "v-"));
assertStatus(resp, Success);
}
TestBulkGetKeysResponse resp = client().bulkGetKeys();
assertStatus(resp, Success);
Set<byte[]> bulkData = resp.bulkData;
assertEquals(size, bulkData.size());
for (int i = 0; i < size; i++) {
byte[] key = keys[i];
List<byte[]> filtered = bulkData.stream().filter(bytes -> Arrays.equals(bytes, key)).collect(Collectors.toList());
assertEquals(1, filtered.size());
}
resp = client().bulkGetKeys(1);
assertStatus(resp, Success);
bulkData = resp.bulkData;
assertEquals(size, bulkData.size());
for (int i = 0; i < size; i++) {
byte[] key = keys[i];
List<byte[]> filtered = bulkData.stream().filter(bytes -> java.util.Arrays.equals(bytes, key)).collect(Collectors.toList());
assertEquals(1, filtered.size());
}
resp = client().bulkGetKeys(2);
assertStatus(resp, Success);
bulkData = resp.bulkData;
assertEquals(size, bulkData.size());
for (int i = 0; i < size; i++) {
byte[] key = keys[i];
List<byte[]> filtered = bulkData.stream().filter(bytes -> Arrays.equals(bytes, key)).collect(Collectors.toList());
assertEquals(1, filtered.size());
}
}
use of org.infinispan.server.hotrod.test.TestResponse in project infinispan by infinispan.
the class HotRodFunctionalTest method testRemoveIfUnmodifiedNotExecuted.
public void testRemoveIfUnmodifiedNotExecuted(Method m) {
client().assertPut(m);
TestGetWithVersionResponse resp = client().getWithVersion(k(m), 0);
assertSuccess(resp, v(m), 0);
TestResponse resp2 = client().replaceIfUnmodified(k(m), 0, 0, v(m, "v1-"), resp.dataVersion);
assertStatus(resp2, Success);
TestGetWithVersionResponse resp3 = client().getWithVersion(k(m), 0);
assertSuccess(resp3, v(m, "v1-"), 0);
assertTrue(resp.dataVersion != resp3.dataVersion);
TestResponse resp4 = client().removeIfUnmodified(k(m), 0, 0, v(m, "v2-"), resp.dataVersion);
assertStatus(resp4, OperationNotExecuted);
TestResponse resp5 = client().removeIfUnmodified(k(m), 0, 0, v(m, "v2-"), resp3.dataVersion);
assertStatus(resp5, Success);
}
use of org.infinispan.server.hotrod.test.TestResponse in project infinispan by infinispan.
the class HotRodFunctionalTest method testRemoveIfUmodifiedWithPreviousValue.
public void testRemoveIfUmodifiedWithPreviousValue(Method m) {
TestResponse resp = client().removeIfUnmodified(k(m), 999, 0);
assertStatus(resp, KeyDoesNotExist);
client().assertPut(m);
TestGetWithVersionResponse getResp = client().getWithVersion(k(m), 0);
assertSuccess(getResp, v(m), 0);
TestResponseWithPrevious resp2 = (TestResponseWithPrevious) client().removeIfUnmodified(k(m), 888, 1);
assertNotExecutedPrevious(resp2, v(m));
TestResponseWithPrevious resp3 = (TestResponseWithPrevious) client().removeIfUnmodified(k(m), getResp.dataVersion, 1);
assertSuccessPrevious(resp3, v(m));
}
Aggregations