Use async requests for high concurrency test. (#3534)
This commit is contained in:
parent
7969bdf18e
commit
9be9e40556
|
@ -35,7 +35,6 @@ import io.opentelemetry.testing.internal.armeria.common.HttpRequest
|
||||||
import io.opentelemetry.testing.internal.armeria.common.HttpRequestBuilder
|
import io.opentelemetry.testing.internal.armeria.common.HttpRequestBuilder
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import spock.lang.Unroll
|
import spock.lang.Unroll
|
||||||
|
|
||||||
@Unroll
|
@Unroll
|
||||||
|
@ -390,9 +389,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
|
||||||
int count = 100
|
int count = 100
|
||||||
def endpoint = INDEXED_CHILD
|
def endpoint = INDEXED_CHILD
|
||||||
|
|
||||||
def latch = new CountDownLatch(1)
|
def latch = new CountDownLatch(count)
|
||||||
|
|
||||||
def pool = Executors.newFixedThreadPool(4)
|
|
||||||
def propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator()
|
def propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator()
|
||||||
def setter = { HttpRequestBuilder carrier, String name, String value ->
|
def setter = { HttpRequestBuilder carrier, String name, String value ->
|
||||||
carrier.header(name, value)
|
carrier.header(name, value)
|
||||||
|
@ -400,22 +398,19 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
|
||||||
|
|
||||||
when:
|
when:
|
||||||
count.times { index ->
|
count.times { index ->
|
||||||
def job = {
|
HttpRequestBuilder request = HttpRequest.builder()
|
||||||
latch.await()
|
// Force HTTP/1 via h1c so upgrade requests don't show up as traces
|
||||||
HttpRequestBuilder request = HttpRequest.builder()
|
.get(endpoint.resolvePath(address).toString().replace("http://", "h1c://"))
|
||||||
// Force HTTP/1 via h1c so upgrade requests don't show up as traces
|
.queryParam(ServerEndpoint.ID_PARAMETER_NAME, "$index")
|
||||||
.get(endpoint.resolvePath(address).toString().replace("http://", "h1c://"))
|
runUnderTrace("client " + index) {
|
||||||
.queryParam(ServerEndpoint.ID_PARAMETER_NAME, "$index")
|
Span.current().setAttribute(ServerEndpoint.ID_ATTRIBUTE_NAME, index)
|
||||||
runUnderTrace("client " + index) {
|
propagator.inject(Context.current(), request, setter)
|
||||||
Span.current().setAttribute(ServerEndpoint.ID_ATTRIBUTE_NAME, index)
|
client.execute(request.build()).aggregate().thenRun {
|
||||||
propagator.inject(Context.current(), request, setter)
|
latch.countDown()
|
||||||
client.execute(request.build()).aggregate().join()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pool.submit(job)
|
|
||||||
}
|
}
|
||||||
latch.countDown()
|
latch.await()
|
||||||
|
|
||||||
then:
|
then:
|
||||||
assertTraces(count) {
|
assertTraces(count) {
|
||||||
|
@ -442,9 +437,6 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
pool.shutdownNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: add tests for POST with large/chunked data
|
//FIXME: add tests for POST with large/chunked data
|
||||||
|
|
Loading…
Reference in New Issue