Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1d7e1d0
add initial skeleton without stunnel
kiryazovi-redis Jan 17, 2025
194aa2b
fix up some paths
kiryazovi-redis Jan 17, 2025
f140202
fix the standalone ones.
kiryazovi-redis Jan 22, 2025
b3e5c29
fix issues which crash the containers.
kiryazovi-redis Jan 23, 2025
334ed1a
add more file renames.
kiryazovi-redis Jan 23, 2025
5a55583
add missed configs
kiryazovi-redis Jan 23, 2025
ee30708
Fix up the docker-compose. TODO: actual testing, after being compliant
kiryazovi-redis Jan 23, 2025
8683a6d
fix sentinel to work
kiryazovi-redis Jan 23, 2025
ebfcf87
fix 70 out of 80 failing tests by fixing configuration
kiryazovi-redis Jan 27, 2025
fbd0167
fix make file, this should be committed
kiryazovi-redis Jan 27, 2025
bc42474
fix up more tests, now only ssl stuff seems to remain. (4 tests)
kiryazovi-redis Jan 27, 2025
54ba159
fix up one tls, but we need to fix up the java code for the store
kiryazovi-redis Jan 28, 2025
d56bd91
fix some of the ssl tests
kiryazovi-redis Jan 29, 2025
8d56ebb
reduce test failures to 3
kiryazovi-redis Jan 30, 2025
43a3a2f
fix java
kiryazovi-redis Jan 30, 2025
8fa4a81
fix the last of ssl tests. TODO: retest the key tests
kiryazovi-redis Feb 3, 2025
fbf085b
add docker to the makefile
kiryazovi-redis Feb 3, 2025
0becc2a
add fixes for several tests
kiryazovi-redis Feb 6, 2025
b9dceb8
formatting
kiryazovi-redis Feb 6, 2025
c4e3b08
attempt to create keystore file via java
kiryazovi-redis Feb 7, 2025
79c2171
format
kiryazovi-redis Feb 7, 2025
1c217f6
Revert "format"
kiryazovi-redis Feb 10, 2025
7892951
Revert "attempt to create keystore file via java"
kiryazovi-redis Feb 10, 2025
2a538e1
Merge branch 'main' into topic/kiryazovi-redis/use-docker-for-tests
kiryazovi-redis Feb 10, 2025
8a4a553
ad some path fixes
kiryazovi-redis Feb 10, 2025
2dfda22
Fix standaloneWithClientCertificates
ggivo Feb 10, 2025
9481549
Remove some of old makefile work + fix up paths so they are not destr…
kiryazovi-redis Feb 11, 2025
570822a
attempt integration.yml to work with docker
kiryazovi-redis Feb 11, 2025
9b36cdc
experiment with version
kiryazovi-redis Feb 11, 2025
4b15b60
fix clean-up-step
kiryazovi-redis Feb 11, 2025
82c3958
ordering
kiryazovi-redis Feb 11, 2025
3432821
fix up move versioning and try to debug folder+unix issue
kiryazovi-redis Feb 11, 2025
4971715
try a sock solution proposed by Ivo
kiryazovi-redis Feb 12, 2025
94b92c9
fix up supported version
kiryazovi-redis Feb 12, 2025
c92c4dc
possible fix
kiryazovi-redis Feb 12, 2025
c64977c
make file name shorte
kiryazovi-redis Feb 12, 2025
04a1f7d
fix up paths, yet again, idk why there was docker
kiryazovi-redis Feb 12, 2025
e475727
test out new waiting strategy
kiryazovi-redis Feb 12, 2025
97d6072
Merge branch 'redis:main' into topic/kiryazovi-redis/use-docker-for-t…
kiryazovi-redis Feb 12, 2025
e829fa7
revet old waiting
kiryazovi-redis Feb 12, 2025
0937c9e
fix default version and disable a test with server regression
kiryazovi-redis Feb 12, 2025
f30a3d6
"Fix" test. Problem is that acldeluser doesn't delete previous Japane…
kiryazovi-redis Feb 12, 2025
1aad1a8
further fix up acl, and later will create a PR for it
kiryazovi-redis Feb 12, 2025
87500e9
fix up benchmarks + fix up integration sudo and makefile.
kiryazovi-redis Feb 12, 2025
c7390d2
format
kiryazovi-redis Feb 12, 2025
2f91bd1
add some readme fixes
kiryazovi-redis Feb 12, 2025
99e573f
fix docker compose down
kiryazovi-redis Feb 12, 2025
3028a35
fix up benchmarks
kiryazovi-redis Feb 12, 2025
ad32128
remove useless files
kiryazovi-redis Feb 12, 2025
4fa2397
Revert ""Fix" test. Problem is that acldeluser doesn't delete previou…
kiryazovi-redis Feb 14, 2025
9a7366b
Revert "further fix up acl, and later will create a PR for it"
kiryazovi-redis Feb 14, 2025
b577763
Revert ""Fix" test. Problem is that acldeluser doesn't delete previou…
kiryazovi-redis Feb 14, 2025
0f24417
Merge branch 'redis:main' into topic/kiryazovi-redis/use-docker-for-t…
kiryazovi-redis Feb 14, 2025
a1e2371
"Fix" test. Problem is that acldeluser doesn't delete previous Japane…
kiryazovi-redis Feb 12, 2025
c7c60fd
fix up merge issues
kiryazovi-redis Feb 14, 2025
4d67a27
fix more merge issues
kiryazovi-redis Feb 14, 2025
468fc62
fix addjirahere thing
kiryazovi-redis Feb 14, 2025
79ed4b0
fix review issues
kiryazovi-redis Feb 14, 2025
f0def08
Merge branch 'main' into topic/kiryazovi-redis/use-docker-for-tests
kiryazovi-redis Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ work/
dependency-reduced-pom.xml
.idea
.flattened-pom.xml
*.java-version
*.DS_Store
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ test: start
mvn -DskipITs=false clean compile verify -P$(PROFILE)
$(MAKE) stop

