Skip to content

Commit

Permalink
Merge branch 'main' into metro_30
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Oct 19, 2023
2 parents bb138f3 + ccb2955 commit f951148
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public class RedissonClientTest extends AbstractRedissonClientTest {
protected boolean useRedisProtocol() {
return true;
}

@Override
protected boolean lockHas3Traces() {
return Boolean.getBoolean("testLatestDeps");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
import static io.opentelemetry.instrumentation.testing.util.TelemetryDataUtil.orderByRootSpanName;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
import static java.util.regex.Pattern.compile;
import static java.util.regex.Pattern.quote;
import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.testing.assertj.TraceAssert;
import io.opentelemetry.semconv.SemanticAttributes;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.junit.Assume;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -75,7 +77,7 @@ static void cleanupAll() {
}

@BeforeEach
void setup() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
void setup() throws InvocationTargetException, IllegalAccessException {
String newAddress = address;
if (useRedisProtocol()) {
// Newer versions of redisson require scheme, older versions forbid it
Expand All @@ -91,8 +93,7 @@ void setup() throws NoSuchMethodException, InvocationTargetException, IllegalAcc
.getClass()
.getMethod("setPingConnectionInterval", int.class)
.invoke(singleServerConfig, 0);
} catch (NoSuchMethodException e) {
logger.warn("no setPingConnectionInterval method", e);
} catch (NoSuchMethodException ignored) {
}
redisson = Redisson.create(config);
testing.clearData();
Expand Down Expand Up @@ -364,24 +365,9 @@ void lockCommand() {
} finally {
lock.unlock();
}
// Use .* to match the actual script, since it changes between redisson versions
// everything that does not change is quoted so that it's matched literally
String lockPattern = compile("^" + quote("EVAL ") + ".*" + quote(" 1 lock ? ?")).toString();

String unlockPattern =
compile(
"^"
+ quote("EVAL ")
+ ".*"
+ quote(" 2 lock ")
+ "\\S+"
+ "("
+ quote(" ?")
+ ")+$")
.toString();

testing.waitAndAssertSortedTraces(
orderByRootSpanKind(SpanKind.CLIENT),
List<Consumer<TraceAssert>> traceAsserts = new ArrayList<>();
traceAsserts.add(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
Expand All @@ -395,7 +381,8 @@ void lockCommand() {
equalTo(SemanticAttributes.DB_OPERATION, "EVAL"),
satisfies(
SemanticAttributes.DB_STATEMENT,
stringAssert -> stringAssert.containsPattern(lockPattern)))),
stringAssert -> stringAssert.startsWith("EVAL")))));
traceAsserts.add(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
Expand All @@ -409,13 +396,36 @@ void lockCommand() {
equalTo(SemanticAttributes.DB_OPERATION, "EVAL"),
satisfies(
SemanticAttributes.DB_STATEMENT,
stringAssert -> stringAssert.containsPattern(unlockPattern)))));
stringAssert -> stringAssert.startsWith("EVAL")))));
if (lockHas3Traces()) {
traceAsserts.add(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName("DEL")
.hasKind(CLIENT)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.NET_SOCK_PEER_ADDR, "127.0.0.1"),
equalTo(SemanticAttributes.NET_SOCK_PEER_NAME, "localhost"),
equalTo(SemanticAttributes.NET_SOCK_PEER_PORT, (long) port),
equalTo(SemanticAttributes.DB_SYSTEM, "redis"),
equalTo(SemanticAttributes.DB_OPERATION, "DEL"),
satisfies(
SemanticAttributes.DB_STATEMENT,
stringAssert -> stringAssert.startsWith("DEL")))));
}

testing.waitAndAssertSortedTraces(orderByRootSpanKind(SpanKind.CLIENT), traceAsserts);
}

protected boolean useRedisProtocol() {
return Boolean.getBoolean("testLatestDeps");
}

protected boolean lockHas3Traces() {
return false;
}

protected RBatch createBatch(RedissonClient redisson) {
return redisson.createBatch(BatchOptions.defaults());
}
Expand Down
4 changes: 2 additions & 2 deletions smoke-tests/images/quarkus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ plugins {
id("otel.java-conventions")

id("com.google.cloud.tools.jib")
id("io.quarkus") version "3.4.3"
id("io.quarkus") version "3.5.0"
}

dependencies {
implementation(enforcedPlatform("io.quarkus:quarkus-bom:3.4.3"))
implementation(enforcedPlatform("io.quarkus:quarkus-bom:3.5.0"))
implementation("io.quarkus:quarkus-resteasy")
}

Expand Down

0 comments on commit f951148

Please sign in to comment.