diff --git a/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java b/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java index 35f85db08317..417de8c61d62 100644 --- a/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java +++ b/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java @@ -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 diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/test/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java b/instrumentation/lettuce/lettuce-5.1/library/src/test/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java index a211963a10fa..7bfb8e452769 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/test/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/test/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceSyncClientTest.java @@ -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 diff --git a/instrumentation/lettuce/lettuce-5.1/testing/build.gradle.kts b/instrumentation/lettuce/lettuce-5.1/testing/build.gradle.kts index e8780d1fa018..fae109de6c07 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/build.gradle.kts +++ b/instrumentation/lettuce/lettuce-5.1/testing/build.gradle.kts @@ -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") diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceClientTest.java b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceClientTest.java index e029bc258f04..4e465d1fd91d 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceClientTest.java +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceClientTest.java @@ -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(); @@ -68,11 +67,6 @@ protected ContainerConnection newContainerConnection() { StatefulRedisConnection 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); } diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java index ac83291714d1..47f1c94840c1 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.java @@ -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(); } @@ -138,12 +133,6 @@ void testSetCommandLocalhost() { StatefulRedisConnection 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"); @@ -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 commands = containerConnection.connection.sync(); diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceTestClientUtil.java b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceTestClientUtil.java index e04c436c707c..b77684609183 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceTestClientUtil.java +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceTestClientUtil.java @@ -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; @@ -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(); }