Skip to content

Commit

Permalink
test: Moved replicate-key-exclude test to stack
Browse files Browse the repository at this point in the history
  • Loading branch information
jruaux committed Apr 29, 2024
1 parent fce39af commit 8e2084c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.redis.testcontainers.RedisStackContainer;

@EnabledOnOs(OS.LINUX)
class EnterpriseContainerToStackTests extends AbstractReplicationTests {
class EnterpriseContainerStackReplicationTests extends ReplicationTests {

private static final RedisEnterpriseContainer source = RedisContainerFactory.enterprise();
private static final RedisStackContainer target = RedisContainerFactory.stack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.redis.testcontainers.RedisStackContainer;

@EnabledIfEnvironmentVariable(named = RedisEnterpriseServer.ENV_HOST, matches = ".*")
class EnterpriseServerToStackTests extends AbstractReplicationTests {
class EnterpriseServerStackReplicationTests extends ReplicationTests {

private static final RedisEnterpriseServer source = RedisContainerFactory.enterpriseServer();
private static final RedisStackContainer target = RedisContainerFactory.stack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.redis.spring.batch.gen.GeneratorItemReader;
import com.redis.spring.batch.gen.Item.Type;

class PostgresTests extends AbstractDbTests {
class PostgresTests extends RiotDbTests {

private static final DockerImageName postgresImage = DockerImageName.parse(PostgreSQLContainer.IMAGE)
.withTag(PostgreSQLContainer.DEFAULT_TAG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import io.lettuce.core.cluster.SlotHash;

abstract class AbstractReplicationTests extends AbstractRiotTestBase {
abstract class ReplicationTests extends AbstractRiotTestBase {

@BeforeAll
void setDefaults() {
Expand All @@ -32,7 +32,7 @@ void replicate(TestInfo info) throws Throwable {
}

@Test
void dryRun(TestInfo info) throws Throwable {
void replicateDryRun(TestInfo info) throws Throwable {
String filename = "replicate-dry-run";
generate(info, generator(73));
Assertions.assertTrue(redisCommands.dbsize() > 0);
Expand All @@ -41,7 +41,7 @@ void dryRun(TestInfo info) throws Throwable {
}

@Test
void hll(TestInfo info) throws Throwable {
void replicateHyperloglog(TestInfo info) throws Throwable {
String key = "crawled:20171124";
String value = "http://www.google.com/";
redisCommands.pfadd(key, value);
Expand All @@ -52,7 +52,7 @@ void hll(TestInfo info) throws Throwable {
}

@Test
void keyProcessor(TestInfo info) throws Throwable {
void replicateKeyProcessor(TestInfo info) throws Throwable {
String filename = "replicate-key-processor";
GeneratorItemReader gen = generator(1, Type.HASH);
generate(info, gen);
Expand All @@ -64,22 +64,7 @@ void keyProcessor(TestInfo info) throws Throwable {
}

@Test
void keyExclude(TestInfo info) throws Throwable {
String filename = "replicate-key-exclude";
int goodCount = 200;
GeneratorItemReader gen = generator(goodCount, Type.HASH);
generate(info, gen);
int badCount = 100;
GeneratorItemReader generator2 = generator(badCount, Type.HASH);
generator2.setKeyspace("bad");
generate(testInfo(info, "2"), generator2);
Assertions.assertEquals(badCount, keyCount("bad:*"));
execute(info, filename);
Assertions.assertEquals(goodCount, targetRedisCommands.keys("gen:*").size());
}

@Test
void liveKeyExclude(TestInfo info) throws Throwable {
void replicateLiveKeyExclude(TestInfo info) throws Throwable {
int goodCount = 200;
int badCount = 100;
enableKeyspaceNotifications();
Expand All @@ -95,22 +80,22 @@ void liveKeyExclude(TestInfo info) throws Throwable {
}

@Test
void live(TestInfo info) throws Exception {
void replicateLive(TestInfo info) throws Exception {
runLiveReplication(info, "replicate-live");
}

@Test
void threads(TestInfo info) throws Exception {
void replicateLiveThreads(TestInfo info) throws Exception {
runLiveReplication(info, "replicate-live-threads");
}

@Test
void liveStruct(TestInfo info) throws Exception {
void replicateLiveStruct(TestInfo info) throws Exception {
runLiveReplication(info, "replicate-live-struct");
}

@Test
void liveOnlyStruct(TestInfo info) throws Exception {
void replicateLiveOnlyStruct(TestInfo info) throws Exception {
Type[] types = new Type[] { Type.HASH, Type.STRING };
enableKeyspaceNotifications();
GeneratorItemReader generator = generator(3500, types);
Expand All @@ -123,7 +108,7 @@ void liveOnlyStruct(TestInfo info) throws Exception {
}

@Test
void liveKeySlot(TestInfo info) throws Exception {
void replicateLiveKeySlot(TestInfo info) throws Exception {
String filename = "replicate-live-keyslot";
enableKeyspaceNotifications();
GeneratorItemReader generator = generator(300);
Expand All @@ -137,7 +122,7 @@ void liveKeySlot(TestInfo info) throws Exception {
}

@Test
void struct(TestInfo info) throws Throwable {
void replicateStruct(TestInfo info) throws Throwable {
String filename = "replicate-struct";
GeneratorItemReader generator = generator(12000);
generate(info, generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import picocli.CommandLine.ExitCode;
import picocli.CommandLine.ParseResult;

abstract class AbstractDbTests extends AbstractRiotTestBase {
abstract class RiotDbTests extends AbstractRiotTestBase {

private static final RedisStackContainer redis = new RedisStackContainer(
RedisStackContainer.DEFAULT_IMAGE_NAME.withTag(RedisStackContainer.DEFAULT_TAG));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.redis.testcontainers.RedisStackContainer;

@EnabledOnOs(OS.LINUX)
class StackToEnterpriseContainerReplicationTests extends AbstractReplicationTests {
class StackEnterpriseContainerReplicationTests extends ReplicationTests {

private static final RedisStackContainer source = RedisContainerFactory.stack();
private static final RedisEnterpriseContainer target = RedisContainerFactory.enterprise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.redis.testcontainers.RedisStackContainer;

@EnabledIfEnvironmentVariable(named = RedisEnterpriseServer.ENV_HOST, matches = ".*")
public class StackToEnterpriseServerReplicationTests extends AbstractReplicationTests {
public class StackEnterpriseServerReplicationTests extends ReplicationTests {

private static final RedisStackContainer source = RedisContainerFactory.stack();
private static final RedisEnterpriseServer target = RedisContainerFactory.enterpriseServer();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.redis.spring.batch.KeyValue;
import com.redis.spring.batch.KeyValue.DataType;
import com.redis.spring.batch.gen.GeneratorItemReader;
import com.redis.spring.batch.gen.Item.Type;
import com.redis.spring.batch.reader.MemKeyValue;
import com.redis.testcontainers.RedisStackContainer;

Expand All @@ -48,10 +49,7 @@
import picocli.CommandLine.ExitCode;
import picocli.CommandLine.ParseResult;

class StackToStackIntegrationTests extends AbstractRiotTestBase {

public static final int BEER_CSV_COUNT = 2410;
public static final int BEER_JSON_COUNT = 216;
class StackToStackTests extends ReplicationTests {

private static final RedisStackContainer source = RedisContainerFactory.stack();
private static final RedisStackContainer target = RedisContainerFactory.stack();
Expand All @@ -66,6 +64,9 @@ protected RedisStackContainer getTargetRedisServer() {
return target;
}

public static final int BEER_CSV_COUNT = 2410;
public static final int BEER_JSON_COUNT = 216;

private static Path tempDir;

@BeforeAll
Expand Down Expand Up @@ -495,4 +496,18 @@ void generateTypes(TestInfo info) throws Exception {
redisCommands.dbsize());
}

@Test
void replicateKeyExclude(TestInfo info) throws Throwable {
String filename = "replicate-key-exclude";
int goodCount = 200;
GeneratorItemReader gen = generator(goodCount, Type.HASH);
generate(info, gen);
int badCount = 100;
GeneratorItemReader generator2 = generator(badCount, Type.HASH);
generator2.setKeyspace("bad");
generate(testInfo(info, "2"), generator2);
Assertions.assertEquals(badCount, keyCount("bad:*"));
execute(info, filename);
Assertions.assertEquals(goodCount, targetRedisCommands.keys("gen:*").size());
}
}

0 comments on commit 8e2084c

Please sign in to comment.