Skip to content

Commit

Permalink
Expand coverage of matrix smoke test, enable tomee test (#279)
Browse files Browse the repository at this point in the history
* Add ReceiveSendGreetingServlet and publish wf for matric project

* Add donation doc to readme and missing license header

* remove gson dependency and customer models

* undo changes in test till new docker images are published

* Make byte read wo need to buffer size

* Expand coverage of matrix smoke test, enable tomee test

* Remove JaegerExporterSmokeTest.groovy
  • Loading branch information
samarth-gupta-traceable authored Feb 26, 2021
1 parent 23728e5 commit ab7de69
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import org.testcontainers.containers.wait.strategy.WaitStrategy

@Ignore
@AppServer(version = "5.2020.6", jdk = "8")
@AppServer(version = "5.2020.6-jdk11", jdk = "11")
@AppServer(version = "5.2020.6", jdk = "8-openj9")
@AppServer(version = "5.2020.6", jdk = "11")
@AppServer(version = "5.2020.6", jdk = "11-openj9")
class GlassFishSmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:payara-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:payara-${serverVersion}-jdk$jdk-20210226.602156580"
}

@Override
Expand All @@ -42,4 +44,4 @@ class GlassFishSmokeTest extends AppServerTest {
false
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GrpcSmokeTest extends SmokeTest {
startTarget(jdk)

def channel = ManagedChannelBuilder.forAddress("localhost", target.getMappedPort(8080))
.usePlaintext()
.build()
.usePlaintext()
.build()
def stub = TraceServiceGrpc.newBlockingStub(channel)

when:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@
package org.hypertrace.agent.smoketest

@AppServer(version = "9.4.35", jdk = "8")
@AppServer(version = "9.4.35", jdk = "8-openj9")
@AppServer(version = "9.4.35", jdk = "11")
@AppServer(version = "9.4.35", jdk = "11-openj9")
@AppServer(version = "10.0.0", jdk = "11")
@AppServer(version = "10.0.0", jdk = "11-openj9")
@AppServer(version = "10.0.0", jdk = "15")
@AppServer(version = "10.0.0", jdk = "15-openj9")
class JettySmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:jetty-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:jetty-${serverVersion}-jdk$jdk-20210226.602156580"
}

def getJettySpanName() {
return serverVersion.startsWith("10.") ? "HandlerList.handle" : "HandlerCollection.handle"
if (serverVersion == "9.4.35") {
//this need to be present till we sync HT java agent with at least v.0.18.x of OTEL which uniformly returns
//HandlerWrapper.handle
"HandlerCollection.handle"
}
else {
"HandlerList.handle"
}
}

@Override
Expand All @@ -28,4 +39,4 @@ class JettySmokeTest extends AppServerTest {
}
return path
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class LibertyServletOnlySmokeTest extends LibertySmokeTest {
protected void customizeContainer(GenericContainer container) {
container.withClasspathResourceMapping("liberty-servlet.xml", "/config/server.xml", BindMode.READ_ONLY)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.containers.wait.strategy.WaitStrategy

@AppServer(version = "20.0.0.12", jdk = "8")
@AppServer(version = "20.0.0.12", jdk = "8-openj9")
@AppServer(version = "20.0.0.12", jdk = "11")
@AppServer(version = "20.0.0.12", jdk = "8-jdk-openj9")
@AppServer(version = "20.0.0.12", jdk = "11-jdk-openj9")
@AppServer(version = "20.0.0.12", jdk = "11-openj9")
class LibertySmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:liberty-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:liberty-${serverVersion}-jdk$jdk-20210226.602156580"
}

@Override
Expand All @@ -33,6 +33,7 @@ class LibertySmokeTest extends AppServerTest {
case "/app/headers":
case "/app/exception":
case "/app/asyncgreeting":
case "/app/echo":
return path
}
return 'HTTP GET'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ import spock.lang.Shared
import spock.lang.Specification

abstract class SmokeTest extends Specification {
private static final Pattern TRACE_ID_PATTERN = Pattern.compile(".*traceId=(?<traceId>[a-zA-Z0-9]+).*")
private static final Pattern TRACE_ID_PATTERN = Pattern.compile(".*trace_id=(?<traceId>[a-zA-Z0-9]+).*")

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()

protected static final OkHttpClient CLIENT = OkHttpUtils.client()

@Shared
private Network network = Network.newNetwork()
private Backend backend = Backend.getInstance()

@Shared
protected String agentPath = System.getProperty("smoketest.javaagent.path")

Expand All @@ -61,31 +62,8 @@ abstract class SmokeTest extends Specification {
protected void customizeContainer(GenericContainer container) {
}

@Shared
private GenericContainer backend

@Shared
private GenericContainer collector

def setupSpec() {
backend = new GenericContainer<>("ghcr.io/open-telemetry/java-test-containers:smoke-fake-backend-20201128.1734635")
.withExposedPorts(8080)
.waitingFor(Wait.forHttp("/health").forPort(8080))
.withNetwork(network)
.withNetworkAliases("backend")
.withImagePullPolicy(PullPolicy.alwaysPull())
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("smoke.tests.backend")))
backend.start()

collector = new GenericContainer<>("otel/opentelemetry-collector-dev:latest")
.dependsOn(backend)
.withNetwork(network)
.withNetworkAliases("collector")
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("smoke.tests.collector")))
.withImagePullPolicy(PullPolicy.alwaysPull())
.withCopyFileToContainer(MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml")
.withCommand("--config /etc/otel.yaml")
collector.start()
backend.setup()
}

def startTarget(int jdk, String serverVersion = null) {
Expand All @@ -96,13 +74,13 @@ abstract class SmokeTest extends Specification {
def output = new ToStringConsumer()
target = new GenericContainer<>(getTargetImage(jdk, serverVersion))
.withExposedPorts(8080)
.withNetwork(network)
.withNetwork(backend.network)
.withLogConsumer(output)
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("smoke.tests.target")))
.withCopyFileToContainer(MountableFile.forHostPath(agentPath), "/hypertrace-agent-all.jar")
.withEnv("JAVA_TOOL_OPTIONS", "-javaagent:/hypertrace-agent-all.jar -Dorg.hypertrace.agent.slf4j.simpleLogger.log.muzzleMatcher=true")
.withEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "1")
.withEnv("OTEL_BSP_SCHEDULE_DELAY_MILLIS", "10")
.withEnv("OTEL_BSP_SCHEDULE_DELAY", "10")
.withEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector:55680")
.withEnv("HT_SERVICE_NAME", "CIService")
.withEnv("HT_REPORTING_ENDPOINT", "http://collector:9411/api/v2/spans")
Expand Down Expand Up @@ -137,9 +115,7 @@ abstract class SmokeTest extends Specification {
}

