Second attempt at fixing flaky spring rabbit test (#9809)

This commit is contained in:
Lauri Tulmin 2023-11-06 16:50:16 +02:00 committed by GitHub
parent dbe90c5fcf
commit f811bf6840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import io.opentelemetry.instrumentation.testing.GlobalTraceUtil;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.SemanticAttributes;
import java.time.Duration;
import java.util.ArrayList;
@ -178,7 +179,27 @@ public class ContextPropagationTest {
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
getAssertions("testQueue", "process", null, false, testHeaders)),
span -> span.hasName("consumer").hasParent(trace.getSpan(3)));
span -> {
// occasionally "testQueue process" spans have their order swapped, usually
// it would be
// 0 - parent
// 1 - <default> publish
// 2 - testQueue process (<default>)
// 3 - testQueue process (testQueue)
// 4 - consumer
// but it could also be
// 0 - parent
// 1 - <default> publish
// 2 - testQueue process (testQueue)
// 3 - consumer
// 4 - testQueue process (<default>)
// determine the correct parent span based on the span name
SpanData parentSpan = trace.getSpan(3);
if (!"testQueue process".equals(parentSpan.getName())) {
parentSpan = trace.getSpan(2);
}
span.hasName("consumer").hasParent(parentSpan);
});
},
trace -> {
trace