Allow the mock http server get assigned a transient port (DataDog/dd-trace-java#1540)
This change should eradicate the spurious test failures due to port conflicts - at least for the profiling smoke tests.
MODIFY
smoke-tests/cli/src/test/groovy/io/opentelemetry/smoketest/CliApplicationSmokeTest.groovy
smoke-tests/cli/src/test/groovy/io/opentelemetry/smoketest/CliApplicationSmokeTest.groovy
@@ -40,6 +40,6 @@ class CliApplicationSmokeTest extends AbstractSmokeTest {
@Timeout(value = TIMEOUT_SECS, unit = TimeUnit.SECONDS)
def "Cli application process ends before timeout"() {
expect:
- assert serverProcess.waitFor() == 0
+ assert testedProcess.waitFor() == 0
}
}

MODIFY
smoke-tests/java9-modules/src/test/groovy/io/opentelemetry/smoketest/Java9ModulesSmokeTest.groovy
smoke-tests/java9-modules/src/test/groovy/io/opentelemetry/smoketest/Java9ModulesSmokeTest.groovy
@@ -42,6 +42,6 @@ class Java9ModulesSmokeTest extends AbstractSmokeTest {
@Timeout(value = TIMEOUT_SECS, unit = TimeUnit.SECONDS)
def "Module application runs correctly"() {
expect:
- assert serverProcess.waitFor() == 0
+ assert testedProcess.waitFor() == 0
}
}

MODIFY
smoke-tests/src/main/groovy/io/opentelemetry/smoketest/AbstractServerSmokeTest.groovy
smoke-tests/src/main/groovy/io/opentelemetry/smoketest/AbstractServerSmokeTest.groovy
@@ -33,7 +33,7 @@ abstract class AbstractServerSmokeTest extends AbstractSmokeTest {
def setupSpec() {
try {
- PortUtils.waitForPortToOpen(httpPort, 240, TimeUnit.SECONDS, serverProcess)
+ PortUtils.waitForPortToOpen(httpPort, 240, TimeUnit.SECONDS, testedProcess)
} catch (e) {
System.err.println(logfile.text)
throw e

MODIFY
smoke-tests/src/main/groovy/io/opentelemetry/smoketest/AbstractSmokeTest.groovy
smoke-tests/src/main/groovy/io/opentelemetry/smoketest/AbstractSmokeTest.groovy
*/
package io.opentelemetry.smoketest
-import io.opentelemetry.auto.test.utils.PortUtils
+
import spock.lang.Shared
import spock.lang.Specification
@@ -27,14 +27,12 @@ abstract class AbstractSmokeTest extends Specification {
protected String buildDirectory = System.getProperty("io.opentelemetry.smoketest.builddir")
@Shared
protected String shadowJarPath = System.getProperty("io.opentelemetry.smoketest.agent.shadowJar.path")
- @Shared
- protected int profilingPort
- @Shared
- protected String profilingUrl
+
@Shared
protected String[] defaultJavaProperties
@Shared
- protected Process serverProcess
+ protected Process testedProcess
+
@Shared
protected String exporterPath = System.getProperty("ota.exporter.jar")
@@ -52,9 +50,6 @@ abstract class AbstractSmokeTest extends Specification {
throw new AssertionError("Expected system properties not found. Smoke tests have to be run from Gradle. Please make sure that is the case.")
}
- profilingPort = PortUtils.randomOpenPort()
- profilingUrl = "http://localhost:${profilingPort}/"
-
defaultJavaProperties = [
"-javaagent:${shadowJarPath}",
"-Dio.opentelemetry.auto.slf4j.simpleLogger.defaultLogLevel=debug",
@@ -74,9 +69,7 @@ abstract class AbstractSmokeTest extends Specification {
logfile = new File("${buildDirectory}/reports/testProcess.${this.getClass().getName()}.log")
processBuilder.redirectOutput(ProcessBuilder.Redirect.to(logfile))
- serverProcess = processBuilder.start()
-
-
+ testedProcess = processBuilder.start()
}
String javaPath() {
@@ -85,7 +78,7 @@ abstract class AbstractSmokeTest extends Specification {
}
def cleanupSpec() {
- serverProcess?.waitForOrKill(1)
+ testedProcess?.waitForOrKill(1)
}
abstract ProcessBuilder createProcessBuilder()

Allow the mock http server get assigned a transient port (DataDog/dd-trace-java#1540)

This change should eradicate the spurious test failures due to port conflicts - at least for the profiling smoke tests.