Skip to content

Commit

Permalink
Attempt to fix cluster cleanup before/after prefix test
Browse files Browse the repository at this point in the history
  • Loading branch information
R-J Lim committed Mar 18, 2024
1 parent 02b8ba9 commit 66f6336
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package redis.clients.jedis.prefix;

import org.junit.BeforeClass;
import redis.clients.jedis.HostAndPorts;
import redis.clients.jedis.util.prefix.ClusterCommandObjectsWithPrefixedKeys;
import redis.clients.jedis.ConnectionPoolConfig;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.args.ClusterResetType;
import redis.clients.jedis.providers.ClusterConnectionProvider;
import redis.clients.jedis.util.JedisClusterTestUtil;

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

@BeforeClass
public static void setUpClass() {
Jedis jedis = new Jedis(HOST_AND_PORT);
jedis.auth("cluster");
jedis.clusterReset(ClusterResetType.HARD);
jedis.flushAll();

int[] slots = new int[Protocol.CLUSTER_HASHSLOTS];

for (int i = 0; i < Protocol.CLUSTER_HASHSLOTS; ++i) {
slots[i] = i;
}

jedis.clusterAddSlots(slots);

try {
JedisClusterTestUtil.waitForClusterReady(jedis);
} catch (InterruptedException e) {
throw new RuntimeException(e);
@Override
protected void flush() {
try (Jedis jedis = new Jedis(HOST_AND_PORT)) {
jedis.auth("cluster");
jedis.flushAll();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class PrefixedKeysTest {

abstract UnifiedJedis nonPrefixingJedis();

private void flush() {
protected void flush() {
try (UnifiedJedis jedis = prefixingJedis()) {
jedis.flushAll();
}
Expand Down

0 comments on commit 66f6336

Please sign in to comment.