diff --git a/java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy b/java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy index 7dae164d44..8ec49d7512 100644 --- a/java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy +++ b/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 diff --git a/java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy b/java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy index 1f5e79cab8..f8b43f615d 100644 --- a/java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy +++ b/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 { 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 { } 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" } } }