Fixed test issues
MODIFY
java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy
java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy
@@ -18,8 +18,6 @@ class CassandraClientTest extends AgentTestRunner {
@Shared
Cluster cluster
- @Shared
- int port = 9142
def setupSpec() {
/*
@@ -28,7 +26,7 @@ class CassandraClientTest extends AgentTestRunner {
started in container like we do for memcached. Note: this will complicate things because
tests would have to assume they run under shared Cassandra and act accordingly.
*/
- EmbeddedCassandraServerHelper.startEmbeddedCassandra(120000L)
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE, 120000L)
cluster = EmbeddedCassandraServerHelper.getCluster()
@@ -124,7 +122,7 @@ class CassandraClientTest extends AgentTestRunner {
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
"$Tags.PEER_HOSTNAME" "localhost"
"$Tags.PEER_HOST_IPV4" "127.0.0.1"
- "$Tags.PEER_PORT" port
+ "$Tags.PEER_PORT" EmbeddedCassandraServerHelper.getNativeTransportPort()
"$Tags.DB_TYPE" "cassandra"
"$Tags.DB_INSTANCE" keyspace
"$Tags.DB_STATEMENT" statement

MODIFY
java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy
java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy
@@ -11,6 +11,7 @@ import io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator
import io.opentelemetry.auto.instrumentation.servlet3.Servlet3Decorator
import io.opentelemetry.auto.test.asserts.TraceAssert
import io.opentelemetry.auto.test.base.HttpServerTest
+import io.opentelemetry.auto.test.utils.PortUtils
import io.opentelemetry.sdk.trace.SpanData
import org.eclipse.jetty.servlet.ServletHandler
@@ -29,9 +30,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport, Servlet3Decor
@Override
DropwizardTestSupport startServer(int port) {
+ println "Port: $port"
def testSupport = new DropwizardTestSupport(testApp(),
null,
- ConfigOverride.config("server.applicationConnectors[0].port", "$port"))
+ ConfigOverride.config("server.applicationConnectors[0].port", "$port"),
+ ConfigOverride.config("server.adminConnectors[0].port", PortUtils.randomOpenPort().toString()))
testSupport.before()
return testSupport
}

MODIFY
java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy
java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy
@@ -61,7 +61,7 @@ class Netty40ClientTest extends HttpClientTest<NettyHttpClientDecorator> {
def "connection error (unopened port)"() {
given:
- def uri = new URI("http://localhost:$UNUSABLE_PORT/")
+ def uri = new URI("http://127.0.0.1:$UNUSABLE_PORT/") // Use numeric address to avoid ipv4/ipv6 confusion
when:
runUnderTrace("parent") {
@@ -93,7 +93,7 @@ class Netty40ClientTest extends HttpClientTest<NettyHttpClientDecorator> {
} catch (ClassNotFoundException e) {
// Older versions use 'java.net.ConnectException' and do not have 'io.netty.channel.AbstractChannel$AnnotatedConnectException'
}
- errorTags errorClass, "Connection refused: localhost/127.0.0.1:$UNUSABLE_PORT"
+ errorTags errorClass, "Connection refused: /127.0.0.1:$UNUSABLE_PORT"
}
}
}

Fixed test issues (#62)