Skip to content

Commit 4c5759d

Browse files
committed
deps: Upgraded to latest testcontainers-redis
1 parent 326c4fb commit 4c5759d

File tree

4 files changed

+70
-6
lines changed

4 files changed

+70
-6
lines changed

core/redis-enterprise-admin/src/main/java/com/redis/enterprise/Database.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ public Builder memory(long memory) {
348348
return this;
349349
}
350350

351+
public Builder memoryMB(long memory) {
352+
return memory(memory * MB_TO_BYTES);
353+
}
354+
351355
public Builder port(Integer port) {
352356
this.port = port;
353357
return this;

core/redis-enterprise-admin/src/test/java/com/redis/enterprise/ContainerAdminTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55
import org.testcontainers.junit.jupiter.Container;
66
import org.testcontainers.junit.jupiter.Testcontainers;
77

8-
import com.redis.testcontainers.RedisEnterpriseContainer;
9-
108
@Testcontainers
119
@EnabledOnOs(value = OS.LINUX)
1210
class ContainerAdminTests extends AbstractAdminTests {
1311

1412
@Container
15-
private static RedisEnterpriseContainer server = new RedisEnterpriseContainer(
16-
RedisEnterpriseContainer.DEFAULT_IMAGE_NAME.withTag(RedisEnterpriseContainer.DEFAULT_TAG));
13+
private static TestRedisEnterpriseContainer container = new TestRedisEnterpriseContainer(
14+
TestRedisEnterpriseContainer.DEFAULT_IMAGE_NAME.withTag(TestRedisEnterpriseContainer.DEFAULT_TAG));
1715

1816
@Override
1917
protected Admin admin() {
2018
Admin admin = new Admin();
21-
admin.withHost(server.getHost());
19+
admin.withHost(container.getHost());
2220
return admin;
2321
}
2422

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.redis.enterprise;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.testcontainers.utility.DockerImageName;
6+
7+
import com.redis.testcontainers.AbstractRedisEnterpriseContainer;
8+
9+
public class TestRedisEnterpriseContainer extends AbstractRedisEnterpriseContainer<TestRedisEnterpriseContainer> {
10+
11+
private final Admin admin = new Admin();
12+
private Database database = Database.builder().shardCount(2).port(12000).ossCluster(true)
13+
.modules(RedisModule.SEARCH, RedisModule.JSON, RedisModule.TIMESERIES, RedisModule.BLOOM).build();
14+
15+
private static final Logger log = LoggerFactory.getLogger(TestRedisEnterpriseContainer.class);
16+
17+
public TestRedisEnterpriseContainer(String dockerImageName) {
18+
super(dockerImageName);
19+
}
20+
21+
public TestRedisEnterpriseContainer(DockerImageName dockerImageName) {
22+
super(dockerImageName);
23+
}
24+
25+
@Override
26+
protected String getAdminUserName() {
27+
return admin.getUserName();
28+
}
29+
30+
@Override
31+
protected String getAdminPassword() {
32+
return admin.getPassword();
33+
}
34+
35+
@Override
36+
public int getRedisPort() {
37+
return database.getPort();
38+
}
39+
40+
@Override
41+
public boolean isRedisCluster() {
42+
return database.isOssCluster();
43+
}
44+
45+
@Override
46+
protected void doStart() {
47+
admin.withHost(getHost());
48+
addFixedExposedPort(admin.getPort(), admin.getPort());
49+
addFixedExposedPort(database.getPort(), database.getPort());
50+
super.doStart();
51+
}
52+
53+
@Override
54+
protected void createCluster() throws Exception {
55+
log.info("Waiting for cluster bootstrap");
56+
admin.waitForBoostrap();
57+
super.createCluster();
58+
Database response = admin.createDatabase(database);
59+
log.info("Created database {} with UID {}", response.getName(), response.getUid());
60+
}
61+
62+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ springBootVersion = 3.2.3
1212

1313
jacocoVersion = 0.8.11
1414
lettucemodVersion = 3.7.3
15-
testcontainersRedisVersion = 2.1.0
15+
testcontainersRedisVersion = 2.1.1
1616

1717
org.gradle.daemon = false
1818
org.gradle.caching = false

0 commit comments

Comments
 (0)