Skip to content

Commit 4e20609

Browse files
committed
beta of the redis enterprise container
1 parent 686cdeb commit 4e20609

File tree

5 files changed

+148
-11
lines changed

5 files changed

+148
-11
lines changed

build.gradle

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ plugins {
22
id 'java-library'
33
id 'maven-publish'
44
id 'signing'
5-
id 'io.github.gradle-nexus.publish-plugin' version '1.0.0'
5+
id 'org.springframework.boot' version '2.4.5'
6+
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
7+
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
68
id 'net.researchgate.release' version '2.8.1'
79
id 'com.github.ben-manes.versions' version '0.38.0'
810
id 'com.github.breadmoirai.github-release' version '2.2.12'
@@ -23,18 +25,26 @@ repositories {
2325
mavenLocal()
2426
}
2527

28+
bootJar {
29+
enabled = false
30+
}
31+
32+
jar {
33+
enabled = true
34+
}
35+
2636
dependencies {
27-
compileOnly group: 'org.projectlombok', name: 'lombok', version: lombok_version
28-
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok_version
29-
api group: 'org.junit.jupiter', name:'junit-jupiter-api', version: junit_version
30-
api group: 'org.junit.jupiter', name:'junit-jupiter-engine', version: junit_version
31-
api group: 'org.junit.jupiter', name:'junit-jupiter-params', version: junit_version
37+
compileOnly 'org.projectlombok:lombok'
38+
annotationProcessor 'org.projectlombok:lombok'
39+
api 'org.junit.jupiter:junit-jupiter-api'
40+
api 'org.junit.jupiter:junit-jupiter-engine'
41+
api 'org.junit.jupiter:junit-jupiter-params'
3242
api group: 'org.testcontainers', name: 'testcontainers', version: testcontainers_version
3343
api group: 'org.testcontainers', name: 'junit-jupiter', version: testcontainers_version
34-
testImplementation 'com.redislabs:mesclun:1.2.4'
35-
testImplementation 'org.slf4j:slf4j-simple:1.7.30'
36-
testImplementation group: 'org.projectlombok', name: 'lombok', version: lombok_version
37-
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombok_version
44+
testImplementation 'com.redislabs:mesclun:1.3.2'
45+
testImplementation 'org.projectlombok:lombok'
46+
testAnnotationProcessor 'org.projectlombok:lombok'
47+
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
3848
}
3949

4050
test {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.redislabs.testcontainers;
2+
3+
import org.testcontainers.containers.GenericContainer;
4+
import org.testcontainers.shaded.org.apache.commons.lang.ClassUtils;
5+
6+
import java.time.Duration;
7+
import java.time.temporal.ChronoUnit;
8+
import java.util.Arrays;
9+
import java.util.List;
10+
11+
public class RedisEnterpriseContainer extends GenericContainer<RedisEnterpriseContainer> implements RedisContainer {
12+
13+
public static final String DEFAULT_IMAGE_NAME = "redislabs/redis:latest";
14+
public static final List<Integer> PORTS = Arrays.asList(53, 5353, 8001, 8070, 8080, 8443, 9443, 12000);
15+
16+
private static final int DEFAULT_STARTUP_TIMEOUT_SECONDS = 240;
17+
private static final int DEFAULT_CONNECT_TIMEOUT_SECONDS = 120;
18+
19+
public RedisEnterpriseContainer() {
20+
super(DEFAULT_IMAGE_NAME);
21+
withPrivilegedMode(true);
22+
setStartupAttempts(1);
23+
withStartupTimeout(Duration.of(2, ChronoUnit.MINUTES));
24+
withExposedPorts(PORTS.toArray(new Integer[0]));
25+
PORTS.forEach(p -> addFixedExposedPort(p, p));
26+
}
27+
28+
@Override
29+
public boolean isCluster() {
30+
return false;
31+
}
32+
33+
/**
34+
* Get Redis URI.
35+
*
36+
* @return Redis URI.
37+
*/
38+
@Override
39+
public String getRedisURI() {
40+
return RedisContainerUtils.redisURI(this);
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return ClassUtils.getShortClassName(getClass());
46+
}
47+
48+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.redislabs.testcontainers;
2+
3+
import io.lettuce.core.RedisClient;
4+
import io.lettuce.core.api.StatefulRedisConnection;
5+
import io.netty.util.internal.logging.InternalLoggerFactory;
6+
import io.netty.util.internal.logging.JdkLoggerFactory;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.junit.jupiter.api.*;
9+
import org.testcontainers.containers.output.Slf4jLogConsumer;
10+
import org.testcontainers.containers.startupcheck.StartupCheckStrategy;
11+
12+
import java.util.HashMap;
13+
import java.util.Map;
14+
import java.util.logging.ConsoleHandler;
15+
import java.util.logging.Level;
16+
import java.util.logging.LogManager;
17+
import java.util.logging.Logger;
18+
19+
//@Testcontainers
20+
@Slf4j
21+
public class TestRedisEnterpriseContainer {
22+
23+
private static final String ROOT_LOGGER = "";
24+
private RedisClient client;
25+
private StatefulRedisConnection<String, String> connection;
26+
27+
@BeforeAll
28+
static void isRunning() {
29+
RedisEnterpriseContainer redisEnterprise = new RedisEnterpriseContainer();
30+
redisEnterprise.withLogConsumer(new Slf4jLogConsumer(log));
31+
redisEnterprise.start();
32+
Assertions.assertTrue(redisEnterprise.isRunning());
33+
}
34+
35+
// @BeforeEach
36+
// public void setupEach() {
37+
// this.client = RedisClient.create(REDIS_ENTERPRISE.getRedisURI());
38+
// this.connection = client.connect();
39+
// }
40+
//
41+
// @AfterEach
42+
// public void cleanupEach() {
43+
// connection.sync().flushall();
44+
// connection.close();
45+
// client.shutdown();
46+
// }
47+
48+
@Test
49+
void canPing() {
50+
// Assertions.assertEquals("PONG", connection.sync().ping());
51+
}
52+
//
53+
// @Test
54+
// void canWrite() {
55+
// Map<String, String> hash = new HashMap<>();
56+
// hash.put("field1", "value1");
57+
// connection.sync().hset("hash:test", hash);
58+
// Map<String, String> response = connection.sync().hgetall("hash:test");
59+
// Assertions.assertEquals(hash, response);
60+
// }
61+
62+
public static void main(String[] args) {
63+
isRunning();
64+
}
65+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<configuration>
2+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
8+
<root level="debug">
9+
<appender-ref ref="STDOUT"/>
10+
</root>
11+
12+
<logger name="org.testcontainers" level="DEBUG"/>
13+
<logger name="com.github.dockerjava" level="DEBUG"/>
14+
</configuration>

0 commit comments

Comments
 (0)