From d02d95a7cf3e5d67555400a020f20e36b39097c5 Mon Sep 17 00:00:00 2001 From: Jens Deppe Date: Thu, 9 Dec 2021 09:13:40 -0800 Subject: [PATCH] GEODE-9870: Avoid Radish MOVED error during flushAll in AuthWhileServersRestartDUnitTest (#7171) - Since servers have been stopped and restarted, as part of the test, buckets may be moving. Occasionally this may still be the case when the test is done and flushAll is cleaning up. To avoid that, make sure that everything is rebalanced before flushAll is called. --- .../dunit/rules/RedisClusterStartupRule.java | 17 +++++++++++++++++ .../auth/AuthWhileServersRestartDUnitTest.java | 3 +++ 2 files changed, 20 insertions(+) diff --git a/geode-for-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java b/geode-for-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java index ad045efbda2e..696788973dd9 100644 --- a/geode-for-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java +++ b/geode-for-redis/src/commonTest/java/org/apache/geode/test/dunit/rules/RedisClusterStartupRule.java @@ -30,6 +30,8 @@ import redis.clients.jedis.Jedis; import org.apache.geode.cache.Region; +import org.apache.geode.cache.control.RebalanceFactory; +import org.apache.geode.cache.control.ResourceManager; import org.apache.geode.cache.partition.PartitionRegionHelper; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.logging.internal.log4j.api.FastLogger; @@ -253,4 +255,19 @@ public String getKeyOnServer(String keyPrefix, int vmId) { }); } + /** + * Rebalance all regions for the cluster. This implicitly uses VM1. + */ + public void rebalanceAllRegions() { + getMember(1).invoke("Running rebalance", () -> { + ResourceManager manager = ClusterStartupRule.getCache().getResourceManager(); + RebalanceFactory factory = manager.createRebalanceFactory(); + try { + factory.start().getResults(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }); + } + } diff --git a/geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/executor/auth/AuthWhileServersRestartDUnitTest.java b/geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/executor/auth/AuthWhileServersRestartDUnitTest.java index bbe00012769d..22f3c1e5e6b8 100644 --- a/geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/executor/auth/AuthWhileServersRestartDUnitTest.java +++ b/geode-for-redis/src/distributedTest/java/org/apache/geode/redis/internal/executor/auth/AuthWhileServersRestartDUnitTest.java @@ -85,6 +85,9 @@ public static void classSetup() { @After public void after() { + // Make sure that no buckets are moving before calling flushAll, otherwise we might get + // a MOVED exception. + clusterStartUp.rebalanceAllRegions(); clusterStartUp.flushAll("data", "data"); }