Fix integration test
This commit is contained in:
parent
c8bbce0549
commit
cddd368fc0
|
@ -16,11 +16,10 @@ import java.time.Duration
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
class DDApiIntegrationTest {
|
|
||||||
// Do not run tests locally on Java7 since testcontainers are not compatible with Java7
|
// 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
|
// It is fine to run on CI because CI provides agent externally, not through testcontainers
|
||||||
@Requires({ "true" == System.getenv("CI") || jvm.java8Compatible })
|
@Requires({ "true" == System.getenv("CI") || jvm.java8Compatible })
|
||||||
static class DDAgentApiIntegrationV4Test extends DDSpecification {
|
class DDApiIntegrationTest extends DDSpecification {
|
||||||
static final WRITER = new ListWriter()
|
static final WRITER = new ListWriter()
|
||||||
static final TRACER = DDTracer.builder().writer(WRITER).build()
|
static final TRACER = DDTracer.builder().writer(WRITER).build()
|
||||||
static final CONTEXT = new DDSpanContext(
|
static final CONTEXT = new DDSpanContext(
|
||||||
|
@ -73,7 +72,7 @@ class DDApiIntegrationTest {
|
||||||
def setupSpec() {
|
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
|
When building locally, however, we need to take matters into our own hands
|
||||||
and we use 'testcontainers' for this.
|
and we use 'testcontainers' for this.
|
||||||
*/
|
*/
|
||||||
|
@ -99,7 +98,7 @@ class DDApiIntegrationTest {
|
||||||
File tmpDir = File.createTempDir()
|
File tmpDir = File.createTempDir()
|
||||||
tmpDir.deleteOnExit()
|
tmpDir.deleteOnExit()
|
||||||
socketPath = new File(tmpDir, "socket")
|
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() {
|
def cleanupSpec() {
|
||||||
|
@ -110,24 +109,18 @@ class DDApiIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
def setup() {
|
def setup() {
|
||||||
api = new DDAgentApi(agentContainerHost, agentContainerPort, v4(), null)
|
api = new DDAgentApi(agentContainerHost, agentContainerPort, null)
|
||||||
api.addResponseListener(responseListener)
|
api.addResponseListener(responseListener)
|
||||||
|
|
||||||
unixDomainSocketApi = new DDAgentApi(SOMEHOST, SOMEPORT, v4(), socketPath.toString())
|
unixDomainSocketApi = new DDAgentApi(SOMEHOST, SOMEPORT, socketPath.toString())
|
||||||
unixDomainSocketApi.addResponseListener(responseListener)
|
unixDomainSocketApi.addResponseListener(responseListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean v4() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
def "Sending traces succeeds (test #test)"() {
|
def "Sending traces succeeds (test #test)"() {
|
||||||
expect:
|
expect:
|
||||||
api.sendTraces(traces)
|
api.sendTraces(traces)
|
||||||
if (v4()) {
|
|
||||||
assert endpoint.get() == "http://${agentContainerHost}:${agentContainerPort}/v0.4/traces"
|
assert endpoint.get() == "http://${agentContainerHost}:${agentContainerPort}/v0.4/traces"
|
||||||
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
|
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
|
||||||
}
|
|
||||||
|
|
||||||
where:
|
where:
|
||||||
traces | test
|
traces | test
|
||||||
|
@ -145,10 +138,8 @@ class DDApiIntegrationTest {
|
||||||
def "Sending traces to unix domain socket succeeds (test #test)"() {
|
def "Sending traces to unix domain socket succeeds (test #test)"() {
|
||||||
expect:
|
expect:
|
||||||
unixDomainSocketApi.sendTraces(traces)
|
unixDomainSocketApi.sendTraces(traces)
|
||||||
if (v4()) {
|
|
||||||
assert endpoint.get() == "http://${SOMEHOST}:${SOMEPORT}/v0.4/traces"
|
assert endpoint.get() == "http://${SOMEHOST}:${SOMEPORT}/v0.4/traces"
|
||||||
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
|
assert agentResponse.get() == [rate_by_service: ["service:,env:": 1]]
|
||||||
}
|
|
||||||
|
|
||||||
where:
|
where:
|
||||||
traces | test
|
traces | test
|
||||||
|
@ -158,16 +149,3 @@ class DDApiIntegrationTest {
|
||||||
[[new DDSpan(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()), CONTEXT)]] | 4
|
[[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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue