Skip to content

Commit

Permalink
deps: Upgraded to latest testcontainers-redis
Browse files Browse the repository at this point in the history
  • Loading branch information
jruaux committed Feb 29, 2024
1 parent 326c4fb commit 4c5759d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ public Builder memory(long memory) {
return this;
}

public Builder memoryMB(long memory) {
return memory(memory * MB_TO_BYTES);
}

public Builder port(Integer port) {
this.port = port;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import com.redis.testcontainers.RedisEnterpriseContainer;

@Testcontainers
@EnabledOnOs(value = OS.LINUX)
class ContainerAdminTests extends AbstractAdminTests {

@Container
private static RedisEnterpriseContainer server = new RedisEnterpriseContainer(
RedisEnterpriseContainer.DEFAULT_IMAGE_NAME.withTag(RedisEnterpriseContainer.DEFAULT_TAG));
private static TestRedisEnterpriseContainer container = new TestRedisEnterpriseContainer(
TestRedisEnterpriseContainer.DEFAULT_IMAGE_NAME.withTag(TestRedisEnterpriseContainer.DEFAULT_TAG));

@Override
protected Admin admin() {
Admin admin = new Admin();
admin.withHost(server.getHost());
admin.withHost(container.getHost());
return admin;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.redis.enterprise;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.utility.DockerImageName;

import com.redis.testcontainers.AbstractRedisEnterpriseContainer;

public class TestRedisEnterpriseContainer extends AbstractRedisEnterpriseContainer<TestRedisEnterpriseContainer> {

private final Admin admin = new Admin();
private Database database = Database.builder().shardCount(2).port(12000).ossCluster(true)
.modules(RedisModule.SEARCH, RedisModule.JSON, RedisModule.TIMESERIES, RedisModule.BLOOM).build();

private static final Logger log = LoggerFactory.getLogger(TestRedisEnterpriseContainer.class);

public TestRedisEnterpriseContainer(String dockerImageName) {
super(dockerImageName);
}

public TestRedisEnterpriseContainer(DockerImageName dockerImageName) {
super(dockerImageName);
}

@Override
protected String getAdminUserName() {
return admin.getUserName();
}

@Override
protected String getAdminPassword() {
return admin.getPassword();
}

@Override
public int getRedisPort() {
return database.getPort();
}

@Override
public boolean isRedisCluster() {
return database.isOssCluster();
}

@Override
protected void doStart() {
admin.withHost(getHost());
addFixedExposedPort(admin.getPort(), admin.getPort());
addFixedExposedPort(database.getPort(), database.getPort());
super.doStart();
}

@Override
protected void createCluster() throws Exception {
log.info("Waiting for cluster bootstrap");
admin.waitForBoostrap();
super.createCluster();
Database response = admin.createDatabase(database);
log.info("Created database {} with UID {}", response.getName(), response.getUid());
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ springBootVersion = 3.2.3

jacocoVersion = 0.8.11
lettucemodVersion = 3.7.3
testcontainersRedisVersion = 2.1.0
testcontainersRedisVersion = 2.1.1

org.gradle.daemon = false
org.gradle.caching = false
Expand Down

0 comments on commit 4c5759d

Please sign in to comment.