Wait for span to finish instead of ignoring test
This commit is contained in:
parent
387f094617
commit
e52c654fd1
|
@ -1,21 +1,14 @@
|
||||||
import datadog.trace.agent.test.base.HttpClientTest
|
import datadog.trace.agent.test.base.HttpClientTest
|
||||||
import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator
|
import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator
|
||||||
|
import io.opentracing.util.GlobalTracer
|
||||||
import org.apache.http.client.methods.HttpGet
|
import org.apache.http.client.methods.HttpGet
|
||||||
import org.apache.http.impl.nio.client.HttpAsyncClients
|
import org.apache.http.impl.nio.client.HttpAsyncClients
|
||||||
import org.apache.http.message.BasicHeader
|
import org.apache.http.message.BasicHeader
|
||||||
import org.junit.Ignore
|
|
||||||
import spock.lang.AutoCleanup
|
import spock.lang.AutoCleanup
|
||||||
import spock.lang.Shared
|
import spock.lang.Shared
|
||||||
|
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: we would like not to ugnore this test, but currently this test is flaky
|
|
||||||
* The problem is that http-request span is closed asynchronously and when we provide no callback (like 39)
|
|
||||||
* we cannot synchronise on when it is closed. Possible soltion here would be to rewrite this to not run
|
|
||||||
* tests will callbacks somehow because they make no sense in 'fire-and-forget' scenarios.
|
|
||||||
*/
|
|
||||||
@Ignore
|
|
||||||
class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest<ApacheHttpAsyncClientDecorator> {
|
class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest<ApacheHttpAsyncClientDecorator> {
|
||||||
|
|
||||||
@AutoCleanup
|
@AutoCleanup
|
||||||
|
@ -41,6 +34,10 @@ class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest<ApacheHttpAsy
|
||||||
Future future = client.execute(request, null)
|
Future future = client.execute(request, null)
|
||||||
future.get()
|
future.get()
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
// Request span is closed asynchronously even in regards to returned future so we have to wait here.
|
||||||
|
if (GlobalTracer.get().activeSpan() != null) {
|
||||||
|
blockUntilChildSpansFinished(1)
|
||||||
|
}
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
return 200
|
return 200
|
||||||
|
|
Loading…
Reference in New Issue