From d810b5713f136911445c24cf51ff59cd3550c1db Mon Sep 17 00:00:00 2001 From: jruaux Date: Tue, 11 Jun 2024 15:41:48 -0700 Subject: [PATCH] test: Moved tests to Stack only --- .../test/java/com/redis/riot/RiotTests.java | 93 ------------------ .../java/com/redis/riot/StackRiotTests.java | 94 +++++++++++++++++++ 2 files changed, 94 insertions(+), 93 deletions(-) diff --git a/plugins/riot/src/test/java/com/redis/riot/RiotTests.java b/plugins/riot/src/test/java/com/redis/riot/RiotTests.java index 5312daa0a..2a304c329 100644 --- a/plugins/riot/src/test/java/com/redis/riot/RiotTests.java +++ b/plugins/riot/src/test/java/com/redis/riot/RiotTests.java @@ -5,7 +5,6 @@ import java.time.Duration; import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.concurrent.Executors; import java.util.function.Predicate; @@ -21,7 +20,6 @@ import com.redis.lettucemod.util.RedisModulesUtils; import com.redis.riot.Replicate.CompareMode; import com.redis.riot.core.ProgressStyle; -import com.redis.riot.core.Expression; import com.redis.spring.batch.Range; import com.redis.spring.batch.item.redis.RedisItemReader.ReaderMode; import com.redis.spring.batch.item.redis.common.DataType; @@ -38,45 +36,6 @@ void setDefaults() { setIdleTimeout(Duration.ofSeconds(1)); } - @Test - void replicate(TestInfo info) throws Throwable { - String filename = "replicate"; - generate(info, generator(73)); - Assertions.assertTrue(redisCommands.dbsize() > 0); - execute(info, filename); - assertCompare(info); - } - - @Test - void replicateDryRun(TestInfo info) throws Throwable { - String filename = "replicate-dry-run"; - generate(info, generator(73)); - Assertions.assertTrue(redisCommands.dbsize() > 0); - execute(info, filename); - Assertions.assertEquals(0, targetRedisCommands.dbsize()); - } - - @Test - void replicateHyperloglog(TestInfo info) throws Throwable { - String key = "crawled:20171124"; - String value = "http://www.google.com/"; - redisCommands.pfadd(key, value); - Assertions.assertEquals(0, execute(info, "replicate-hll")); - assertCompare(info); - } - - @Test - void replicateKeyProcessor(TestInfo info) throws Throwable { - String filename = "replicate-key-processor"; - GeneratorItemReader gen = generator(1, DataType.HASH); - generate(info, gen); - Long sourceSize = redisCommands.dbsize(); - Assertions.assertTrue(sourceSize > 0); - execute(info, filename); - Assertions.assertEquals(sourceSize, targetRedisCommands.dbsize()); - Assertions.assertEquals(redisCommands.hgetall("gen:1"), targetRedisCommands.hgetall("0:gen:1")); - } - @Test void replicateLive(TestInfo info) throws Exception { runLiveReplication(info, "replicate-live"); @@ -87,34 +46,6 @@ void replicateLiveThreads(TestInfo info) throws Exception { runLiveReplication(info, "replicate-live-threads"); } - @Test - void replicateLiveStruct(TestInfo info) throws Exception { - runLiveReplication(info, "replicate-live-struct"); - } - - @Test - void replicateLiveKeySlot(TestInfo info) throws Exception { - String filename = "replicate-live-keyslot"; - enableKeyspaceNotifications(); - GeneratorItemReader generator = generator(300); - generateAsync(info, generator); - execute(info, filename); - List keys = targetRedisCommands.keys("*"); - for (String key : keys) { - int slot = SlotHash.getSlot(key); - Assertions.assertTrue(slot >= 0 && slot <= 8000); - } - } - - @Test - void replicateStruct(TestInfo info) throws Throwable { - String filename = "replicate-struct"; - GeneratorItemReader generator = generator(12000); - generate(info, generator); - Assertions.assertTrue(redisCommands.dbsize() > 0); - execute(info, filename); - } - protected void runLiveReplication(TestInfo info, String filename) throws Exception { DataType[] types = new DataType[] { DataType.HASH, DataType.STRING }; enableKeyspaceNotifications(); @@ -155,30 +86,6 @@ protected void execute(Replicate replication, TestInfo info) throws Exception { replication.call(); } - @Test - void keyProcessor(TestInfo info) throws Throwable { - String key1 = "key1"; - String value1 = "value1"; - redisCommands.set(key1, value1); - Replicate command = new Replicate(); - command.setStruct(true); - command.getProcessorArgs().setKeyExpression(Expression.parseTemplate("#{type}:#{key}")); - execute(command, info); - Assertions.assertEquals(value1, targetRedisCommands.get("string:" + key1)); - } - - @Test - void keyProcessorWithDate(TestInfo info) throws Throwable { - String key1 = "key1"; - String value1 = "value1"; - redisCommands.set(key1, value1); - Replicate replication = new Replicate(); - replication.getProcessorArgs().setKeyExpression(Expression - .parseTemplate(String.format("#{#date.parse('%s').getTime()}:#{key}", "2010-05-10T00:00:00.000+0000"))); - execute(replication, info); - Assertions.assertEquals(value1, targetRedisCommands.get("1273449600000:" + key1)); - } - @Test void replicateBinaryStruct(TestInfo info) throws Exception { byte[] key = Hex.decode("aced0005"); diff --git a/plugins/riot/src/test/java/com/redis/riot/StackRiotTests.java b/plugins/riot/src/test/java/com/redis/riot/StackRiotTests.java index 1cba45626..465c50b73 100644 --- a/plugins/riot/src/test/java/com/redis/riot/StackRiotTests.java +++ b/plugins/riot/src/test/java/com/redis/riot/StackRiotTests.java @@ -33,6 +33,7 @@ import com.redis.lettucemod.timeseries.MRangeOptions; import com.redis.lettucemod.timeseries.RangeResult; import com.redis.lettucemod.timeseries.TimeRange; +import com.redis.riot.core.Expression; import com.redis.riot.file.xml.XmlItemReader; import com.redis.riot.file.xml.XmlItemReaderBuilder; import com.redis.riot.file.xml.XmlObjectReader; @@ -46,6 +47,7 @@ import io.lettuce.core.GeoArgs; import io.lettuce.core.Range; import io.lettuce.core.StreamMessage; +import io.lettuce.core.cluster.SlotHash; import picocli.CommandLine.ExitCode; import picocli.CommandLine.ParseResult; @@ -552,4 +554,96 @@ void replication(TestInfo info) throws Throwable { Assertions.assertFalse(comparison.getAll().isEmpty()); Assertions.assertEquals(Collections.emptyList(), comparison.mismatches()); } + + @Test + void replicate(TestInfo info) throws Throwable { + String filename = "replicate"; + generate(info, generator(73)); + Assertions.assertTrue(redisCommands.dbsize() > 0); + execute(info, filename); + assertCompare(info); + } + + @Test + void replicateDryRun(TestInfo info) throws Throwable { + String filename = "replicate-dry-run"; + generate(info, generator(73)); + Assertions.assertTrue(redisCommands.dbsize() > 0); + execute(info, filename); + Assertions.assertEquals(0, targetRedisCommands.dbsize()); + } + + @Test + void replicateHyperloglog(TestInfo info) throws Throwable { + String key = "crawled:20171124"; + String value = "http://www.google.com/"; + redisCommands.pfadd(key, value); + Assertions.assertEquals(0, execute(info, "replicate-hll")); + assertCompare(info); + } + + @Test + void replicateKeyProcessor(TestInfo info) throws Throwable { + String filename = "replicate-key-processor"; + GeneratorItemReader gen = generator(1, DataType.HASH); + generate(info, gen); + Long sourceSize = redisCommands.dbsize(); + Assertions.assertTrue(sourceSize > 0); + execute(info, filename); + Assertions.assertEquals(sourceSize, targetRedisCommands.dbsize()); + Assertions.assertEquals(redisCommands.hgetall("gen:1"), targetRedisCommands.hgetall("0:gen:1")); + } + + @Test + void replicateLiveStruct(TestInfo info) throws Exception { + runLiveReplication(info, "replicate-live-struct"); + } + + @Test + void replicateLiveKeySlot(TestInfo info) throws Exception { + String filename = "replicate-live-keyslot"; + enableKeyspaceNotifications(); + GeneratorItemReader generator = generator(300); + generateAsync(info, generator); + execute(info, filename); + List keys = targetRedisCommands.keys("*"); + for (String key : keys) { + int slot = SlotHash.getSlot(key); + Assertions.assertTrue(slot >= 0 && slot <= 8000); + } + } + + @Test + void replicateStruct(TestInfo info) throws Throwable { + String filename = "replicate-struct"; + GeneratorItemReader generator = generator(12000); + generate(info, generator); + Assertions.assertTrue(redisCommands.dbsize() > 0); + execute(info, filename); + } + + @Test + void keyProcessor(TestInfo info) throws Throwable { + String key1 = "key1"; + String value1 = "value1"; + redisCommands.set(key1, value1); + Replicate command = new Replicate(); + command.setStruct(true); + command.getProcessorArgs().setKeyExpression(Expression.parseTemplate("#{type}:#{key}")); + execute(command, info); + Assertions.assertEquals(value1, targetRedisCommands.get("string:" + key1)); + } + + @Test + void keyProcessorWithDate(TestInfo info) throws Throwable { + String key1 = "key1"; + String value1 = "value1"; + redisCommands.set(key1, value1); + Replicate replication = new Replicate(); + replication.getProcessorArgs().setKeyExpression(Expression + .parseTemplate(String.format("#{#date.parse('%s').getTime()}:#{key}", "2010-05-10T00:00:00.000+0000"))); + execute(replication, info); + Assertions.assertEquals(value1, targetRedisCommands.get("1273449600000:" + key1)); + } + }