Permalink
Browse files

Create redis select (partitions) test

  • Loading branch information...
justinsb committed Dec 16, 2013
1 parent 6c19150 commit 96e26b13bdc83cb1c9071116fa4493133c395a52
Showing with 34 additions and 0 deletions.
  1. +34 −0 cloudata-keyvalue/src/test/java/com/cloudata/keyvalue/RedisIntegrationTest.java
@@ -41,6 +41,40 @@ public void testSetAndGet() throws Exception {
}
}
@Test
public void testPartitions() throws Exception {
int n = 100;
int partitions = 10;
for (int i = 0; i < n; i++) {
byte[] key = Integer.toString(i).getBytes();
byte[] value = buildValue(i);
assertOk(jedis.select(i / 10));
jedis.set(key, value);
}
for (int j = 0; j < partitions; j++) {
for (int i = 0; i < n; i++) {
byte[] key = Integer.toString(i).getBytes();
byte[] value = buildValue(i);
assertOk(jedis.select(j));
byte[] found = jedis.get(key);
if ((i / partitions) == j) {
Assert.assertArrayEquals(value, found);
} else {
Assert.assertNull(found);
}
}
}
}
private void assertOk(String r) {
Assert.assertEquals("OK", r);
}
@Test
public void testAppend() throws Exception {
byte[] key = UUID.randomUUID().toString().getBytes();

0 comments on commit 96e26b1

Please sign in to comment.