Improve reactor test (#4168)
This commit is contained in:
parent
2c9d6e313f
commit
6a91dae5a1
|
@ -10,21 +10,24 @@ 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:
|
||||
Mono<Connection> connection = Mono.create {
|
||||
it.success(new Connection())
|
||||
}
|
||||
CountDownLatch latch = new CountDownLatch(1)
|
||||
runWithSpan("parent") {
|
||||
Mono<Connection> connection = Mono.create {
|
||||
it.success(new Connection())
|
||||
}
|
||||
connection.subscribe {
|
||||
it.query()
|
||||
latch.countDown()
|
||||
}
|
||||
connection
|
||||
.delayElement(Duration.ofMillis(1))
|
||||
.subscribe {
|
||||
it.query()
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
latch.await()
|
||||
|
||||
|
@ -43,7 +46,6 @@ abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class Connection {
|
||||
|
|
Loading…
Reference in New Issue