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 io.opentelemetry.instrumentation.test.InstrumentationSpecification
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
|
|
||||||
|
import java.time.Duration
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
|
abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
|
||||||
|
|
||||||
def "subscription test"() {
|
def "subscription test"() {
|
||||||
when:
|
when:
|
||||||
|
Mono<Connection> connection = Mono.create {
|
||||||
|
it.success(new Connection())
|
||||||
|
}
|
||||||
CountDownLatch latch = new CountDownLatch(1)
|
CountDownLatch latch = new CountDownLatch(1)
|
||||||
runWithSpan("parent") {
|
runWithSpan("parent") {
|
||||||
Mono<Connection> connection = Mono.create {
|
connection
|
||||||
it.success(new Connection())
|
.delayElement(Duration.ofMillis(1))
|
||||||
}
|
.subscribe {
|
||||||
connection.subscribe {
|
it.query()
|
||||||
it.query()
|
latch.countDown()
|
||||||
latch.countDown()
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
latch.await()
|
latch.await()
|
||||||
|
|
||||||
|
@ -43,7 +46,6 @@ abstract class AbstractSubscriptionTest extends InstrumentationSpecification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Connection {
|
static class Connection {
|
||||||
|
|
Loading…
Reference in New Issue