You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2021/05/11 15:01:34 UTC
[geode] branch develop updated: GEODE-9220: Switch Redis key tests
to use JedisCluster (#6447)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 88db085 GEODE-9220: Switch Redis key tests to use JedisCluster (#6447)
88db085 is described below
commit 88db085fcc453893cccc2d606521e84da2068935
Author: Jens Deppe <jd...@vmware.com>
AuthorDate: Tue May 11 08:00:21 2021 -0700
GEODE-9220: Switch Redis key tests to use JedisCluster (#6447)
---
.../executor/key/DelNativeRedisAcceptanceTest.java | 11 +-
.../key/ExistsNativeRedisAcceptanceTest.java | 11 +-
.../key/ExpireAtNativeRedisAcceptanceTest.java | 11 +-
.../key/ExpireNativeRedisAcceptanceTest.java | 11 +-
.../key/KeysNativeRedisAcceptanceTest.java | 10 +-
.../key/PExpireAtNativeRedisAcceptanceTest.java | 11 +-
.../key/PTTLNativeRedisAcceptanceTest.java | 11 +-
.../key/PersistNativeRedisAcceptanceTest.java | 11 +-
.../key/PexpireNativeRedisAcceptanceTest.java | 11 +-
.../key/RenameNativeRedisAcceptanceTest.java | 11 +-
.../key/ScanNativeRedisAcceptanceTest.java | 11 +-
.../executor/key/TTLNativeRedisAcceptanceTest.java | 11 +-
.../key/TypeNativeRedisAcceptanceTest.java | 11 +-
.../key/UnlinkNativeRedisAcceptanceTest.java | 11 +-
.../executor/key/AbstractDelIntegrationTest.java | 21 ++--
.../key/AbstractExistsIntegrationTest.java | 28 ++---
.../key/AbstractExpireAtIntegrationTest.java | 14 ++-
.../key/AbstractExpireIntegrationTest.java | 43 +++----
.../executor/key/AbstractKeysIntegrationTest.java | 76 ++++++------
.../key/AbstractPExpireAtIntegrationTest.java | 17 ++-
.../executor/key/AbstractPTTLIntegrationTest.java | 9 +-
.../key/AbstractPersistIntegrationTest.java | 18 ++-
.../key/AbstractPexpireIntegrationTest.java | 20 +--
.../key/AbstractRenameIntegrationTest.java | 107 +++++++---------
.../executor/key/AbstractScanIntegrationTest.java | 135 +++++++++++----------
.../executor/key/AbstractTTLIntegrationTest.java | 9 +-
.../executor/key/AbstractTypeIntegrationTest.java | 9 +-
.../key/AbstractUnlinkIntegrationTest.java | 21 ++--
.../internal/executor/key/ScanIntegrationTest.java | 11 +-
29 files changed, 374 insertions(+), 317 deletions(-)
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/DelNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/DelNativeRedisAcceptanceTest.java
index 8dc5c31..3326ea4 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/DelNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/DelNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class DelNativeRedisAcceptanceTest extends AbstractDelIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExistsNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExistsNativeRedisAcceptanceTest.java
index 39c1b43..0412404 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExistsNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExistsNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class ExistsNativeRedisAcceptanceTest extends AbstractExistsIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireAtNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireAtNativeRedisAcceptanceTest.java
index b818312..dab9c71 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireAtNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireAtNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class ExpireAtNativeRedisAcceptanceTest extends AbstractExpireAtIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireNativeRedisAcceptanceTest.java
index fe78931..99c0d73 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ExpireNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class ExpireNativeRedisAcceptanceTest extends AbstractExpireIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/KeysNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/KeysNativeRedisAcceptanceTest.java
index bdc7b7d..09c1d4f 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/KeysNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/KeysNativeRedisAcceptanceTest.java
@@ -17,16 +17,20 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class KeysNativeRedisAcceptanceTest extends AbstractKeysIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
}
+ @Override
+ public void flushAll() {
+ redis.flushAll();
+ }
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PExpireAtNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PExpireAtNativeRedisAcceptanceTest.java
index 8c50110..6e6de8b 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PExpireAtNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PExpireAtNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class PExpireAtNativeRedisAcceptanceTest extends AbstractPExpireAtIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PTTLNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PTTLNativeRedisAcceptanceTest.java
index 67817da..95af919 100755
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PTTLNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PTTLNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class PTTLNativeRedisAcceptanceTest extends AbstractPTTLIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PersistNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PersistNativeRedisAcceptanceTest.java
index 906310a..a723b73 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PersistNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PersistNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class PersistNativeRedisAcceptanceTest extends AbstractPersistIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PexpireNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PexpireNativeRedisAcceptanceTest.java
index de7b3f4..79be586 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PexpireNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/PexpireNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class PexpireNativeRedisAcceptanceTest extends AbstractPexpireIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/RenameNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/RenameNativeRedisAcceptanceTest.java
index 803f776..b339b1c 100755
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/RenameNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/RenameNativeRedisAcceptanceTest.java
@@ -16,16 +16,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class RenameNativeRedisAcceptanceTest extends AbstractRenameIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ScanNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ScanNativeRedisAcceptanceTest.java
index 237d691..8285936 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ScanNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/ScanNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class ScanNativeRedisAcceptanceTest extends AbstractScanIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TTLNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TTLNativeRedisAcceptanceTest.java
index 614e61b..ce2b34c 100755
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TTLNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TTLNativeRedisAcceptanceTest.java
@@ -16,15 +16,20 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class TTLNativeRedisAcceptanceTest extends AbstractTTLIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TypeNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TypeNativeRedisAcceptanceTest.java
index 5f6e647..0556413 100755
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TypeNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/TypeNativeRedisAcceptanceTest.java
@@ -16,15 +16,20 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class TypeNativeRedisAcceptanceTest extends AbstractTypeIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/UnlinkNativeRedisAcceptanceTest.java b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/UnlinkNativeRedisAcceptanceTest.java
index 748ae1c..f3f1274 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/UnlinkNativeRedisAcceptanceTest.java
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/java/org/apache/geode/redis/internal/executor/key/UnlinkNativeRedisAcceptanceTest.java
@@ -17,16 +17,21 @@ package org.apache.geode.redis.internal.executor.key;
import org.junit.ClassRule;
-import org.apache.geode.NativeRedisTestRule;
+import org.apache.geode.redis.NativeRedisClusterTestRule;
public class UnlinkNativeRedisAcceptanceTest extends AbstractUnlinkIntegrationTest {
@ClassRule
- public static NativeRedisTestRule redis = new NativeRedisTestRule();
+ public static NativeRedisClusterTestRule redis = new NativeRedisClusterTestRule();
@Override
public int getPort() {
- return redis.getPort();
+ return redis.getExposedPorts().get(0);
+ }
+
+ @Override
+ public void flushAll() {
+ redis.flushAll();
}
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractDelIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractDelIntegrationTest.java
index f5dd19a..e9ec556 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractDelIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractDelIntegrationTest.java
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicLong;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.ConcurrentLoopingThreads;
@@ -32,22 +33,19 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractDelIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
- private Jedis jedis2;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
- jedis2.close();
}
@Test
@@ -73,9 +71,9 @@ public abstract class AbstractDelIntegrationTest implements RedisIntegrationTest
@Test
public void testDel_deletingMultipleKeys_returnsCountOfOnlyDeletedKeys() {
- String key1 = "firstKey";
- String key2 = "secondKey";
- String key3 = "thirdKey";
+ String key1 = "{user1}firstKey";
+ String key2 = "{user1}secondKey";
+ String key3 = "{user1}thirdKey";
jedis.set(key1, "value1");
jedis.set(key2, "value2");
@@ -97,10 +95,9 @@ public abstract class AbstractDelIntegrationTest implements RedisIntegrationTest
AtomicLong deletedCount = new AtomicLong();
new ConcurrentLoopingThreads(ITERATION_COUNT,
(i) -> deletedCount.addAndGet(jedis.del(keyBaseName + i)),
- (i) -> deletedCount.addAndGet(jedis2.del(keyBaseName + i)))
+ (i) -> deletedCount.addAndGet(jedis.del(keyBaseName + i)))
.run();
-
assertThat(deletedCount.get()).isEqualTo(ITERATION_COUNT);
for (int i = 0; i < ITERATION_COUNT; i++) {
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExistsIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExistsIntegrationTest.java
index 1901618..b07631a 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExistsIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExistsIntegrationTest.java
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicLong;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.ConcurrentLoopingThreads;
@@ -32,25 +33,19 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractExistsIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
- private Jedis jedis2;
- private Jedis jedis3;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis3 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
- jedis2.close();
- jedis3.close();
}
@Test
@@ -151,13 +146,14 @@ public abstract class AbstractExistsIntegrationTest implements RedisIntegrationT
@Test
public void shouldReturnTotalNumber_givenMultipleKeys() {
- String key1 = "key1";
- String key2 = "key2";
+ String key1 = "{user1}key1";
+ String key2 = "{user1}key2";
jedis.set(key1, "value1");
jedis.set(key2, "value2");
- assertThat(jedis.exists(toArray(key1, "doesNotExist1", key2, "doesNotExist2"))).isEqualTo(2L);
+ assertThat(jedis.exists(toArray(key1, "{user1}doesNotExist1", key2, "{user1}doesNotExist2")))
+ .isEqualTo(2L);
}
@Test
@@ -170,7 +166,7 @@ public abstract class AbstractExistsIntegrationTest implements RedisIntegrationT
new ConcurrentLoopingThreads(
iterationCount,
(i) -> existsCount.addAndGet(jedis.exists(toArray("key" + i))),
- (i) -> existsCount.addAndGet(jedis2.exists(toArray("key" + i))))
+ (i) -> existsCount.addAndGet(jedis.exists(toArray("key" + i))))
.run();
assertThat(existsCount.get()).isEqualTo(2 * iterationCount);
@@ -183,8 +179,8 @@ public abstract class AbstractExistsIntegrationTest implements RedisIntegrationT
new ConcurrentLoopingThreads(
iterationCount,
(i) -> jedis.set("key", "value"),
- (i) -> jedis2.exists(toArray("key")),
- (i) -> jedis3.del("key"))
+ (i) -> jedis.exists(toArray("key")),
+ (i) -> jedis.del("key"))
.run();
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireAtIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireAtIntegrationTest.java
index e5ca4aa..1e766c7 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireAtIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireAtIntegrationTest.java
@@ -23,7 +23,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -31,7 +32,7 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractExpireAtIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
private static final String key = "key";
@@ -41,13 +42,13 @@ public abstract class AbstractExpireAtIntegrationTest implements RedisIntegratio
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
unixTimeStampInTheFutureInSeconds = (System.currentTimeMillis() / 1000) + 60;
}
@After
public void testLevelTearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
@@ -58,8 +59,9 @@ public abstract class AbstractExpireAtIntegrationTest implements RedisIntegratio
@Test
public void givenInvalidTimestamp_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.EXPIREAT, "key", "notInteger"))
- .hasMessageContaining(ERROR_NOT_INTEGER);
+ assertThatThrownBy(
+ () -> jedis.sendCommand("key", Protocol.Command.EXPIREAT, "key", "notInteger"))
+ .hasMessageContaining(ERROR_NOT_INTEGER);
}
@Test
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireIntegrationTest.java
index 4aaa798..67a2619 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractExpireIntegrationTest.java
@@ -23,7 +23,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -31,18 +32,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractExpireIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
- public void flushAll() {
- jedis.flushAll();
+ public void tearDown() {
+ flushAll();
jedis.close();
}
@@ -53,7 +54,7 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void givenInvalidTimestamp_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.EXPIRE, "key", "notInteger"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.EXPIRE, "key", "notInteger"))
.hasMessageContaining(ERROR_NOT_INTEGER);
}
@@ -178,9 +179,9 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingSDIFFSTOREonExistingKey_ShouldClearExpirationTime() {
- String key1 = "key1";
- String key2 = "key2";
- String key3 = "key3";
+ String key1 = "{user1}key1";
+ String key2 = "{user1}key2";
+ String key3 = "{user1}key3";
String value1 = "value1";
String value2 = "value2";
String value3 = "value3";
@@ -201,9 +202,9 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingSINTERSTOREonExistingKey_ShouldClearExpirationTime() {
- String key1 = "key1";
- String key2 = "key2";
- String key3 = "key3";
+ String key1 = "{user1}key1";
+ String key2 = "{user1}key2";
+ String key3 = "{user1}key3";
String value1 = "value1";
String value2 = "value2";
String value3 = "value3";
@@ -224,9 +225,9 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingSUNIONSTOREonExistingKey_ShouldClearExpirationTime() {
- String key1 = "key1";
- String key2 = "key2";
- String key3 = "key3";
+ String key1 = "{user1}key1";
+ String key2 = "{user1}key2";
+ String key3 = "{user1}key3";
String value1 = "value1";
String value2 = "value2";
String value3 = "value3";
@@ -279,8 +280,8 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingRENAMEonExistingKey_shouldTransferExpirationTimeToNewKeyName_GivenNewName_Not_InUse() {
- String key = "key";
- String newKeyName = "new key name";
+ String key = "{user1}key";
+ String newKeyName = "{user1}new key name";
String value = "value";
jedis.set(key, value);
jedis.expire(key, 20);
@@ -293,8 +294,8 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingRENAMEonExistingKey_shouldTransferExpirationTimeToNewKeyName_GivenNewName_is_InUse_ButNo_ExpirationSet() {
- String key = "key";
- String key2 = "key2";
+ String key = "{user1}key";
+ String key2 = "{user1}key2";
String value = "value";
jedis.set(key, value);
@@ -310,8 +311,8 @@ public abstract class AbstractExpireIntegrationTest implements RedisIntegrationT
@Test
public void callingRENAMEonExistingKey_shouldTransferExpirationTimeToNewKeyName_GivenNewName_is_InUse_AndHas_ExpirationSet() {
- String key = "key";
- String key2 = "key2";
+ String key = "{user1}key";
+ String key2 = "{user1}key2";
String value = "value";
jedis.set(key, value);
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java
index 6e7253f..8e6e6fd 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java
@@ -18,13 +18,14 @@ package org.apache.geode.redis.internal.executor.key;
import static org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertExactNumberOfArgs;
import static org.assertj.core.api.Assertions.assertThat;
-import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -32,18 +33,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractKeysIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
@@ -54,68 +55,71 @@ public abstract class AbstractKeysIntegrationTest implements RedisIntegrationTes
@Test
public void givenSplat_withASCIIdata_returnsExpectedMatches() {
- jedis.set("string1", "v1");
- jedis.sadd("set1", "member1");
- jedis.hset("hash1", "key1", "field1");
- assertThat(jedis.keys("*")).containsExactlyInAnyOrder("string1", "set1", "hash1");
- assertThat(jedis.keys("s*")).containsExactlyInAnyOrder("string1", "set1");
- assertThat(jedis.keys("h*")).containsExactlyInAnyOrder("hash1");
- assertThat(jedis.keys("foo*")).isEmpty();
+ jedis.set("{K}string1", "v1");
+ jedis.sadd("{K}set1", "member1");
+ jedis.hset("{K}hash1", "key1", "field1");
+ assertThat(jedis.keys("{K}*")).containsExactlyInAnyOrder("{K}string1", "{K}set1", "{K}hash1");
+ assertThat(jedis.keys("{K}s*")).containsExactlyInAnyOrder("{K}string1", "{K}set1");
+ assertThat(jedis.keys("{K}h*")).containsExactlyInAnyOrder("{K}hash1");
+ assertThat(jedis.keys("{K}foo*")).isEmpty();
}
@Test
public void givenSplat_withBinaryData_returnsExpectedMatches() {
byte[] stringKey =
- new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 't', 'r', 'i', 'n', 'g', '1'};
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 't', 'r', 'i', 'n', 'g',
+ '1'};
byte[] value = new byte[] {'v', '1'};
jedis.set(stringKey, value);
- byte[] setKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 'e', 't', '1'};
+ byte[] setKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 'e', 't', '1'};
byte[] member = new byte[] {'m', '1'};
jedis.sadd(setKey, member);
- byte[] hashKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h', 'a', 's', 'h', '1'};
- byte[] key = new byte[] {'k', 'e', 'y', '1'};
+ byte[] hashKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h', 'a', 's', 'h', '1'};
+ byte[] key = new byte[] {'{', 1, '}', 'k', 'e', 'y', '1'};
jedis.hset(hashKey, key, value);
- assertThat(jedis.exists(stringKey));
- assertThat(jedis.exists(setKey));
- assertThat(jedis.exists(hashKey));
- assertThat(jedis.keys(new byte[] {'*'})).containsExactlyInAnyOrder(stringKey, setKey, hashKey);
- assertThat(jedis.keys(new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', '*'}))
+ assertThat(jedis.exists(stringKey)).isTrue();
+ assertThat(jedis.exists(setKey)).isTrue();
+ assertThat(jedis.exists(hashKey)).isTrue();
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', '*'})).containsExactlyInAnyOrder(stringKey,
+ setKey, hashKey);
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', '*'}))
.containsExactlyInAnyOrder(stringKey, setKey);
- assertThat(jedis.keys(new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h', '*'}))
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h', '*'}))
.containsExactlyInAnyOrder(hashKey);
- assertThat(jedis.keys(new byte[] {'f', '*'})).isEmpty();
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', 'f', '*'})).isEmpty();
}
@Test
- public void givenBinaryValue_withExactMatch_preservesBinaryData()
- throws UnsupportedEncodingException {
- String chinese_utf16 = "子";
- byte[] utf16encodedBytes = chinese_utf16.getBytes("UTF-16");
+ public void givenBinaryValue_withExactMatch_preservesBinaryData() {
+ String chineseHashTag = "{子}";
+ byte[] utf8encodedBytes = chineseHashTag.getBytes(StandardCharsets.UTF_8);
byte[] stringKey =
new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 't', 'r', 'i', 'n', 'g', '1'};
- byte[] allByteArray = new byte[utf16encodedBytes.length + stringKey.length];
+ byte[] allByteArray = new byte[utf8encodedBytes.length + stringKey.length];
ByteBuffer buff = ByteBuffer.wrap(allByteArray);
- buff.put(utf16encodedBytes);
+ buff.put(utf8encodedBytes);
buff.put(stringKey);
byte[] combined = buff.array();
jedis.set(combined, combined);
- assertThat(jedis.keys("*".getBytes())).containsExactlyInAnyOrder(combined);
+ assertThat(jedis.keys("{子}*".getBytes())).containsExactlyInAnyOrder(combined);
}
@Test
public void givenSplat_withCarriageReturnLineFeedAndTab_returnsExpectedMatches() {
- jedis.set(" foo bar ", "123");
- jedis.set(" foo\r\nbar\r\n ", "456");
- jedis.set(" \r\n\t\\x07\\x13 ", "789");
+ jedis.set("{K} foo bar ", "123");
+ jedis.set("{K} foo\r\nbar\r\n ", "456");
+ jedis.set("{K} \r\n\t\\x07\\x13 ", "789");
- assertThat(jedis.keys("*")).containsExactlyInAnyOrder(" \r\n\t\\x07\\x13 ", " foo\r\nbar\r\n ",
- " foo bar ");
+ assertThat(jedis.keys("{K}*")).containsExactlyInAnyOrder("{K} \r\n\t\\x07\\x13 ",
+ "{K} foo\r\nbar\r\n ", "{K} foo bar ");
}
@Test
public void givenMalformedGlobPattern_returnsEmptySet() {
- assertThat(jedis.keys("[][]")).isEmpty();
+ assertThat(jedis.keys("{K}[][]")).isEmpty();
}
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPExpireAtIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPExpireAtIntegrationTest.java
index 7d843bc..73d3461 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPExpireAtIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPExpireAtIntegrationTest.java
@@ -22,7 +22,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -30,23 +31,20 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractPExpireAtIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
private static final String key = "key";
private static final String value = "value";
- private long unixTimeStampInTheFutureInSeconds;
- private final long unixTimeStampFromThePast = 0L;
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- unixTimeStampInTheFutureInSeconds = (System.currentTimeMillis() / 1000) + 60;
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void testLevelTearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
@@ -57,8 +55,9 @@ public abstract class AbstractPExpireAtIntegrationTest implements RedisIntegrati
@Test
public void givenInvalidTimestamp_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.PEXPIREAT, "key", "notInteger"))
- .hasMessageContaining(ERROR_NOT_INTEGER);
+ assertThatThrownBy(() -> jedis
+ .sendCommand("key", Protocol.Command.PEXPIREAT, "key", "notInteger"))
+ .hasMessageContaining(ERROR_NOT_INTEGER);
}
@Test
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPTTLIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPTTLIntegrationTest.java
index 46affc6..b297330 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPTTLIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPTTLIntegrationTest.java
@@ -21,7 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -29,18 +30,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractPTTLIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPersistIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPersistIntegrationTest.java
index 115d259..0501b8e 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPersistIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPersistIntegrationTest.java
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicLong;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.params.SetParams;
@@ -32,22 +33,19 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractPersistIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
- private Jedis jedis2;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
- jedis2.close();
}
@Test
@@ -118,7 +116,7 @@ public abstract class AbstractPersistIntegrationTest implements RedisIntegration
AtomicLong persistedFromThread2 = new AtomicLong(0);
Runnable runnable1 = () -> persistKeys(persistedFromThread1, jedis, iterationCount);
- Runnable runnable2 = () -> persistKeys(persistedFromThread2, jedis2, iterationCount);
+ Runnable runnable2 = () -> persistKeys(persistedFromThread2, jedis, iterationCount);
Thread thread1 = new Thread(runnable1);
Thread thread2 = new Thread(runnable2);
@@ -131,7 +129,7 @@ public abstract class AbstractPersistIntegrationTest implements RedisIntegration
assertThat(persistedFromThread1.get() + persistedFromThread2.get()).isEqualTo(iterationCount);
}
- private void setKeysWithExpiration(Jedis jedis, int iterationCount) {
+ private void setKeysWithExpiration(JedisCluster jedis, int iterationCount) {
for (int i = 0; i < iterationCount; i++) {
SetParams setParams = new SetParams();
setParams.ex(600);
@@ -140,7 +138,7 @@ public abstract class AbstractPersistIntegrationTest implements RedisIntegration
}
}
- private void persistKeys(AtomicLong atomicLong, Jedis jedis, int iterationCount) {
+ private void persistKeys(AtomicLong atomicLong, JedisCluster jedis, int iterationCount) {
for (int i = 0; i < iterationCount; i++) {
String key = "key" + i;
atomicLong.addAndGet(jedis.persist(key));
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPexpireIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPexpireIntegrationTest.java
index 2b60f18..0e40e68 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPexpireIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractPexpireIntegrationTest.java
@@ -23,7 +23,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -31,18 +32,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractPexpireIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void teardown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
@@ -53,8 +54,9 @@ public abstract class AbstractPexpireIntegrationTest implements RedisIntegration
@Test
public void givenInvalidTimestamp_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.PEXPIRE, "key", "notInteger"))
- .hasMessageContaining(ERROR_NOT_INTEGER);
+ assertThatThrownBy(
+ () -> jedis.sendCommand("key", Protocol.Command.PEXPIRE, "key", "notInteger"))
+ .hasMessageContaining(ERROR_NOT_INTEGER);
}
@Test
@@ -98,9 +100,9 @@ public abstract class AbstractPexpireIntegrationTest implements RedisIntegration
@Test
public void should_passivelyExpireKeys() {
- jedis.sadd("key", "value");
- jedis.pexpire("key", 100);
+ jedis.sadd("{user1}key", "value");
+ jedis.pexpire("{user1}key", 100);
- GeodeAwaitility.await().until(() -> jedis.keys("key").isEmpty());
+ GeodeAwaitility.await().until(() -> jedis.keys("{user1}key").isEmpty());
}
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractRenameIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractRenameIntegrationTest.java
index b9fd724..2c06ec9 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractRenameIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractRenameIntegrationTest.java
@@ -35,7 +35,8 @@ import java.util.concurrent.Future;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.exceptions.JedisDataException;
@@ -48,9 +49,7 @@ import org.apache.geode.redis.internal.executor.SynchronizedStripedExecutor;
import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractRenameIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
- private Jedis jedis2;
- private Jedis jedis3;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
private static Random rand;
@@ -58,17 +57,13 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
@Before
public void setUp() {
rand = new Random();
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis3 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
- jedis2.close();
- jedis3.close();
}
@Test
@@ -78,22 +73,22 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
@Test
public void testNewKey() {
- jedis.set("foo", "bar");
- jedis.rename("foo", "newfoo");
- assertThat(jedis.get("newfoo")).isEqualTo("bar");
+ jedis.set("{user1}foo", "bar");
+ jedis.rename("{user1}foo", "{user1}newfoo");
+ assertThat(jedis.get("{user1}newfoo")).isEqualTo("bar");
}
@Test
public void testOldKeyIsDeleted() {
- jedis.set("foo", "bar");
- jedis.rename("foo", "newfoo");
- assertThat(jedis.get("foo")).isNull();
+ jedis.set("{user1}foo", "bar");
+ jedis.rename("{user1}foo", "{user1}newfoo");
+ assertThat(jedis.get("{user1}foo")).isNull();
}
@Test
public void testRenameKeyThatDoesNotExist() {
try {
- jedis.rename("foo", "newfoo");
+ jedis.rename("{user1}foo", "{user1}newfoo");
} catch (JedisDataException e) {
assertThat(e.getMessage()).contains(RedisConstants.ERROR_NO_SUCH_KEY);
}
@@ -101,37 +96,37 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
@Test
public void testHashMap() {
- jedis.hset("foo", "field", "va");
- jedis.rename("foo", "newfoo");
- assertThat(jedis.hget("newfoo", "field")).isEqualTo("va");
+ jedis.hset("{user1}foo", "field", "va");
+ jedis.rename("{user1}foo", "{user1}newfoo");
+ assertThat(jedis.hget("{user1}newfoo", "field")).isEqualTo("va");
}
@Test
public void testSet() {
- jedis.sadd("foo", "data");
- jedis.rename("foo", "newfoo");
- assertThat(jedis.smembers("newfoo")).contains("data");
+ jedis.sadd("{user1}foo", "data");
+ jedis.rename("{user1}foo", "{user1}newfoo");
+ assertThat(jedis.smembers("{user1}newfoo")).contains("data");
}
@Test
public void testRenameSameKey() {
- jedis.set("blue", "moon");
- assertThat(jedis.rename("blue", "blue")).isEqualTo("OK");
- assertThat(jedis.get("blue")).isEqualTo("moon");
+ jedis.set("{user1}blue", "moon");
+ assertThat(jedis.rename("{user1}blue", "{user1}blue")).isEqualTo("OK");
+ assertThat(jedis.get("{user1}blue")).isEqualTo("moon");
}
@Test
public void testConcurrentSets() throws ExecutionException, InterruptedException {
- Set<String> stringsForK1 = new HashSet<String>();
- Set<String> stringsForK2 = new HashSet<String>();
+ Set<String> stringsForK1 = new HashSet<>();
+ Set<String> stringsForK2 = new HashSet<>();
int numOfStrings = 500000;
Callable<Long> callable1 =
- () -> addStringsToKeys(stringsForK1, "k1", numOfStrings, jedis);
+ () -> addStringsToKeys(stringsForK1, "{user1}k1", numOfStrings, jedis);
int numOfStringsForSecondKey = 30000;
Callable<Long> callable2 =
- () -> addStringsToKeys(stringsForK2, "k2", numOfStringsForSecondKey, jedis2);
- Callable<String> callable3 = () -> renameKeys(jedis3);
+ () -> addStringsToKeys(stringsForK2, "{user1}k2", numOfStringsForSecondKey, jedis);
+ Callable<String> callable3 = () -> jedis.rename("{user1}k1", "{user1}k2");
ExecutorService pool = Executors.newFixedThreadPool(4);
Future<Long> future1 = pool.submit(callable1);
@@ -143,16 +138,13 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
future2.get();
try {
future3.get();
- assertThat(jedis.scard("k2")).isEqualTo(numOfStrings);
- assertThat(jedis.get("k1")).isEqualTo(null);
+ assertThat(jedis.scard("{user1}k2")).isEqualTo(numOfStrings);
+ assertThat(jedis.get("{user1}k1")).isEqualTo(null);
} catch (Exception e) {
assertThat(e.getMessage()).contains(RedisConstants.ERROR_NO_SUCH_KEY);
- assertThat(jedis.scard("k1")).isEqualTo(numOfStrings);
- assertThat(jedis.scard("k2")).isEqualTo(numOfStringsForSecondKey);
+ assertThat(jedis.scard("{user1}k1")).isEqualTo(numOfStrings);
+ assertThat(jedis.scard("{user1}k2")).isEqualTo(numOfStringsForSecondKey);
}
-
- jedis2.close();
- jedis3.close();
}
@Test
@@ -203,18 +195,17 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
ExecutorService pool = Executors.newFixedThreadPool(2);
for (int i = 0; i < 100; i++) {
- jedis.set("oldKey", "foo");
+ jedis.set("{user1}oldKey", "foo");
Runnable renameOldKeyToNewKey = () -> {
cyclicBarrierAwait(startCyclicBarrier);
- jedis.rename("oldKey", "newKey");
+ jedis.rename("{user1}oldKey", "{user1}newKey");
};
Runnable deleteOldKey = () -> {
cyclicBarrierAwait(startCyclicBarrier);
-
- jedis2.del("oldKey");
+ jedis.del("{user1}oldKey");
};
Future<?> future1 = pool.submit(renameOldKeyToNewKey);
@@ -222,13 +213,13 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
try {
future1.get();
- assertThat(jedis.get("newKey")).isEqualTo("foo");
+ assertThat(jedis.get("{user1}newKey")).isEqualTo("foo");
} catch (Exception e) {
assertThat(e).hasMessageContaining("no such key");
}
future2.get();
- assertThat(jedis.get("oldKey")).isNull();
+ assertThat(jedis.get("{user1}oldKey")).isNull();
}
}
@@ -245,14 +236,14 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
}
private List<String> getKeysOnDifferentStripes() {
- String key1 = "keyz" + new Random().nextInt();
+ String key1 = "{user1}keyz" + new Random().nextInt();
RedisKey key1ByteArrayWrapper = new RedisKey(key1.getBytes());
StripedExecutor stripedExecutor = new SynchronizedStripedExecutor();
int iterator = 0;
String key2;
do {
- key2 = "key" + iterator;
+ key2 = "{user1}key" + iterator;
iterator++;
} while (stripedExecutor.compareStripes(key1ByteArrayWrapper,
new ByteArrayWrapper(key2.getBytes())) == 0);
@@ -262,14 +253,14 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
private Set<String> getKeysOnSameRandomStripe(int numKeysNeeded) {
Random random = new Random();
- String key1 = "keyz" + random.nextInt();
+ String key1 = "{user1}keyz" + random.nextInt();
RedisKey key1ByteArrayWrapper = new RedisKey(key1.getBytes());
StripedExecutor stripedExecutor = new SynchronizedStripedExecutor();
Set<String> keys = new HashSet<>();
keys.add(key1);
do {
- String key2 = "key" + random.nextInt();
+ String key2 = "{user1}key" + random.nextInt();
if (stripedExecutor.compareStripes(key1ByteArrayWrapper,
new ByteArrayWrapper(key2.getBytes())) == 0) {
keys.add(key2);
@@ -301,8 +292,7 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
Runnable renameOldKey2ToNewKey2 = () -> {
cyclicBarrierAwait(startCyclicBarrier);
-
- jedis2.rename(oldKey2, newKey2);
+ jedis.rename(oldKey2, newKey2);
};
Future<?> future1 = pool.submit(renameOldKey1ToNewKey1);
@@ -329,12 +319,12 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
String key1;
RedisKey key1ByteArrayWrapper;
do {
- key1 = "keyz" + new Random().nextInt();
+ key1 = "{user1}keyz" + new Random().nextInt();
key1ByteArrayWrapper = new RedisKey(key1.getBytes());
} while (stripedExecutor.compareStripes(key1ByteArrayWrapper, toAvoid) == 0 && keys.add(key1));
do {
- String key2 = "key" + new Random().nextInt();
+ String key2 = "{user1}key" + new Random().nextInt();
if (stripedExecutor.compareStripes(key1ByteArrayWrapper,
new ByteArrayWrapper(key2.getBytes())) == 0) {
@@ -364,7 +354,7 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
Runnable renameKey2ToKey1 = () -> {
cyclicBarrierAwait(startCyclicBarrier);
- jedis2.rename(key2, key1);
+ jedis.rename(key2, key1);
};
Future<?> future1 = pool.submit(renameKey1ToKey2);
@@ -374,20 +364,13 @@ public abstract class AbstractRenameIntegrationTest implements RedisIntegrationT
future2.get();
}
- private Long addStringsToKeys(
- Set<String> strings,
- String key,
- int numOfStrings,
- Jedis client) {
+ private Long addStringsToKeys(Set<String> strings, String key, int numOfStrings,
+ JedisCluster client) {
generateStrings(numOfStrings, strings);
String[] stringArray = strings.toArray(new String[strings.size()]);
return client.sadd(key, stringArray);
}
- private String renameKeys(Jedis client) {
- return client.rename("k1", "k2");
- }
-
private Set<String> generateStrings(int elements, Set<String> strings) {
for (int i = 0; i < elements; i++) {
String elem = String.valueOf(i);
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractScanIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractScanIntegrationTest.java
index e2713ba..8ab119c 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractScanIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractScanIntegrationTest.java
@@ -28,7 +28,8 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult;
@@ -38,89 +39,89 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractScanIntegrationTest implements RedisIntegrationTest {
- protected Jedis jedis;
+ protected JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
@Test
public void givenNoCursorArgument_returnsWrongNumberOfArgsError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN))
.hasMessageContaining("ERR wrong number of arguments for 'scan' command");
}
@Test
public void givenCursorArgumentIsNotAnInteger_returnsCursorError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "sljfs"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "sljfs"))
.hasMessageContaining(ERROR_CURSOR);
}
@Test
public void givenArgumentsAreNotEven_returnsSyntaxError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "a*"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "a*"))
.hasMessageContaining(ERROR_SYNTAX);
}
@Test
public void givenMatchOrCountKeywordNotSpecified_returnsSyntaxError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "a*", "1"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "a*", "1"))
.hasMessageContaining(ERROR_SYNTAX);
}
@Test
public void givenCount_whenCountParameterIsNotAnInteger_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "COUNT", "MATCH"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "COUNT", "MATCH"))
.hasMessageContaining(ERROR_NOT_INTEGER);
}
@Test
public void givenCount_whenCountParameterIsZero_returnsSyntaxError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "COUNT", "0"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "COUNT", "0"))
.hasMessageContaining(ERROR_SYNTAX);
}
@Test
public void givenCount_whenCountParameterIsNegative_returnsSyntaxError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "COUNT", "-37"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "COUNT", "-37"))
.hasMessageContaining(ERROR_SYNTAX);
}
@Test
public void givenMultipleCounts_whenAnyCountParameterIsNotAnInteger_returnsNotIntegerError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "COUNT", "2", "COUNT",
- "sjlfs", "COUNT", "1"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "COUNT", "2",
+ "COUNT", "sjlfs", "COUNT", "1"))
.hasMessageContaining(ERROR_NOT_INTEGER);
}
@Test
public void givenMultipleCounts_whenAnyCountParameterIsLessThanOne_returnsSyntaxError() {
- assertThatThrownBy(() -> jedis.sendCommand(Protocol.Command.SCAN, "0", "COUNT", "2", "COUNT",
- "0", "COUNT", "1"))
+ assertThatThrownBy(() -> jedis.sendCommand("key", Protocol.Command.SCAN, "0", "COUNT", "2",
+ "COUNT", "0", "COUNT", "1"))
.hasMessageContaining(ERROR_SYNTAX);
}
@Test
public void givenOneKeyInRegion_returnsKey() {
- jedis.set("a", "1");
- ScanResult<String> result = jedis.scan("0");
+ jedis.set("{user1}a", "1");
+ ScanResult<String> result = jedis.scan("0", new ScanParams().match("{user1}*"));
assertThat(result.isCompleteIteration()).isTrue();
- assertThat(result.getResult()).containsExactly("a");
+ assertThat(result.getResult()).containsExactly("{user1}a");
}
@Test
public void givenEmptyRegion_returnsEmptyArray() {
- ScanResult<String> result = jedis.scan("0");
+ ScanResult<String> result = jedis.scan("0", new ScanParams().match("{user1}*"));
assertThat(result.isCompleteIteration()).isTrue();
assertThat(result.getResult()).isEmpty();
@@ -128,23 +129,24 @@ public abstract class AbstractScanIntegrationTest implements RedisIntegrationTes
@Test
public void givenMultipleKeysInRegion_returnsAllKeys() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
- ScanResult<String> result = jedis.scan("0");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
+ ScanResult<String> result = jedis.scan("0", new ScanParams().match("{user1}*"));
assertThat(result.isCompleteIteration()).isTrue();
- assertThat(result.getResult()).containsExactlyInAnyOrder("a", "b", "c");
+ assertThat(result.getResult()).containsExactlyInAnyOrder("{user1}a", "{user1}b", "{user1}c");
}
@Test
public void givenCount_returnsAllKeysWithoutDuplicates() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
ScanParams scanParams = new ScanParams();
scanParams.count(1);
+ scanParams.match("{user1}*");
String cursor = "0";
ScanResult<String> result;
List<String> allKeysFromScan = new ArrayList<>();
@@ -155,67 +157,69 @@ public abstract class AbstractScanIntegrationTest implements RedisIntegrationTes
cursor = result.getCursor();
} while (!result.isCompleteIteration());
- assertThat(allKeysFromScan).containsExactlyInAnyOrder("a", "b", "c");
+ assertThat(allKeysFromScan).containsExactlyInAnyOrder("{user1}a", "{user1}b", "{user1}c");
}
@Test
@SuppressWarnings("unchecked")
public void givenMultipleCounts_returnsAllKeysWithoutDuplicates() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
String cursor = "0";
List<Object> result;
List<Object> allKeysFromScan = new ArrayList<>();
do {
- result = (List<Object>) jedis.sendCommand(Protocol.Command.SCAN, cursor, "COUNT", "2",
- "COUNT", "1");
+ result =
+ (List<Object>) jedis.sendCommand("user1", Protocol.Command.SCAN, cursor, "COUNT", "2",
+ "COUNT", "1");
allKeysFromScan.addAll((List<byte[]>) result.get(1));
cursor = new String((byte[]) result.get(0));
} while (!Arrays.equals((byte[]) result.get(0), "0".getBytes()));
assertThat((byte[]) result.get(0)).isEqualTo("0".getBytes());
- assertThat(allKeysFromScan).containsExactlyInAnyOrder("a".getBytes(), "b".getBytes(),
- "c".getBytes());
+ assertThat(allKeysFromScan).containsExactlyInAnyOrder("{user1}a".getBytes(),
+ "{user1}b".getBytes(), "{user1}c".getBytes());
}
@Test
public void givenMatch_returnsAllMatchingKeysWithoutDuplicates() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
ScanParams scanParams = new ScanParams();
- scanParams.match("a*");
+ scanParams.match("{user1}a*");
ScanResult<String> result = jedis.scan("0", scanParams);
assertThat(result.isCompleteIteration()).isTrue();
- assertThat(result.getResult()).containsExactly("a");
+ assertThat(result.getResult()).containsExactly("{user1}a");
}
@Test
@SuppressWarnings("unchecked")
public void givenMultipleMatches_returnsKeysMatchingLastMatchParameter() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
List<Object> result =
- (List<Object>) jedis.sendCommand(Protocol.Command.SCAN, "0", "MATCH", "b*", "MATCH", "a*");
+ (List<Object>) jedis.sendCommand("user1", Protocol.Command.SCAN, "0", "MATCH", "{user1}b*",
+ "MATCH", "{user1}a*");
assertThat((byte[]) result.get(0)).isEqualTo("0".getBytes());
- assertThat((List<byte[]>) result.get(1)).containsExactly("a".getBytes());
+ assertThat((List<byte[]>) result.get(1)).containsExactly("{user1}a".getBytes());
}
@Test
public void givenMatchAndCount_returnsAllMatchingKeysWithoutDuplicates() {
- jedis.set("a", "1");
- jedis.sadd("apple", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}apple", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
ScanParams scanParams = new ScanParams();
- scanParams.match("a*");
+ scanParams.match("{user1}a*");
scanParams.count(1);
String cursor = "0";
@@ -229,58 +233,61 @@ public abstract class AbstractScanIntegrationTest implements RedisIntegrationTes
} while (!result.isCompleteIteration());
assertThat(result.isCompleteIteration()).isTrue();
- assertThat(allKeysFromScan).containsExactlyInAnyOrder("a", "apple");
+ assertThat(allKeysFromScan).containsExactlyInAnyOrder("{user1}a", "{user1}apple");
}
@Test
@SuppressWarnings("unchecked")
public void givenMultipleCountsAndMatches_returnsKeysMatchingLastMatchParameter() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("aardvark", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}aardvark", "potato", "sweet");
String cursor = "0";
List<Object> result;
List<Object> allKeysFromScan = new ArrayList<>();
do {
- result = (List<Object>) jedis.sendCommand(Protocol.Command.SCAN, cursor, "COUNT", "37",
- "MATCH", "b*", "COUNT", "2", "COUNT", "1", "MATCH", "a*");
+ result =
+ (List<Object>) jedis.sendCommand("{user1}", Protocol.Command.SCAN, cursor, "COUNT", "37",
+ "MATCH", "{user1}b*", "COUNT", "2", "COUNT", "1", "MATCH", "{user1}a*");
allKeysFromScan.addAll((List<byte[]>) result.get(1));
cursor = new String((byte[]) result.get(0));
} while (!Arrays.equals((byte[]) result.get(0), "0".getBytes()));
assertThat((byte[]) result.get(0)).isEqualTo("0".getBytes());
- assertThat(allKeysFromScan).containsExactlyInAnyOrder("a".getBytes(), "aardvark".getBytes());
+ assertThat(allKeysFromScan).containsExactlyInAnyOrder("{user1}a".getBytes(),
+ "{user1}aardvark".getBytes());
}
@Test
public void givenNegativeCursor_returnsKeysUsingAbsoluteValueOfCursor() {
- jedis.set("a", "1");
- jedis.sadd("b", "green", "orange");
- jedis.hset("c", "potato", "sweet");
+ jedis.set("{user1}a", "1");
+ jedis.sadd("{user1}b", "green", "orange");
+ jedis.hset("{user1}c", "potato", "sweet");
List<String> allEntries = new ArrayList<>();
String cursor = "-100";
ScanResult<String> result;
do {
- result = jedis.scan(cursor);
+ result = jedis.scan(cursor, new ScanParams().match("{user1}*"));
allEntries.addAll(result.getResult());
cursor = result.getCursor();
} while (!result.isCompleteIteration());
- assertThat(allEntries).containsExactlyInAnyOrder("a", "b", "c");
+ assertThat(allEntries).containsExactlyInAnyOrder("{user1}a", "{user1}b", "{user1}c");
}
@Test
public void givenCursorGreaterThanUnsignedLongCapacity_returnsCursorError() {
- assertThatThrownBy(() -> jedis.scan("18446744073709551616")).hasMessageContaining(ERROR_CURSOR);
+ assertThatThrownBy(() -> jedis.scan("18446744073709551616", new ScanParams().match("{a}*")))
+ .hasMessageContaining(ERROR_CURSOR);
}
@Test
public void givenNegativeCursorGreaterThanUnsignedLongCapacity_returnsCursorError() {
- assertThatThrownBy(() -> jedis.scan("-18446744073709551616"))
+ assertThatThrownBy(() -> jedis.scan("-18446744073709551616", new ScanParams().match("{a}*")))
.hasMessageContaining(ERROR_CURSOR);
}
@@ -288,7 +295,7 @@ public abstract class AbstractScanIntegrationTest implements RedisIntegrationTes
public void givenInvalidRegexSyntax_returnsEmptyArray() {
ScanParams scanParams = new ScanParams();
scanParams.count(1);
- scanParams.match("\\p");
+ scanParams.match("{user1}\\p");
ScanResult<String> result = jedis.scan("0", scanParams);
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTTLIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTTLIntegrationTest.java
index a05a331..a22463e 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTTLIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTTLIntegrationTest.java
@@ -24,7 +24,8 @@ import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -32,18 +33,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractTTLIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTypeIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTypeIntegrationTest.java
index 147c4ae..5a814f2 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTypeIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractTypeIntegrationTest.java
@@ -21,7 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.RedisIntegrationTest;
@@ -29,18 +30,18 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractTypeIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractUnlinkIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractUnlinkIntegrationTest.java
index dfd3275..f2868dd 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractUnlinkIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractUnlinkIntegrationTest.java
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicLong;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import redis.clients.jedis.Jedis;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import org.apache.geode.redis.ConcurrentLoopingThreads;
@@ -32,22 +33,19 @@ import org.apache.geode.test.awaitility.GeodeAwaitility;
public abstract class AbstractUnlinkIntegrationTest implements RedisIntegrationTest {
- private Jedis jedis;
- private Jedis jedis2;
+ private JedisCluster jedis;
private static final int REDIS_CLIENT_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().toMillis());
@Before
public void setUp() {
- jedis = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
- jedis2 = new Jedis("localhost", getPort(), REDIS_CLIENT_TIMEOUT);
+ jedis = new JedisCluster(new HostAndPort("localhost", getPort()), REDIS_CLIENT_TIMEOUT);
}
@After
public void tearDown() {
- jedis.flushAll();
+ flushAll();
jedis.close();
- jedis2.close();
}
@Test
@@ -73,9 +71,9 @@ public abstract class AbstractUnlinkIntegrationTest implements RedisIntegrationT
@Test
public void testUnlink_unlinkingMultipleKeys_returnsCountOfOnlyUnlinkedKeys() {
- String key1 = "firstKey";
- String key2 = "secondKey";
- String key3 = "thirdKey";
+ String key1 = "{user1}firstKey";
+ String key2 = "{user1}secondKey";
+ String key3 = "{user1}thirdKey";
jedis.set(key1, "value1");
jedis.set(key2, "value2");
@@ -97,10 +95,9 @@ public abstract class AbstractUnlinkIntegrationTest implements RedisIntegrationT
AtomicLong unlinkedCount = new AtomicLong();
new ConcurrentLoopingThreads(ITERATION_COUNT,
(i) -> unlinkedCount.addAndGet(jedis.unlink(keyBaseName + i)),
- (i) -> unlinkedCount.addAndGet(jedis2.unlink(keyBaseName + i)))
+ (i) -> unlinkedCount.addAndGet(jedis.unlink(keyBaseName + i)))
.run();
-
assertThat(unlinkedCount.get()).isEqualTo(ITERATION_COUNT);
for (int i = 0; i < ITERATION_COUNT; i++) {
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/ScanIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/ScanIntegrationTest.java
index 08d47a7..4018bdb 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/ScanIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/ScanIntegrationTest.java
@@ -41,16 +41,15 @@ public class ScanIntegrationTest extends AbstractScanIntegrationTest {
public void givenDifferentCursorThanSpecifiedByPreviousScan_returnsAllKeys() {
List<String> keyList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
- jedis.set(String.valueOf(i), "a");
- keyList.add(String.valueOf(i));
+ String key = "{user1}" + i;
+ jedis.set(key, "a");
+ keyList.add(key);
}
- ScanParams scanParams = new ScanParams();
- scanParams.count(5);
- ScanResult<String> result = jedis.scan("0", scanParams);
+ ScanResult<String> result = jedis.scan("0", new ScanParams().count(5).match("{user1}*"));
assertThat(result.isCompleteIteration()).isFalse();
- result = jedis.scan("100");
+ result = jedis.scan("100", new ScanParams().match("{user1}*"));
assertThat(result.getResult()).containsExactlyInAnyOrder(keyList.toArray(new String[0]));
}