diff --git a/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java b/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java index 23c5cfa9..a099bc40 100644 --- a/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java +++ b/src/main/java/io/vertx/redis/client/impl/RedisClusterConnection.java @@ -141,7 +141,7 @@ public Future send(Request request) { // can run anywhere if (REDUCERS.containsKey(cmd)) { sendToAllSlots(promise, req, cmd, args, forceMasterEndpoint, REDUCERS.get(cmd)); - } else if(cmd.equals(SCRIPT) && Arrays.equals(args.get(0), "LOAD".getBytes())) { + } else if(cmd.equals(SCRIPT) && "LOAD".equalsIgnoreCase(new String(args.get(0)))) { sendToAllSlots(promise, req, cmd, args, forceMasterEndpoint, responses -> { // all nodes should compute the same sha assert responses.stream().map(Response::toString).collect(Collectors.toSet()).size() == 1; diff --git a/src/test/java/io/vertx/redis/client/test/RedisClusterTest.java b/src/test/java/io/vertx/redis/client/test/RedisClusterTest.java index e6e6f231..045efbe3 100644 --- a/src/test/java/io/vertx/redis/client/test/RedisClusterTest.java +++ b/src/test/java/io/vertx/redis/client/test/RedisClusterTest.java @@ -14,6 +14,7 @@ import org.junit.runner.RunWith; import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -26,25 +27,28 @@ public class RedisClusterTest { @ClassRule - public static final GenericContainer redis = new FixedHostPortGenericContainer<>("grokzen/redis-cluster:6.2.0") + public static final GenericContainer redis = new FixedHostPortGenericContainer<>("grokzen/redis-cluster:6.2.11") + .withAccessToHost(true) .withEnv("IP", "0.0.0.0") .withEnv("STANDALONE", "true") .withEnv("SENTINEL", "true") - .withExposedPorts(7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 5000, 5001, 5002) - // cluster ports (7000-7005) 6x (master+replica) 3 nodes - .withFixedExposedPort(7000, 7000) - .withFixedExposedPort(7001, 7001) - .withFixedExposedPort(7002, 7002) - .withFixedExposedPort(7003, 7003) - .withFixedExposedPort(7004, 7004) - .withFixedExposedPort(7005, 7005) - // standalone ports (7006-7007) 2x - .withFixedExposedPort(7006, 7006) - .withFixedExposedPort(7007, 7007) + .withEnv("INITIAL_PORT", "48000") + .waitingFor(Wait.forLogMessage(".*Cluster state changed: ok\\n", 3)) + .withExposedPorts(48000, 48001, 48002, 48003, 48004, 48005, 48006, 48007, 55465, 55466, 55467) + // cluster ports (48000-48005) 6x (master+replica) 3 nodes + .withFixedExposedPort(48000, 48000) + .withFixedExposedPort(48001, 48001) + .withFixedExposedPort(48002, 48002) + .withFixedExposedPort(48003, 48003) + .withFixedExposedPort(48004, 48004) + .withFixedExposedPort(48005, 48005) + // standalone ports (48006-48007) 2x + .withFixedExposedPort(48006, 48006) + .withFixedExposedPort(48007, 48007) // sentinel ports (5000-5002) 3x (match the cluster master nodes) - .withFixedExposedPort(5000, 5000) - .withFixedExposedPort(5001, 5001) - .withFixedExposedPort(5002, 5002); + .withFixedExposedPort(55465, 55465) + .withFixedExposedPort(55466, 55466) + .withFixedExposedPort(55467, 55467); @Rule @@ -56,12 +60,12 @@ public class RedisClusterTest { .setUseReplicas(RedisReplicas.SHARE) // we will flood the redis server .setMaxWaitingHandlers(128 * 1024) - .addConnectionString("redis://127.0.0.1:7000") - .addConnectionString("redis://127.0.0.1:7001") - .addConnectionString("redis://127.0.0.1:7002") - .addConnectionString("redis://127.0.0.1:7003") - .addConnectionString("redis://127.0.0.1:7004") - .addConnectionString("redis://127.0.0.1:7005") + .addConnectionString("redis://127.0.0.1:48000") + .addConnectionString("redis://127.0.0.1:48001") + .addConnectionString("redis://127.0.0.1:48002") + .addConnectionString("redis://127.0.0.1:48003") + .addConnectionString("redis://127.0.0.1:48004") + .addConnectionString("redis://127.0.0.1:48005") .setMaxPoolSize(8) .setMaxPoolWaiting(16) .setHashSlotCacheTTL(10_000); @@ -1244,7 +1248,7 @@ public void testScriptLoadRunsOnEveryMaster(TestContext should) { cluster.exceptionHandler(should::fail); Future<@Nullable Response> setFuture1 = cluster.send(cmd(SET).arg(key1).arg(argv1)); Future<@Nullable Response> setFuture2 = cluster.send(cmd(SET).arg(key2).arg(argv2)); - Future<@Nullable Response> scriptLoadFuture = cluster.send(cmd(SCRIPT).arg("LOAD").arg(script)); + Future<@Nullable Response> scriptLoadFuture = cluster.send(cmd(SCRIPT).arg("load").arg(script)); return Future.all(setFuture1, setFuture2, scriptLoadFuture) .compose(compositeRet -> {