From 84bc413d68e1ad0d8f153c676df4891a24c53dbc Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 21 Sep 2021 12:33:01 -0700 Subject: [PATCH] Remove collector from smoke tests (#4186) --- .../pr-smoke-test-fake-backend-images.yml | 2 +- .../example/javaagent/DemoPropertySource.java | 2 +- examples/distro/settings.gradle | 3 +- .../javaagent/smoketest/SmokeTest.java | 13 ----- .../smoke-tests/src/test/resources/otel.yaml | 30 ---------- .../example/javaagent/DemoPropertySource.java | 2 +- .../javaagent/smoketest/IntegrationTest.java | 13 ----- .../extension/src/test/resources/otel.yaml | 30 ---------- smoke-tests/fake-backend/build.gradle | 35 +----------- .../src/docker/collector/windows.dockerfile | 4 -- .../smoketest/JaegerExporterSmokeTest.groovy | 56 ------------------- .../smoketest/ZipkinExporterSmokeTest.groovy | 52 ----------------- .../AbstractTestContainerManager.java | 3 +- .../smoketest/LinuxTestContainerManager.java | 18 ------ .../windows/WindowsTestContainerManager.java | 35 ------------ smoke-tests/src/test/resources/otel.yaml | 40 ------------- 16 files changed, 7 insertions(+), 331 deletions(-) delete mode 100644 examples/distro/smoke-tests/src/test/resources/otel.yaml delete mode 100644 examples/extension/src/test/resources/otel.yaml delete mode 100644 smoke-tests/fake-backend/src/docker/collector/windows.dockerfile delete mode 100644 smoke-tests/src/test/groovy/io/opentelemetry/smoketest/JaegerExporterSmokeTest.groovy delete mode 100644 smoke-tests/src/test/groovy/io/opentelemetry/smoketest/ZipkinExporterSmokeTest.groovy delete mode 100644 smoke-tests/src/test/resources/otel.yaml diff --git a/.github/workflows/pr-smoke-test-fake-backend-images.yml b/.github/workflows/pr-smoke-test-fake-backend-images.yml index 6d468a6dd1ea..f7573010ecab 100644 --- a/.github/workflows/pr-smoke-test-fake-backend-images.yml +++ b/.github/workflows/pr-smoke-test-fake-backend-images.yml @@ -67,5 +67,5 @@ jobs: key: ${{ runner.os }}-gradle-wrapper-cache-${{ hashFiles('smoke-tests/fake-backend/gradle/wrapper/gradle-wrapper.properties') }} - name: Build Docker Image - run: ./gradlew windowsBackendImageBuild windowsCollectorImageBuild + run: ./gradlew windowsBackendImageBuild working-directory: smoke-tests/fake-backend diff --git a/examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java b/examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java index 809d812f3aea..97d0c768aa30 100644 --- a/examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java +++ b/examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java @@ -14,7 +14,7 @@ public class DemoPropertySource implements ConfigPropertySource { @Override public Map getProperties() { return Map.of( - "otel.exporter.otlp.endpoint", "http://collector:4317", + "otel.exporter.otlp.endpoint", "http://backend:8080", "otel.exporter.otlp.insecure", "true", "otel.config.max.attrs", "16"); } diff --git a/examples/distro/settings.gradle b/examples/distro/settings.gradle index 3fe07b603592..c0c40708a6ff 100644 --- a/examples/distro/settings.gradle +++ b/examples/distro/settings.gradle @@ -1,8 +1,7 @@ -rootProject.name = 'opentelemetry-java-instrumentation-demo' +rootProject.name = 'opentelemetry-java-instrumentation-distro-demo' include "agent" include "custom" include "instrumentation" include "instrumentation:servlet-3" include "smoke-tests" - diff --git a/examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java b/examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java index 09efec91d6f7..c4d24bfec62d 100644 --- a/examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java +++ b/examples/distro/smoke-tests/src/test/java/com/example/javaagent/smoketest/SmokeTest.java @@ -47,7 +47,6 @@ protected Map getExtraEnv() { } private static GenericContainer backend; - private static GenericContainer collector; @BeforeAll static void setupSpec() { @@ -60,17 +59,6 @@ static void setupSpec() { .withNetworkAliases("backend") .withLogConsumer(new Slf4jLogConsumer(logger)); backend.start(); - - collector = - new GenericContainer<>("otel/opentelemetry-collector-contrib:latest") - .dependsOn(backend) - .withNetwork(network) - .withNetworkAliases("collector") - .withLogConsumer(new Slf4jLogConsumer(logger)) - .withCopyFileToContainer( - MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml") - .withCommand("--config /etc/otel.yaml"); - collector.start(); } protected GenericContainer target; @@ -109,7 +97,6 @@ void stopTarget() { @AfterAll static void cleanupSpec() { backend.stop(); - collector.stop(); } protected static int countResourcesByValue( diff --git a/examples/distro/smoke-tests/src/test/resources/otel.yaml b/examples/distro/smoke-tests/src/test/resources/otel.yaml deleted file mode 100644 index 3be594aafa5e..000000000000 --- a/examples/distro/smoke-tests/src/test/resources/otel.yaml +++ /dev/null @@ -1,30 +0,0 @@ -extensions: - health_check: - pprof: - endpoint: 0.0.0.0:1777 - zpages: - endpoint: 0.0.0.0:55679 - -receivers: - otlp: - protocols: - grpc: - -processors: - batch: - -exporters: - logging: - loglevel: debug - otlp: - endpoint: backend:8080 - insecure: true - -service: - pipelines: - traces: - receivers: [ otlp ] - processors: [ batch ] - exporters: [ logging, otlp ] - - extensions: [ health_check, pprof, zpages ] diff --git a/examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java b/examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java index 21b41483b019..2f432369b372 100644 --- a/examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java +++ b/examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java @@ -16,7 +16,7 @@ public class DemoPropertySource implements ConfigPropertySource { @Override public Map getProperties() { return Map.of( - "otel.exporter.otlp.endpoint", "http://collector:4317", + "otel.exporter.otlp.endpoint", "http://backend:8080", "otel.exporter.otlp.insecure", "true", "otel.config.max.attrs", "16"); } diff --git a/examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java b/examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java index 32f5a9532e50..e9945e67872f 100644 --- a/examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java +++ b/examples/extension/src/test/java/com/example/javaagent/smoketest/IntegrationTest.java @@ -52,7 +52,6 @@ protected Map getExtraEnv() { } private static GenericContainer backend; - private static GenericContainer collector; @BeforeAll static void setupSpec() { @@ -65,17 +64,6 @@ static void setupSpec() { .withNetworkAliases("backend") .withLogConsumer(new Slf4jLogConsumer(logger)); backend.start(); - - collector = - new GenericContainer<>("otel/opentelemetry-collector-contrib:latest") - .dependsOn(backend) - .withNetwork(network) - .withNetworkAliases("collector") - .withLogConsumer(new Slf4jLogConsumer(logger)) - .withCopyFileToContainer( - MountableFile.forClasspathResource("/otel.yaml"), "/etc/otel.yaml") - .withCommand("--config /etc/otel.yaml"); - collector.start(); } protected GenericContainer target; @@ -136,7 +124,6 @@ void stopTarget() { @AfterAll static void cleanupSpec() { backend.stop(); - collector.stop(); } protected static int countResourcesByValue( diff --git a/examples/extension/src/test/resources/otel.yaml b/examples/extension/src/test/resources/otel.yaml deleted file mode 100644 index 3be594aafa5e..000000000000 --- a/examples/extension/src/test/resources/otel.yaml +++ /dev/null @@ -1,30 +0,0 @@ -extensions: - health_check: - pprof: - endpoint: 0.0.0.0:1777 - zpages: - endpoint: 0.0.0.0:55679 - -receivers: - otlp: - protocols: - grpc: - -processors: - batch: - -exporters: - logging: - loglevel: debug - otlp: - endpoint: backend:8080 - insecure: true - -service: - pipelines: - traces: - receivers: [ otlp ] - processors: [ batch ] - exporters: [ logging, otlp ] - - extensions: [ health_check, pprof, zpages ] diff --git a/smoke-tests/fake-backend/build.gradle b/smoke-tests/fake-backend/build.gradle index 938b92c2d2cd..8d2608f4d79c 100644 --- a/smoke-tests/fake-backend/build.gradle +++ b/smoke-tests/fake-backend/build.gradle @@ -62,40 +62,9 @@ task windowsBackendImageBuild(type: DockerBuildImage) { it.dockerFile = new File(backendDockerBuildDir, "windows.dockerfile") } -def collectorDockerBuildDir = new File(project.buildDir, "docker-collector") - -task windowsCollectorBinaryDownload(type: Download) { - doFirst { - collectorDockerBuildDir.mkdirs() - } - - // TODO (trask) update this to point to new opentelemetry-collector-releases repo - // this involves making two further changes: - // * all the artifacts in the new repo now have version in their name (so no single url for "latest") - // * the artifacts are now tar.gz format, so need to extract the exe - // note: version is hardcoded below because that is last version in the collector repo that has the releases attached - src("https://github.com/open-telemetry/opentelemetry-collector/releases/download/v0.33.0/otelcol_windows_amd64.exe") - dest(collectorDockerBuildDir) -} - -task windowsCollectorImagePrepare(type: Copy) { - dependsOn(windowsCollectorBinaryDownload) - into(collectorDockerBuildDir) - from("src/docker/collector") -} - -task windowsCollectorImageBuild(type: DockerBuildImage) { - dependsOn(windowsCollectorImagePrepare) - inputDir = collectorDockerBuildDir - - it.images.add "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-collector-windows:$extraTag" - it.dockerFile = new File(collectorDockerBuildDir, "windows.dockerfile") -} - tasks.create("dockerPush", DockerPushImage) { group = "publishing" description = "Push all Docker images for the test backend" - dependsOn(windowsBackendImageBuild, windowsCollectorImageBuild) - images.set(["ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-fake-backend-windows:$extraTag", - "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-collector-windows:$extraTag"]) + dependsOn(windowsBackendImageBuild) + images.set(["ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-fake-backend-windows:$extraTag"]) } diff --git a/smoke-tests/fake-backend/src/docker/collector/windows.dockerfile b/smoke-tests/fake-backend/src/docker/collector/windows.dockerfile deleted file mode 100644 index dc2ad5855e7b..000000000000 --- a/smoke-tests/fake-backend/src/docker/collector/windows.dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2019 -COPY otelcol_windows_amd64.exe /otelcol_windows_amd64.exe -ENV NO_WINDOWS_SERVICE=1 -ENTRYPOINT /otelcol_windows_amd64.exe diff --git a/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/JaegerExporterSmokeTest.groovy b/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/JaegerExporterSmokeTest.groovy deleted file mode 100644 index 579072c1e6dc..000000000000 --- a/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/JaegerExporterSmokeTest.groovy +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.smoketest - -import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest -import spock.lang.IgnoreIf - -import java.util.jar.Attributes -import java.util.jar.JarFile - -import static java.util.stream.Collectors.toSet - -@IgnoreIf({ os.windows }) -class JaegerExporterSmokeTest extends SmokeTest { - - protected String getTargetImage(String jdk) { - "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210915.1238472439" - } - - @Override - protected Map getExtraEnv() { - return [ - "OTEL_TRACES_EXPORTER" : "jaeger", - "OTEL_EXPORTER_JAEGER_ENDPOINT": "http://collector:14250" - ] - } - - def "spring boot smoke test with jaeger grpc"() { - setup: - startTarget(11) - - def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION) - - when: - def response = client().get("/greeting").aggregate().join() - Collection traces = waitForTraces() - - then: - response.contentUtf8() == "Hi!" - countSpansByName(traces, '/greeting') == 1 - countSpansByName(traces, 'WebController.greeting') == 1 - countSpansByName(traces, 'WebController.withSpan') == 1 - - [currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version") - .map { it.stringValue } - .collect(toSet()) - - cleanup: - stopTarget() - - } - -} diff --git a/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/ZipkinExporterSmokeTest.groovy b/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/ZipkinExporterSmokeTest.groovy deleted file mode 100644 index a617ba6c76b6..000000000000 --- a/smoke-tests/src/test/groovy/io/opentelemetry/smoketest/ZipkinExporterSmokeTest.groovy +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.smoketest - -import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest -import spock.lang.IgnoreIf - -@IgnoreIf({ os.windows }) -class ZipkinExporterSmokeTest extends SmokeTest { - - protected String getTargetImage(String jdk) { - "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210915.1238472439" - } - - @Override - protected Map getExtraEnv() { - return [ - "OTEL_TRACES_EXPORTER" : "zipkin", - "OTEL_EXPORTER_ZIPKIN_ENDPOINT": "http://collector:9411/api/v2/spans" - ] - } - - def "spring boot smoke test with Zipkin"() { - setup: - startTarget(11) - - // def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION) - - when: - def response = client().get("/greeting").aggregate().join() - Collection traces = waitForTraces() - - then: - response.contentUtf8() == "Hi!" - countSpansByName(traces, '/greeting') == 1 - countSpansByName(traces, 'webcontroller.greeting') == 1 - countSpansByName(traces, 'webcontroller.withspan') == 1 - - //This is currently broken, see https://github.com/open-telemetry/opentelemetry-java/issues/1970 -// [currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version") -// .map { it.stringValue } -// .collect(toSet()) - - cleanup: - stopTarget() - - } - -} diff --git a/smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java b/smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java index d461074858bf..f1d64c1203da 100644 --- a/smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java +++ b/smoke-tests/src/test/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java @@ -13,7 +13,6 @@ public abstract class AbstractTestContainerManager implements TestContainerManag protected static final int BACKEND_PORT = 8080; protected static final String BACKEND_ALIAS = "backend"; - protected static final String COLLECTOR_ALIAS = "collector"; protected static final String TARGET_AGENT_FILENAME = "opentelemetry-javaagent.jar"; protected static final String COLLECTOR_CONFIG_RESOURCE = "/otel.yaml"; @@ -28,7 +27,7 @@ protected Map getAgentEnvironment(String jvmArgsEnvVarName) { environment.put("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "1"); environment.put("OTEL_BSP_SCHEDULE_DELAY", "10ms"); environment.put("OTEL_IMR_EXPORT_INTERVAL", "1000"); - environment.put("OTEL_EXPORTER_OTLP_ENDPOINT", "http://" + COLLECTOR_ALIAS + ":4317"); + environment.put("OTEL_EXPORTER_OTLP_ENDPOINT", "http://" + BACKEND_ALIAS + ":8080"); environment.put("OTEL_RESOURCE_ATTRIBUTES", "service.name=smoke-test"); environment.put("OTEL_JAVAAGENT_DEBUG", "true"); return environment; diff --git a/smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java b/smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java index 75821509234f..0d7b65c10d37 100644 --- a/smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java +++ b/smoke-tests/src/test/java/io/opentelemetry/smoketest/LinuxTestContainerManager.java @@ -22,12 +22,10 @@ public class LinuxTestContainerManager extends AbstractTestContainerManager { private static final Logger logger = LoggerFactory.getLogger(LinuxTestContainerManager.class); - private static final Logger collectorLogger = LoggerFactory.getLogger("Collector"); private static final Logger backendLogger = LoggerFactory.getLogger("Backend"); private final Network network = Network.newNetwork(); private GenericContainer backend = null; - private GenericContainer collector = null; private GenericContainer target = null; @Override @@ -42,17 +40,6 @@ protected void startEnvironment() { .withNetworkAliases(BACKEND_ALIAS) .withLogConsumer(new Slf4jLogConsumer(backendLogger)); backend.start(); - - collector = - new GenericContainer<>(DockerImageName.parse("otel/opentelemetry-collector-contrib:latest")) - .dependsOn(backend) - .withNetwork(network) - .withNetworkAliases(COLLECTOR_ALIAS) - .withLogConsumer(new Slf4jLogConsumer(collectorLogger)) - .withCopyFileToContainer( - MountableFile.forClasspathResource(COLLECTOR_CONFIG_RESOURCE), "/etc/otel.yaml") - .withCommand("--config /etc/otel.yaml"); - collector.start(); } @Override @@ -62,11 +49,6 @@ protected void stopEnvironment() { backend = null; } - if (collector != null) { - collector.stop(); - collector = null; - } - network.close(); } diff --git a/smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java b/smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java index 8f73c1834918..fd770830c458 100644 --- a/smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java +++ b/smoke-tests/src/test/java/io/opentelemetry/smoketest/windows/WindowsTestContainerManager.java @@ -52,11 +52,9 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager { private static final Logger logger = LoggerFactory.getLogger(WindowsTestContainerManager.class); - private static final Logger collectorLogger = LoggerFactory.getLogger("Collector"); private static final Logger backendLogger = LoggerFactory.getLogger("Backend"); private static final String NPIPE_URI = "npipe:////./pipe/docker_engine"; - private static final String COLLECTOR_CONFIG_FILE_PATH = "/collector-config.yml"; private final DockerClient client = DockerClientImpl.getInstance( @@ -65,7 +63,6 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager { @Nullable private String natNetworkId = null; @Nullable private Container backend; - @Nullable private Container collector; @Nullable private Container target; @Override @@ -104,44 +101,12 @@ protected void startEnvironment() { new HttpWaiter(BACKEND_PORT, "/health", Duration.ofSeconds(60)), /* inspect= */ true, backendLogger); - - String collectorImageName = - "ghcr.io/open-telemetry/java-test-containers:collector" + backendSuffix; - if (!imageExists(collectorImageName)) { - pullImage(collectorImageName); - } - collector = - startContainer( - collectorImageName, - command -> - command - .withAliases(COLLECTOR_ALIAS) - .withHostConfig( - HostConfig.newHostConfig() - .withAutoRemove(true) - .withNetworkMode(natNetworkId)) - .withCmd("--config", COLLECTOR_CONFIG_FILE_PATH), - containerId -> { - try (InputStream configFileStream = - this.getClass().getResourceAsStream(COLLECTOR_CONFIG_RESOURCE)) { - copyFileToContainer( - containerId, IOUtils.toByteArray(configFileStream), COLLECTOR_CONFIG_FILE_PATH); - } catch (IOException e) { - throw new IllegalStateException(e); - } - }, - new NoOpWaiter(), - /* inspect= */ false, - collectorLogger); } @Override protected void stopEnvironment() { stopTarget(); - killContainer(collector); - collector = null; - killContainer(backend); backend = null; diff --git a/smoke-tests/src/test/resources/otel.yaml b/smoke-tests/src/test/resources/otel.yaml deleted file mode 100644 index d6a6b2b539bf..000000000000 --- a/smoke-tests/src/test/resources/otel.yaml +++ /dev/null @@ -1,40 +0,0 @@ -extensions: - health_check: - pprof: - endpoint: 0.0.0.0:1777 - zpages: - endpoint: 0.0.0.0:55679 - -receivers: - otlp: - protocols: - grpc: - zipkin: - jaeger: - protocols: - grpc: - -processors: - batch: - -exporters: - logging/logging_debug: - loglevel: debug - logging/logging_info: - loglevel: info - otlp: - endpoint: backend:8080 - insecure: true - -service: - pipelines: - traces: - receivers: [ otlp, zipkin, jaeger ] - processors: [ batch ] - exporters: [ logging/logging_debug, otlp ] - metrics: - receivers: [ otlp ] - processors: [ batch ] - exporters: [ logging/logging_info, otlp ] - - extensions: [ health_check, pprof, zpages ]