Improve reactor test
@@ -10,18 +10,21 @@ import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import reactor.core.publisher.Mono
+import java.time.Duration
import java.util.concurrent.CountDownLatch
abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
def "subscription test"() {
when:
- CountDownLatch latch = new CountDownLatch(1)
- runWithSpan("parent") {
Mono<Connection> connection = Mono.create {
it.success(new Connection())
}
- connection.subscribe {
+ CountDownLatch latch = new CountDownLatch(1)
+ runWithSpan("parent") {
+ connection
+ .delayElement(Duration.ofMillis(1))
+ .subscribe {
it.query()
latch.countDown()
}
@@ -43,7 +46,6 @@ abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
}
}
}
-
}
static class Connection {
