Skip to content

Commit 66f6336

Browse files
author
R-J Lim
committed
Attempt to fix cluster cleanup before/after prefix test
1 parent 02b8ba9 commit 66f6336

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

src/test/java/redis/clients/jedis/prefix/JedisClusterPrefixedKeysTest.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package redis.clients.jedis.prefix;
22

3-
import org.junit.BeforeClass;
43
import redis.clients.jedis.HostAndPorts;
54
import redis.clients.jedis.util.prefix.ClusterCommandObjectsWithPrefixedKeys;
65
import redis.clients.jedis.ConnectionPoolConfig;
76
import redis.clients.jedis.DefaultJedisClientConfig;
87
import redis.clients.jedis.HostAndPort;
98
import redis.clients.jedis.Jedis;
109
import redis.clients.jedis.JedisCluster;
11-
import redis.clients.jedis.Protocol;
1210
import redis.clients.jedis.UnifiedJedis;
13-
import redis.clients.jedis.args.ClusterResetType;
1411
import redis.clients.jedis.providers.ClusterConnectionProvider;
15-
import redis.clients.jedis.util.JedisClusterTestUtil;
1612

1713
import java.time.Duration;
1814
import java.util.Collections;
@@ -22,27 +18,13 @@ public class JedisClusterPrefixedKeysTest extends PrefixedKeysTest {
2218
private static final int DEFAULT_TIMEOUT = 2000;
2319
private static final int DEFAULT_REDIRECTIONS = 5;
2420
private static final ConnectionPoolConfig DEFAULT_POOL_CONFIG = new ConnectionPoolConfig();
25-
private static final HostAndPort HOST_AND_PORT = HostAndPorts.getClusterServers().get(0);
21+
private static final HostAndPort HOST_AND_PORT = HostAndPorts.getStableClusterServers().get(0);
2622

27-
@BeforeClass
28-
public static void setUpClass() {
29-
Jedis jedis = new Jedis(HOST_AND_PORT);
30-
jedis.auth("cluster");
31-
jedis.clusterReset(ClusterResetType.HARD);
32-
jedis.flushAll();
33-
34-
int[] slots = new int[Protocol.CLUSTER_HASHSLOTS];
35-
36-
for (int i = 0; i < Protocol.CLUSTER_HASHSLOTS; ++i) {
37-
slots[i] = i;
38-
}
39-
40-
jedis.clusterAddSlots(slots);
41-
42-
try {
43-
JedisClusterTestUtil.waitForClusterReady(jedis);
44-
} catch (InterruptedException e) {
45-
throw new RuntimeException(e);
23+
@Override
24+
protected void flush() {
25+
try (Jedis jedis = new Jedis(HOST_AND_PORT)) {
26+
jedis.auth("cluster");
27+
jedis.flushAll();
4628
}
4729
}
4830

src/test/java/redis/clients/jedis/prefix/PrefixedKeysTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class PrefixedKeysTest {
1818

1919
abstract UnifiedJedis nonPrefixingJedis();
2020

21-
private void flush() {
21+
protected void flush() {
2222
try (UnifiedJedis jedis = prefixingJedis()) {
2323
jedis.flushAll();
2424
}

0 commit comments

Comments
 (0)