Skip to content

Commit

Permalink
Fixes matching for a lowercase subcommand
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kubovic <[email protected]>
  • Loading branch information
MichaelKubovic committed Nov 21, 2023
1 parent 0244b96 commit 191f7ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Future<Response> 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;
Expand Down
48 changes: 26 additions & 22 deletions src/test/java/io/vertx/redis/client/test/RedisClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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 -> {
Expand Down

0 comments on commit 191f7ed

Please sign in to comment.