def cleanupSpec() {
backend.stop()
collector.stop()
network.close()
backend.cleanup()
}

protected static Stream<AnyValue> findResourceAttribute(Collection<ExportTraceServiceRequest> traces,
Expand Down Expand Up @@ -247,4 +223,59 @@ abstract class SmokeTest extends Specification {
}
return encoding
}
}

static class Backend {
private static final INSTANCE = new Backend()

private final Network network = Network.newNetwork()
private GenericContainer backend
private GenericContainer collector

boolean started = false

static Backend getInstance() {
return INSTANCE
}

def setup() {
// we start backend & collector once for all tests
if (started) {
return
}
started = true
Runtime.addShutdownHook { stop() }

backend = new GenericContainer<>("ghcr.io/open-telemetry/java-test-containers:smoke-fake-backend-20201128.1734635")
.withExposedPorts(8080)
.waitingFor(Wait.forHttp("/health").forPort(8080))
.withNetwork(network)
.withNetworkAliases("backend")
.withImagePullPolicy(PullPolicy.alwaysPull())
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("smoke.tests.backend")))
backend.start()

collector = new GenericContainer<>("otel/opentelemetry-collector-dev:latest")
.dependsOn(backend)
.withNetwork(network)
.withNetworkAliases("collector")
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("smoke.tests.collector")))
.withImagePullPolicy(PullPolicy.alwaysPull())
.withCopyFileToContainer(MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml")
.withCommand("--config /etc/otel.yaml")
collector.start()
}

int getMappedPort(int originalPort) {
return backend.getMappedPort(originalPort)
}

def cleanup() {
}

def stop() {
backend?.stop()
collector?.stop()
network?.close()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
package org.hypertrace.agent.smoketest

@AppServer(version = "7.0.107", jdk = "8")
@AppServer(version = "7.0.107", jdk = "8-openj9")
@AppServer(version = "8.5.60", jdk = "8")
@AppServer(version = "8.5.60", jdk = "8-openj9")
@AppServer(version = "8.5.60", jdk = "11")
@AppServer(version = "8.5.60", jdk = "11-openj9")
@AppServer(version = "9.0.40", jdk = "8")
@AppServer(version = "9.0.40", jdk = "8-openj9")
@AppServer(version = "9.0.40", jdk = "11")
@AppServer(version = "9.0.40", jdk = "11-openj9")
class TomcatSmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:tomcat-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:tomcat-${serverVersion}-jdk$jdk-20210226.602156580"
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ import java.time.Duration
import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.containers.wait.strategy.WaitStrategy

@Ignore
@AppServer(version = "7.0.0", jdk = "8")
@AppServer(version = "7.0.0", jdk = "8-openj9")
@AppServer(version = "8.0.6", jdk = "8")
@AppServer(version = "8.0.6", jdk = "8-openj9")
@AppServer(version = "8.0.6", jdk = "11")
@AppServer(version = "8.0.6", jdk = "11-openj9")
class TomeeSmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:tomee-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:tomee-${serverVersion}-jdk$jdk-20210226.602156580"
}

@Override
protected WaitStrategy getWaitStrategy() {
return Wait
.forLogMessage(".*Server startup in.*", 1)
.withStartupTimeout(Duration.ofMinutes(3))
.forLogMessage(".*Server startup in.*", 1)
.withStartupTimeout(Duration.ofMinutes(3))
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import okhttp3.Request
import spock.lang.Unroll

@AppServer(version = "13.0.0.Final", jdk = "8")
@AppServer(version = "13.0.0.Final", jdk = "8-openj9")
@AppServer(version = "17.0.1.Final", jdk = "11")
@AppServer(version = "17.0.1.Final", jdk = "11-openj9")
@AppServer(version = "21.0.0.Final", jdk = "11")
@AppServer(version = "21.0.0.Final", jdk = "11-openj9")
class WildflySmokeTest extends AppServerTest {

protected String getTargetImage(String jdk, String serverVersion) {
"hypertrace/java-agent-test-containers:wildfly-${serverVersion}-jdk$jdk-20210224.596496007"
"hypertrace/java-agent-test-containers:wildfly-${serverVersion}-jdk$jdk-20210226.602156580"
}

@Override
Expand Down

0 comments on commit ab7de69

Please sign in to comment.