Skip to content

Commit 686f72e

Browse files
prydintrask
authored andcommitted
Fixed test issues (#62)
1 parent 80d3690 commit 686f72e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

java-agent/instrumentation/datastax-cassandra-3/src/test/groovy/CassandraClientTest.groovy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class CassandraClientTest extends AgentTestRunner {
1818

1919
@Shared
2020
Cluster cluster
21-
@Shared
22-
int port = 9142
2321

2422
def setupSpec() {
2523
/*
@@ -28,7 +26,7 @@ class CassandraClientTest extends AgentTestRunner {
2826
started in container like we do for memcached. Note: this will complicate things because
2927
tests would have to assume they run under shared Cassandra and act accordingly.
3028
*/
31-
EmbeddedCassandraServerHelper.startEmbeddedCassandra(120000L)
29+
EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE, 120000L)
3230

3331
cluster = EmbeddedCassandraServerHelper.getCluster()
3432

@@ -124,7 +122,7 @@ class CassandraClientTest extends AgentTestRunner {
124122
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
125123
"$Tags.PEER_HOSTNAME" "localhost"
126124
"$Tags.PEER_HOST_IPV4" "127.0.0.1"
127-
"$Tags.PEER_PORT" port
125+
"$Tags.PEER_PORT" EmbeddedCassandraServerHelper.getNativeTransportPort()
128126
"$Tags.DB_TYPE" "cassandra"
129127
"$Tags.DB_INSTANCE" keyspace
130128
"$Tags.DB_STATEMENT" statement

java-agent/instrumentation/dropwizard/src/test/groovy/DropwizardTest.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator
1111
import io.opentelemetry.auto.instrumentation.servlet3.Servlet3Decorator
1212
import io.opentelemetry.auto.test.asserts.TraceAssert
1313
import io.opentelemetry.auto.test.base.HttpServerTest
14+
import io.opentelemetry.auto.test.utils.PortUtils
1415
import io.opentelemetry.sdk.trace.SpanData
1516
import org.eclipse.jetty.servlet.ServletHandler
1617

@@ -29,9 +30,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport, Servlet3Decor
2930

3031
@Override
3132
DropwizardTestSupport startServer(int port) {
33+
println "Port: $port"
3234
def testSupport = new DropwizardTestSupport(testApp(),
3335
null,
34-
ConfigOverride.config("server.applicationConnectors[0].port", "$port"))
36+
ConfigOverride.config("server.applicationConnectors[0].port", "$port"),
37+
ConfigOverride.config("server.adminConnectors[0].port", PortUtils.randomOpenPort().toString()))
3538
testSupport.before()
3639
return testSupport
3740
}

java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Netty40ClientTest extends HttpClientTest<NettyHttpClientDecorator> {
6161

6262
def "connection error (unopened port)"() {
6363
given:
64-
def uri = new URI("http://localhost:$UNUSABLE_PORT/")
64+
def uri = new URI("http://127.0.0.1:$UNUSABLE_PORT/") // Use numeric address to avoid ipv4/ipv6 confusion
6565

6666
when:
6767
runUnderTrace("parent") {
@@ -93,7 +93,7 @@ class Netty40ClientTest extends HttpClientTest<NettyHttpClientDecorator> {
9393
} catch (ClassNotFoundException e) {
9494
// Older versions use 'java.net.ConnectException' and do not have 'io.netty.channel.AbstractChannel$AnnotatedConnectException'
9595
}
96-
errorTags errorClass, "Connection refused: localhost/127.0.0.1:$UNUSABLE_PORT"
96+
errorTags errorClass, "Connection refused: /127.0.0.1:$UNUSABLE_PORT"
9797
}
9898
}
9999
}

0 commit comments

Comments
 (0)