Skip to content

Commit

Permalink
Reenable clustering tests (#3764)
Browse files Browse the repository at this point in the history
* Reenable clustering tests

Uncomment clustering tests and adapt the code in the minimum possible
way to make these tests run.

* Include RESP protocol in cluster tests

The cluster tests were not using the configured RESP protocol, so adjust
that.

* Use a separate cluster for the bulk of clustering tests

Most of the clustering tests don't need to change the structure of the
cluster. Use for these tests a stable cluster, that is configured
outside the Java code and keeps its structure. The tests only flush the
data on the cluster nodes, which is safe and fast.

* Don't stunnel the stable cluster nodes

Co-authored-by: M Sazzadul Hoque <[email protected]>

* Move port range for stable cluster

* Move some tests into subclasses

The goal is to leave unchanged the top level test classes.

---------

Co-authored-by: Gabriel Erzse <[email protected]>
Co-authored-by: M Sazzadul Hoque <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent 5733cd6 commit d41dbe9
Show file tree
Hide file tree
Showing 12 changed files with 1,448 additions and 1,354 deletions.
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,50 @@ cluster-enabled yes
cluster-config-file /tmp/redis_cluster_node5.conf
endef

# STABLE CLUSTER REDIS NODES
# The structure of this cluster is not changed by the tests!
define REDIS_STABLE_CLUSTER_NODE1_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7479
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node1.pid
logfile /tmp/redis_stable_cluster_node1.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node1.conf
endef

define REDIS_STABLE_CLUSTER_NODE2_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7480
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node2.pid
logfile /tmp/redis_stable_cluster_node2.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node2.conf
endef

define REDIS_STABLE_CLUSTER_NODE3_CONF
daemonize yes
protected-mode no
requirepass cluster
port 7481
cluster-node-timeout 15000
pidfile /tmp/redis_stable_cluster_node3.pid
logfile /tmp/redis_stable_cluster_node3.log
save ""
appendonly no
cluster-enabled yes
cluster-config-file /tmp/redis_stable_cluster_node3.conf
endef

# UDS REDIS NODES
define REDIS_UDS
daemonize yes
Expand Down Expand Up @@ -355,6 +399,9 @@ export REDIS_CLUSTER_NODE2_CONF
export REDIS_CLUSTER_NODE3_CONF
export REDIS_CLUSTER_NODE4_CONF
export REDIS_CLUSTER_NODE5_CONF
export REDIS_STABLE_CLUSTER_NODE1_CONF
export REDIS_STABLE_CLUSTER_NODE2_CONF
export REDIS_STABLE_CLUSTER_NODE3_CONF
export REDIS_UDS
export REDIS_UNAVAILABLE_CONF
export STUNNEL_CONF
Expand Down Expand Up @@ -393,8 +440,12 @@ start: stunnel cleanup
echo "$$REDIS_CLUSTER_NODE3_CONF" | redis-server -
echo "$$REDIS_CLUSTER_NODE4_CONF" | redis-server -
echo "$$REDIS_CLUSTER_NODE5_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE1_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE2_CONF" | redis-server -
echo "$$REDIS_STABLE_CLUSTER_NODE3_CONF" | redis-server -
echo "$$REDIS_UDS" | redis-server -
echo "$$REDIS_UNAVAILABLE_CONF" | redis-server -
redis-cli -a cluster --cluster create 127.0.0.1:7479 127.0.0.1:7480 127.0.0.1:7481 --cluster-yes

cleanup:
- rm -vf /tmp/redis_cluster_node*.conf 2>/dev/null
Expand Down Expand Up @@ -426,6 +477,9 @@ stop:
kill `cat /tmp/redis_cluster_node3.pid` || true
kill `cat /tmp/redis_cluster_node4.pid` || true
kill `cat /tmp/redis_cluster_node5.pid` || true
kill `cat /tmp/redis_stable_cluster_node1.pid`
kill `cat /tmp/redis_stable_cluster_node2.pid`
kill `cat /tmp/redis_stable_cluster_node3.pid`
kill `cat /tmp/redis_uds.pid` || true
kill `cat /tmp/stunnel.pid` || true
[ -f /tmp/redis_unavailable.pid ] && kill `cat /tmp/redis_unavailable.pid` || true
Expand All @@ -439,6 +493,9 @@ stop:
rm -f /tmp/redis_cluster_node3.conf
rm -f /tmp/redis_cluster_node4.conf
rm -f /tmp/redis_cluster_node5.conf
rm -f /tmp/redis_stable_cluster_node1.conf
rm -f /tmp/redis_stable_cluster_node2.conf
rm -f /tmp/redis_stable_cluster_node3.conf

test: compile-module start
sleep 2
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/redis/clients/jedis/HostAndPorts.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public final class HostAndPorts {
private static List<HostAndPort> redisHostAndPortList = new ArrayList<>();
private static List<HostAndPort> sentinelHostAndPortList = new ArrayList<>();
private static List<HostAndPort> clusterHostAndPortList = new ArrayList<>();
private static List<HostAndPort> stableClusterHostAndPortList = new ArrayList<>();

static {
redisHostAndPortList.add(new HostAndPort("localhost", Protocol.DEFAULT_PORT));
Expand All @@ -34,6 +35,10 @@ public final class HostAndPorts {
clusterHostAndPortList.add(new HostAndPort("localhost", 7382));
clusterHostAndPortList.add(new HostAndPort("localhost", 7383));
clusterHostAndPortList.add(new HostAndPort("localhost", 7384));

stableClusterHostAndPortList.add(new HostAndPort("localhost", 7479));
stableClusterHostAndPortList.add(new HostAndPort("localhost", 7480));
stableClusterHostAndPortList.add(new HostAndPort("localhost", 7481));
}

public static List<HostAndPort> parseHosts(String envHosts,
Expand Down Expand Up @@ -71,6 +76,10 @@ public static List<HostAndPort> getClusterServers() {
return clusterHostAndPortList;
}

public static List<HostAndPort> getStableClusterServers() {
return stableClusterHostAndPortList;
}

private HostAndPorts() {
throw new InstantiationError("Must not instantiate this class");
}
Expand Down
Loading

0 comments on commit d41dbe9

Please sign in to comment.