Fix integration test

This commit is contained in:
Nikolay Martynov 2020-02-20 09:26:33 -05:00
parent c8bbce0549
commit cddd368fc0
1 changed files with 115 additions and 137 deletions

View File

@ -16,11 +16,10 @@ import java.time.Duration
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicReference
class DDApiIntegrationTest {
// Do not run tests locally on Java7 since testcontainers are not compatible with Java7
// It is fine to run on CI because CI provides rabbitmq externally, not through testcontainers
@Requires({ "true" == System.getenv("CI") || jvm.java8Compatible })
static class DDAgentApiIntegrationV4Test extends DDSpecification {
// Do not run tests locally on Java7 since testcontainers are not compatible with Java7
// It is fine to run on CI because CI provides agent externally, not through testcontainers
@Requires({ "true" == System.getenv("CI") || jvm.java8Compatible })
class DDApiIntegrationTest extends DDSpecification {
static final WRITER = new ListWriter()
static final TRACER = DDTracer.builder().writer(WRITER).build()
static final CONTEXT = new DDSpanContext(
@ -73,7 +72,7 @@ class DDApiIntegrationTest {
def setupSpec() {
/*
CI will provide us with rabbitmq container running along side our build.
CI will provide us with agent container running along side our build.
When building locally, however, we need to take matters into our own hands
and we use 'testcontainers' for this.
*/
@ -99,7 +98,7 @@ class DDApiIntegrationTest {
File tmpDir = File.createTempDir()
tmpDir.deleteOnExit()
socketPath = new File(tmpDir, "socket")
process = Runtime.getRuntime().exec("socat UNIX-LISTEN:${socketPath},reuseaddr,fork TCP-CONNECT:${agentContainerHost}:${agentContainerPort}")
process = Runtime.getRuntime().exec("socat UNIX-LISEN:${socketPath},reuseaddr,fork TCP-CONNECT:${agentContainerHost}:${agentContainerPort}")
}
def cleanupSpec() {
@ -110,24 +109,18 @@ class DDApiIntegrationTest {
}
def setup() {
api = new DDAgentApi(agentContainerHost, agentContainerPort, v4(), null)
api = new DDAgentApi(agentContainerHost, agentContainerPort, null)
api.addResponseListener(responseListener)
unixDomainSocketApi = new DDAgentApi(SOMEHOST, SOMEPORT, v4(), socketPath.toString())
unixDomainSocketApi = new DDAgentApi(SOMEHOST, SOMEPORT, socketPath.toString())
unixDomainSocketApi.addResponseListener(responseListener)
}
boolean v4() {
return true
}
def "Sending traces succeeds (test #test)"() {
expect:
api.sendTraces(traces)
if (v4()) {
assert endpoint.get() == "http://${agentContainerHost}:${agentContainerPort}/v0.4/traces"
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
}
where:
traces | test
@ -145,10 +138,8 @@ class DDApiIntegrationTest {
def "Sending traces to unix domain socket succeeds (test #test)"() {
expect:
unixDomainSocketApi.sendTraces(traces)
if (v4()) {
assert endpoint.get() == "http://${SOMEHOST}:${SOMEPORT}/v0.4/traces"
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
}
where:
traces | test
@ -157,17 +148,4 @@ class DDApiIntegrationTest {
[[new DDSpan(1, CONTEXT)]] | 3
[[new DDSpan(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), CONTEXT)]] | 4
}
}
@Requires({ "true" == System.getenv("CI") || jvm.java8Compatible })
static class DDAgentApiIntegrationV3Test extends DDAgentApiIntegrationV4Test {
boolean v4() {
return false
}
def cleanup() {
assert endpoint.get() == null
assert agentResponse.get() == null
}
}
}