Skip to content

Commit

Permalink
bump lettuce version used in test module to allow access to protocol …
Browse files Browse the repository at this point in the history
…control
  • Loading branch information
jaydeluca committed Oct 18, 2023
1 parent a6466c1 commit 912e3df
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class LettuceSyncClientTest extends AbstractLettuceSyncClientTest {
@RegisterExtension
static final InstrumentationExtension agentTesting = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Override
public InstrumentationExtension getInstrumentationExtension() {
return agentTesting;
return testing;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import org.junit.jupiter.api.extension.RegisterExtension;

class LettuceSyncClientTest extends AbstractLettuceSyncClientTest {

@RegisterExtension
static final InstrumentationExtension agentTesting = LibraryInstrumentationExtension.create();
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@Override
public InstrumentationExtension getInstrumentationExtension() {
return agentTesting;
return testing;
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/lettuce/lettuce-5.1/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ plugins {
dependencies {
api(project(":testing-common"))

api("io.lettuce:lettuce-core:5.1.0.RELEASE")
// 6.0+ added protocolVersion access which allows forcing RESP2 for consistency in tests
compileOnly("io.lettuce:lettuce-core:6.0.0.RELEASE")

implementation("org.testcontainers:testcontainers")
implementation("com.google.guava:guava")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ abstract class AbstractLettuceClientTest {
protected static final Logger logger = LoggerFactory.getLogger(AbstractLettuceClientTest.class);

@RegisterExtension
protected static final InstrumentationExtension agentTesting =
AgentInstrumentationExtension.create();
protected static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

public InstrumentationExtension getInstrumentationExtension() {
return agentTesting;
return testing;
}

@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();
Expand Down Expand Up @@ -68,11 +67,6 @@ protected ContainerConnection newContainerConnection() {
StatefulRedisConnection<String, String> statefulConnection = client.connect();
cleanup.deferCleanup(statefulConnection);

if (Boolean.getBoolean("testLatestDeps")) {
// 1 HELLO (in lettuce 6+)
getInstrumentationExtension().waitForTraces(1);
}
getInstrumentationExtension().clearData();
return new ContainerConnection(statefulConnection, serverPort);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,8 @@ void setUp() {
syncCommands.set("TESTKEY", "TESTVAL");
syncCommands.hmset("TESTHM", testHashMap);

if (Boolean.getBoolean("testLatestDeps")) {
// 1 HELLO (in lettuce 6+) and 2 sets
getInstrumentationExtension().waitForTraces(3);
} else {
// 2 sets
getInstrumentationExtension().waitForTraces(2);
}
// 2 sets
getInstrumentationExtension().waitForTraces(2);
getInstrumentationExtension().clearData();
}

Expand Down Expand Up @@ -138,12 +133,6 @@ void testSetCommandLocalhost() {
StatefulRedisConnection<String, String> testConnection = testConnectionClient.connect();
cleanup.deferCleanup(testConnection);

if (Boolean.getBoolean("testLatestDeps")) {
// 1 HELLO (in lettuce 6+)
getInstrumentationExtension().waitForTraces(1);
getInstrumentationExtension().clearData();
}

String res = testConnection.sync().set("TESTSETKEY", "TESTSETVAL");
assertThat(res).isEqualTo("OK");

Expand Down Expand Up @@ -244,7 +233,7 @@ void testCommandWithNoArguments() {

@Test
void testListCommand() {
// Needs its own container or inconsistent command count
// Needs its own container or flaky from inconsistent command count
ContainerConnection containerConnection = newContainerConnection();
RedisCommands<String, String> commands = containerConnection.connection.sync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.lettuce.v5_1;

import io.lettuce.core.ClientOptions;
import io.lettuce.core.protocol.ProtocolVersion;

final class LettuceTestClientUtil {
static final ClientOptions CLIENT_OPTIONS;
Expand All @@ -17,7 +18,7 @@ final class LettuceTestClientUtil {
.autoReconnect(false);
if (Boolean.getBoolean("testLatestDeps")) {
// Force RESP2 on 6+ for consistency in tests
options.pingBeforeActivateConnection(false);
options.pingBeforeActivateConnection(false).protocolVersion(ProtocolVersion.RESP2);
}
CLIENT_OPTIONS = options.build();
}
Expand Down

0 comments on commit 912e3df

Please sign in to comment.