docker-test:
rm -rf /tmp/redis-env-work
docker compose --env-file src/test/resources/docker-env/.env -f src/test/resources/docker-env/docker-compose.yml up -d; \
mvn -DskipITs=false clean compile verify -P$(PROFILE)

docker-stop:
docker compose --env-file src/test/resources/docker-env/.env -f src/test/resources/docker-env/docker-compose.yml down; \

prepare: stop

ifndef STUNNEL_BIN
Expand Down
64 changes: 42 additions & 22 deletions src/test/java/io/lettuce/core/SslIntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.List;
import java.util.function.Function;
Expand All @@ -50,6 +52,7 @@

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static io.lettuce.test.settings.TestSettings.sslPort;
import static io.lettuce.test.settings.TlsSettings.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
Expand All @@ -66,11 +69,13 @@ class SslIntegrationTests extends TestSupport {

private static final String KEYSTORE = "work/keystore.jks";

private static final String TRUSTSTORE = "work/truststore.jks";
private static File truststoreFile0;

private static final File TRUSTSTORE_FILE = new File(TRUSTSTORE);
private static File truststoreFile1;

private static final File CA_CERT_FILE = new File("work/ca/certs/ca.cert.pem");
private static File truststoreFile2;

private static File cacertFile;

private static final int MASTER_SLAVE_BASE_PORT_OFFSET = 2000;

Expand All @@ -86,7 +91,7 @@ class SslIntegrationTests extends TestSupport {
.withVerifyPeer(false) //
.build();

private static final RedisURI URI_CLIENT_CERT_AUTH = sslURIBuilder(2) //
private static final RedisURI URI_CLIENT_CERT_AUTH = sslURIBuilder(1) //
.withVerifyPeer(true) //
.build();

Expand All @@ -111,9 +116,24 @@ class SslIntegrationTests extends TestSupport {

@BeforeAll
static void beforeClass() {
Path path0 = createAndSaveTestTruststore("redis-standalone-0", Paths.get("redis-standalone-0/work/tls"), "changeit");
truststoreFile0 = path0.toFile();
cacertFile = envCa(Paths.get("redis-standalone-0/work/tls")).toFile();

Path path = createAndSaveTestTruststore("redis-standalone-1", Paths.get("redis-standalone-1/work/tls"), "changeit");
truststoreFile1 = path.toFile();
cacertFile = envCa(Paths.get("redis-standalone-1/work/tls")).toFile();

Path path2 = createAndSaveTestTruststore("redis-standalone-sentinel-controlled",
Paths.get("redis-standalone-sentinel-controlled/work/tls"), "changeit");
truststoreFile2 = path2.toFile();
cacertFile = envCa(Paths.get("redis-standalone-sentinel-controlled/work/tls")).toFile();

assumeTrue(CanConnect.to(TestSettings.host(), sslPort()), "Assume that stunnel runs on port 6443");
assertThat(TRUSTSTORE_FILE).exists();
// Maybe we should do a list.
assertThat(truststoreFile0).exists();
assertThat(truststoreFile1).exists();
assertThat(truststoreFile2).exists();
}

@Test
Expand All @@ -130,7 +150,7 @@ void standaloneWithJdkSsl() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile1, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -142,7 +162,7 @@ void standaloneWithVerifyCaOnly() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile0, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -153,7 +173,7 @@ void standaloneWithVerifyCaOnly() {
void standaloneWithPemCert() {

SslOptions sslOptions = SslOptions.builder() //
.trustManager(CA_CERT_FILE) //
.trustManager(envCa(Paths.get("redis-standalone-1/work/tls")).toFile()) //
.build();
setOptions(sslOptions);
verifyConnection(URI_VERIFY);
Expand All @@ -164,7 +184,7 @@ void standaloneWithPemCertAndImpossibleTimeout() {

Assertions.setMaxStackTraceElementsDisplayed(30);
SslOptions sslOptions = SslOptions.builder() //
.trustManager(CA_CERT_FILE) //
.trustManager(envCa(Paths.get("redis-standalone-1/work/tls")).toFile()) //
.build();
setOptions(sslOptions);
redisClient.setOptions(ClientOptions.builder().protocolVersion(ProtocolVersion.RESP3).sslOptions(sslOptions).build());
Expand All @@ -183,7 +203,7 @@ void standaloneWithJdkSslUsingTruststoreUrl() throws Exception {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(truststoreURL()) //
.truststore(truststoreURL(truststoreFile1), "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -192,11 +212,11 @@ void standaloneWithJdkSslUsingTruststoreUrl() throws Exception {

@Test
void standaloneWithClientCertificates() {

// 6445
SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.keystore(new File(KEYSTORE), "changeit".toCharArray()) //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile0, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -208,7 +228,7 @@ void standaloneWithClientCertificatesWithoutKeystore() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile1, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -220,7 +240,7 @@ void standaloneWithJdkSslUsingTruststoreUrlWithWrongPassword() throws Exception

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(truststoreURL(), "knödel") //
.truststore(truststoreURL(truststoreFile0), "knödel") //
.build();
setOptions(sslOptions);

Expand All @@ -245,7 +265,7 @@ void standaloneWithOpenSsl() {

SslOptions sslOptions = SslOptions.builder() //
.openSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile0, "changeit") //
.build();
setOptions(sslOptions);

Expand Down Expand Up @@ -298,7 +318,7 @@ void masterSlaveWithJdkSsl() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile2, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -310,7 +330,7 @@ void masterSlaveWithJdkSslUsingTruststoreUrl() throws Exception {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(truststoreURL()) //
.truststore(truststoreURL(truststoreFile2), "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -322,7 +342,7 @@ void masterSlaveWithJdkSslUsingTruststoreUrlWithWrongPassword() throws Exception

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(truststoreURL(), "knödel") //
.truststore(truststoreURL(truststoreFile0), "knödel") //
.build();
setOptions(sslOptions);

Expand Down Expand Up @@ -363,7 +383,7 @@ void masterSlaveSslWithOneInvalidHostWillSucceed() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile2, "changeit") //
.build();
setOptions(sslOptions);

Expand All @@ -375,7 +395,7 @@ void masterSlaveSslWithAllInvalidHostsWillFail() {

SslOptions sslOptions = SslOptions.builder() //
.jdkSslProvider() //
.truststore(TRUSTSTORE_FILE) //
.truststore(truststoreFile0, "changeit") //
.build();
setOptions(sslOptions);

Expand Down Expand Up @@ -415,8 +435,8 @@ private static List<RedisURI> sslUris(IntStream masterSlaveOffsets,
.map(builderCustomizer).map(RedisURI.Builder::build).collect(Collectors.toList());
}

private URL truststoreURL() throws MalformedURLException {
return TRUSTSTORE_FILE.toURI().toURL();
private URL truststoreURL(File truststoreFile) throws MalformedURLException {
return truststoreFile.toURI().toURL();
}

private void setOptions(SslOptions sslOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

import javax.inject.Inject;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.extension.ExtendWith;

import io.lettuce.core.MigrateArgs;
Expand All @@ -32,6 +30,7 @@
*/
@Tag(INTEGRATION_TEST)
@ExtendWith(LettuceExtension.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class RunOnlyOnceServerCommandIntegrationTests extends TestSupport {

private final RedisClient client;
Expand All @@ -54,6 +53,7 @@ class RunOnlyOnceServerCommandIntegrationTests extends TestSupport {
*/
@Test
@Disabled
@Order(1)
void debugSegfault() {

assumeTrue(CanConnect.to(host(), port(1)));
Expand All @@ -74,32 +74,34 @@ void debugSegfault() {
* Executed in order: 2
*/
@Test
@Order(2)
void migrate() {

assumeTrue(CanConnect.to(host(), port(2)));
assumeTrue(CanConnect.to(host(), port(7)));

redis.set(key, value);

String result = redis.migrate("localhost", TestSettings.port(2), key, 0, 10);
String result = redis.migrate("localhost", TestSettings.port(7), key, 0, 10);
assertThat(result).isEqualTo("OK");
}

/**
* Executed in order: 3
*/
@Test
@Order(3)
void migrateCopyReplace() {

assumeTrue(CanConnect.to(host(), port(2)));
assumeTrue(CanConnect.to(host(), port(7)));

redis.set(key, value);
redis.set("key1", value);
redis.set("key2", value);
redis.set("key3", value);

String result = redis.migrate("localhost", TestSettings.port(2), 0, 10, MigrateArgs.Builder.keys(key).copy().replace());
String result = redis.migrate("localhost", TestSettings.port(7), 0, 10, MigrateArgs.Builder.keys(key).copy().replace());
assertThat(result).isEqualTo("OK");

result = redis.migrate("localhost", TestSettings.port(2), 0, 10,
result = redis.migrate("localhost", TestSettings.port(7), 0, 10,
MigrateArgs.Builder.keys(Arrays.asList("key1", "key2")).replace());
assertThat(result).isEqualTo("OK");
}
Expand All @@ -109,9 +111,10 @@ void migrateCopyReplace() {
* redis.
*/
@Test
@Order(4)
void shutdown() {

assumeTrue(CanConnect.to(host(), port(2)));
assumeTrue(CanConnect.to(host(), port(7)));

final RedisAsyncCommands<String, String> commands = client.connect(RedisURI.Builder.redis(host(), port(2)).build())
.async();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import javax.inject.Inject;

import io.lettuce.core.*;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import io.lettuce.core.ReadFrom;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.TestSupport;
import io.lettuce.core.codec.StringCodec;
import io.lettuce.core.internal.HostAndPort;
import io.lettuce.core.resource.ClientResources;
Expand All @@ -19,7 +16,15 @@
import io.lettuce.test.resource.FastShutdown;
import io.lettuce.test.settings.TestSettings;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static io.lettuce.test.settings.TlsSettings.createAndSaveTestTruststore;

/**
* Integration test for Master/Replica using Redis Sentinel over SSL.
Expand All @@ -32,19 +37,33 @@ class MasterReplicaSentinelSslIntegrationTests extends TestSupport {

private final ClientResources clientResources;

private static File truststoreFile;

private static Map<Integer, Integer> portMap = new HashMap<>();
static {
portMap.put(26379, 26822);
portMap.put(6482, 8443);
portMap.put(6483, 8444);
}

@Inject
MasterReplicaSentinelSslIntegrationTests(ClientResources clientResources) {

this.clientResources = clientResources.mutate()
.socketAddressResolver(MappingSocketAddressResolver.create(DnsResolver.jvmDefault(), hostAndPort -> {
int port = hostAndPort.getPort();
if (portMap.containsKey(port)) {
return HostAndPort.of(hostAndPort.getHostText(), portMap.get(port));
}

return HostAndPort.of(hostAndPort.getHostText(), hostAndPort.getPort() + 443);
return hostAndPort;
})).build();
}

@Test
void testMasterReplicaSentinelBasic() {

RedisClient client = RedisClient.create(clientResources);

RedisURI redisURI = RedisURI.create("rediss-sentinel://" + TestSettings.host() + ":26379?sentinelMasterId=mymaster");
redisURI.setVerifyPeer(false);
StatefulRedisMasterReplicaConnection<String, String> connection = MasterReplica.connect(client, StringCodec.UTF8,
Expand Down
Loading