From a59fd523e3269489b5122823c5160137f53ab19c Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 19 Jun 2024 15:39:59 -0400 Subject: [PATCH 01/77] Initial work to integrate OpenTelemtry Signed-off-by: dhoard --- jmx_prometheus_common/pom.xml | 4 + .../common/configuration/ValidateIsURL.java | 62 ++++++++ .../jmx/common/http/HTTPServerFactory.java | 18 ++- .../OpenTelemetryMetricsExporter.java | 139 ++++++++++++++++++ .../java/io/prometheus/jmx/WebServer.java | 10 +- .../java/io/prometheus/jmx/JavaAgent.java | 7 +- pom.xml | 5 + 7 files changed, 242 insertions(+), 3 deletions(-) create mode 100644 jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ValidateIsURL.java create mode 100644 jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java diff --git a/jmx_prometheus_common/pom.xml b/jmx_prometheus_common/pom.xml index 95c242ae..2d7ff9c1 100644 --- a/jmx_prometheus_common/pom.xml +++ b/jmx_prometheus_common/pom.xml @@ -78,6 +78,10 @@ io.prometheus prometheus-metrics-exporter-httpserver + + io.prometheus + prometheus-metrics-exporter-opentelemetry + io.prometheus.jmx collector diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ValidateIsURL.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ValidateIsURL.java new file mode 100644 index 00000000..6a7416d4 --- /dev/null +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ValidateIsURL.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 The Prometheus jmx_exporter Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.prometheus.jmx.common.configuration; + +import io.prometheus.jmx.common.util.Precondition; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * Class to validate a String is not blank, throwing a RuntimeException from the Supplier if there + * is a ClassCastException + */ +public class ValidateIsURL implements Function { + + private final Supplier supplier; + + /** + * Constructor + * + * @param supplier supplier + */ + public ValidateIsURL(Supplier supplier) { + Precondition.notNull(supplier); + this.supplier = supplier; + } + + /** + * Method to apply a function + * + * @param value value + * @return the return value + */ + @Override + public String apply(String value) { + if (value.trim().isEmpty()) { + throw supplier.get(); + } + + try { + new URL(value); + return value; + } catch (MalformedURLException e) { + throw supplier.get(); + } + } +} diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java index db967d07..cf2b3802 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java @@ -88,7 +88,7 @@ public class HTTPServerFactory { private YamlMapAccessor rootYamlMapAccessor; /** Constructor */ - public HTTPServerFactory() { + private HTTPServerFactory() { // DO NOTHING } @@ -123,6 +123,15 @@ public HTTPServer createHTTPServer( return httpServerBuilder.buildAndStart(); } + /** + * Method to get an instance of the HTTPServerFactory + * + * @return the HTTPServerFactory + */ + public static HTTPServerFactory getInstance() { + return SingletonHolder.SINGLETON; + } + /** * Method to create a MapAccessor for accessing YAML configuration * @@ -639,4 +648,11 @@ public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolEx } } } + + /** Class to hold the singleton */ + private static class SingletonHolder { + + /** The singleton */ + public static final HTTPServerFactory SINGLETON = new HTTPServerFactory(); + } } diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java new file mode 100644 index 00000000..0f0ce146 --- /dev/null +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java @@ -0,0 +1,139 @@ +package io.prometheus.jmx.common.opentelemetry; + +import static java.lang.String.format; + +import io.prometheus.jmx.common.configuration.ConvertToInteger; +import io.prometheus.jmx.common.configuration.ConvertToMapAccessor; +import io.prometheus.jmx.common.configuration.ConvertToString; +import io.prometheus.jmx.common.configuration.ValidateIntegerInRange; +import io.prometheus.jmx.common.configuration.ValidateIsURL; +import io.prometheus.jmx.common.configuration.ValidateStringIsNotBlank; +import io.prometheus.jmx.common.http.ConfigurationException; +import io.prometheus.jmx.common.yaml.YamlMapAccessor; +import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.util.Map; +import org.yaml.snakeyaml.Yaml; + +/** Class to implement a OpenTelemetry exporter */ +public class OpenTelemetryMetricsExporter { + + private OpenTelemetryExporter openTelemetryExporter; + + /** + * Method to initialize the OpenTelemetry exporter + * + * @param exporterYamlFile exporterYamlFile + * @throws ConfigurationException ConfigurationException + */ + public void initialize(File exporterYamlFile) throws ConfigurationException { + try { + try (Reader reader = new FileReader(exporterYamlFile)) { + Map yamlMap = new Yaml().load(reader); + YamlMapAccessor rootYamlMapAccessor = new YamlMapAccessor(yamlMap); + + if (rootYamlMapAccessor.containsPath("/openTelemetry")) { + YamlMapAccessor openTelemetryYamlMapAccessor = + rootYamlMapAccessor + .get("/openTelemetry") + .map( + new ConvertToMapAccessor( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry"))) + .orElseThrow( + ConfigurationException.supplier( + "Invalid configuration for /openTelemetry")); + + String endpoint = + openTelemetryYamlMapAccessor + .get("/endpoint") + .map( + new ConvertToString( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/endpoint" + + " must be a string"))) + .map( + new ValidateStringIsNotBlank( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/endpoint" + + " must not be blank"))) + .map( + new ValidateIsURL( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/endpoint" + + " must be a URL"))) + .orElseThrow( + ConfigurationException.supplier( + "/openTelemetry/endpoint a required string")); + + String protocol = + openTelemetryYamlMapAccessor + .get("/protocol") + .map( + new ConvertToString( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/protocol" + + " must be a string"))) + .map( + new ValidateStringIsNotBlank( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/protocol" + + " must not be blank"))) + .orElseThrow( + ConfigurationException.supplier( + "/openTelemetry/protocol a required string")); + + int interval = + openTelemetryYamlMapAccessor + .get("/interval") + .map( + new ConvertToInteger( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/interval" + + " must be an integer"))) + .map( + new ValidateIntegerInRange( + 1, + Integer.MAX_VALUE, + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/interval must be" + + " between greater than 0"))) + .orElse(1); + + openTelemetryExporter = + OpenTelemetryExporter.builder() + .endpoint(endpoint) + .protocol(protocol) + .intervalSeconds(interval) + .buildAndStart(); + } + } + } catch (IOException e) { + throw new ConfigurationException( + format("Exception loading file [%s]", exporterYamlFile), e); + } + } + + /** Method to close the OpenTelemetryMetricsExporter */ + public void close() { + if (openTelemetryExporter != null) { + try { + openTelemetryExporter.close(); + openTelemetryExporter = null; + } catch (Throwable t) { + // DO NOTHING + } + } + } +} diff --git a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java index 0b5864ec..ad52e11a 100644 --- a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java +++ b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java @@ -18,6 +18,7 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; +import io.prometheus.jmx.common.opentelemetry.OpenTelemetryMetricsExporter; import io.prometheus.metrics.exporter.httpserver.HTTPServer; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; @@ -53,16 +54,20 @@ public static void main(String[] args) throws Exception { .register(PrometheusRegistry.defaultRegistry); HTTPServer httpServer = null; + OpenTelemetryMetricsExporter openTelemetryMetricsExporter = null; try { httpServer = - new HTTPServerFactory() + HTTPServerFactory.getInstance() .createHTTPServer( InetAddress.getByName(host), port, PrometheusRegistry.defaultRegistry, new File(args[1])); + openTelemetryMetricsExporter = new OpenTelemetryMetricsExporter(); + openTelemetryMetricsExporter.initialize(new File(args[1])); + System.out.println( String.format( "%s | %s | INFO | %s | %s", @@ -79,6 +84,9 @@ public static void main(String[] args) throws Exception { System.err.println("Exception starting"); t.printStackTrace(); } finally { + if (openTelemetryMetricsExporter != null) { + openTelemetryMetricsExporter.close(); + } if (httpServer != null) { httpServer.close(); } diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index 408b7715..fbaf5203 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -18,6 +18,7 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; +import io.prometheus.jmx.common.opentelemetry.OpenTelemetryMetricsExporter; import io.prometheus.metrics.exporter.httpserver.HTTPServer; import io.prometheus.metrics.instrumentation.jvm.JvmMetrics; import io.prometheus.metrics.model.registry.PrometheusRegistry; @@ -39,6 +40,7 @@ public class JavaAgent { private static final String DEFAULT_HOST = "0.0.0.0"; private static HTTPServer httpServer; + private static OpenTelemetryMetricsExporter openTelemetryMetricsExporter; public static void agentmain(String agentArgument, Instrumentation instrumentation) throws Exception { @@ -58,12 +60,15 @@ public static void premain(String agentArgument, Instrumentation instrumentation String host = config.host != null ? config.host : DEFAULT_HOST; httpServer = - new HTTPServerFactory() + HTTPServerFactory.getInstance() .createHTTPServer( InetAddress.getByName(host), config.port, PrometheusRegistry.defaultRegistry, new File(config.file)); + + openTelemetryMetricsExporter = new OpenTelemetryMetricsExporter(); + openTelemetryMetricsExporter.initialize(new File(config.file)); } catch (Throwable t) { synchronized (System.err) { System.err.println("Failed to start Prometheus JMX Exporter"); diff --git a/pom.xml b/pom.xml index 21f31182..ea7fdd0c 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,11 @@ prometheus-metrics-exporter-httpserver ${prometheus.metrics.version} + + io.prometheus + prometheus-metrics-exporter-opentelemetry + ${prometheus.metrics.version} + From 1ee23d1d331b6002da4bc72229df3b0cfac0573e Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 19 Jun 2024 16:27:45 -0400 Subject: [PATCH 02/77] Initial OpenTelemetry integration tests Signed-off-by: dhoard --- .../test/opentelemetry/OpenTelemetryTest.java | 278 ++++++++++++++++++ .../OpenTelemetryTestArguments.java | 53 ++++ .../JavaAgent/application.sh | 6 + .../OpenTelemetryTest/JavaAgent/exporter.yaml | 2 + .../JavaAgent/prometheus.yml | 0 .../Standalone/application.sh | 13 + .../OpenTelemetryTest/Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 3 + .../Standalone/prometheus.yml | 0 9 files changed, 360 insertions(+) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java new file mode 100644 index 00000000..6450827c --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -0,0 +1,278 @@ +package io.prometheus.jmx.test.opentelemetry; + +import com.github.dockerjava.api.model.Ulimit; +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import org.antublue.test.engine.api.TestEngine; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; +import org.testcontainers.containers.wait.strategy.Wait; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Stream; + +public class OpenTelemetryTest { + + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:latest"; + private static final long MEMORY_BYTES = 1073741824; // 1GB + private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; + + private Network network; + private GenericContainer prometheusContainer; + private GenericContainer standaloneApplicationContainer; + private GenericContainer javaAgentApplicationContainer; + private GenericContainer standaloneExporterContainer; + + @TestEngine.Argument + public OpenTelemetryTestArguments openTelemetryTestArguments; + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:latest"); + + prometheusDockerImageNames.forEach(prometheusDockerImage -> DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + " / " + javaDockerImageName + " / " + jmxExporterMode, + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } + + @TestEngine.Prepare + public void prepare() { + // Get the Network and get the id to force the network creation + network = Network.newNetwork(); + network.getId(); + } + + @TestEngine.BeforeAll + public void beforeAll() throws Throwable { + switch (openTelemetryTestArguments.getJmxExporterMode()) { + case Standalone: { + setupStandalone(); + break; + } + case JavaAgent: { + setUpJavaAgent(); + break; + } + } + } + + @TestEngine.Test + public void testOpenTelemetry() throws Throwable { + System.out.println("testOpenTelemetry()"); + } + + @TestEngine.AfterAll + public void afterAll() { + if (javaAgentApplicationContainer != null) { + javaAgentApplicationContainer.close(); + } + + if (standaloneExporterContainer != null) { + standaloneExporterContainer.close(); + } + + if (standaloneApplicationContainer != null) { + standaloneApplicationContainer.close(); + } + + if (prometheusContainer != null) { + prometheusContainer.close(); + } + } + + @TestEngine.Conclude + public void conclude() { + if (network != null) { + network.close(); + } + } + + private void setUpJavaAgent() { + prometheusContainer = createPrometheusContainer(network, openTelemetryTestArguments.getPrometheusDockerImageName(), getClass().getName()); + javaAgentApplicationContainer = createJavaAgentApplicationContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); + + prometheusContainer.start(); + javaAgentApplicationContainer.start(); + } + + + private void setupStandalone() { + prometheusContainer = createPrometheusContainer(network, openTelemetryTestArguments.getPrometheusDockerImageName(), getClass().getName()); + standaloneApplicationContainer = createStandaloneApplicationContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); + standaloneExporterContainer = createStandaloneExporterContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); + + prometheusContainer.start(); + standaloneApplicationContainer.start(); + standaloneExporterContainer.start(); + } + + /** + * Method to create a Prometheus container + * + * @param network network + * @param prometheusDockerImageName prometheusDockerImageName + * @param testName testName + * @return the return value + */ + private static GenericContainer createPrometheusContainer(Network network, String prometheusDockerImageName, String testName) { + return new GenericContainer<>(prometheusDockerImageName) + .withExposedPorts(777) + .withNetwork(network) + .withClasspathResourceMapping( + testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) + .withStartupTimeout(Duration.ofMillis(30000)); + } + + /** + * Method to create an application container + * + * @param network network + * @param dockerImageName dockerImageName + * @param testName testName + * @return the return value + */ + private static GenericContainer createStandaloneApplicationContainer( + Network network, String dockerImageName, String testName) { + return new GenericContainer<>(dockerImageName) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh application.sh") + .withExposedPorts(9999) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("application") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } + + /** + * Method to create an exporter container + * + * @param network network + * @param dockerImageName dockerImageName + * @param testName testName + * @return the return value + */ + private static GenericContainer createStandaloneExporterContainer( + Network network, String dockerImageName, String testName) { + return new GenericContainer<>(dockerImageName) + .waitingFor(Wait.forListeningPort()) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh exporter.sh") + .withExposedPorts(8888) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("exporter") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } + + /** + * Method to create an application container + * + * @param network network + * @param dockerImageName dockerImageName + * @param testName testName + * @return the return value + */ + private static GenericContainer createJavaAgentApplicationContainer( + Network network, String dockerImageName, String testName) { + return new GenericContainer<>(dockerImageName) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh application.sh") + .withExposedPorts(8888) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("application") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java new file mode 100644 index 00000000..71e29a2f --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java @@ -0,0 +1,53 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.JmxExporterMode; +import org.antublue.test.engine.api.Argument; + +public class OpenTelemetryTestArguments implements Argument { + + private final String name; + private final String prometheusDockerImageName; + private final String javaDockerImageName; + private final JmxExporterMode jmxExporterMode; + + private OpenTelemetryTestArguments(String name, String prometheusDockerImageName, String javaDockerImageName, JmxExporterMode jmxExporterMode) { + this.name = name; + this.prometheusDockerImageName = prometheusDockerImageName; + this.javaDockerImageName = javaDockerImageName; + this.jmxExporterMode = jmxExporterMode; + } + + @Override + public String getName() { + return name; + } + + @Override + public OpenTelemetryTestArguments getPayload() { + return this; + } + + public String getPrometheusDockerImageName() { + return prometheusDockerImageName; + } + + public String getJavaDockerImageName() { + return javaDockerImageName; + } + + public JmxExporterMode getJmxExporterMode() { + return jmxExporterMode; + } + + @Override + public String toString() { + return String.format( + "TestArgument{name=[%s],dockerImageName=[%s],mode=[%s]}", + name, javaDockerImageName, jmxExporterMode); + } + + public static OpenTelemetryTestArguments of( + String name, String prometheusDockerImageName, String javaDockerImageName, JmxExporterMode jmxExporterMode) { + return new OpenTelemetryTestArguments(name, prometheusDockerImageName, javaDockerImageName, jmxExporterMode); + } +} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml new file mode 100644 index 00000000..cb19fee9 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml @@ -0,0 +1,2 @@ +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml new file mode 100644 index 00000000..e69de29b diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml new file mode 100644 index 00000000..67cbff69 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml @@ -0,0 +1,3 @@ +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml new file mode 100644 index 00000000..e69de29b From 3f87236278e331db7010026c5e67338985860d88 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 19 Jun 2024 17:16:26 -0400 Subject: [PATCH 03/77] Added Prometheus container Signed-off-by: dhoard --- .../test/opentelemetry/OpenTelemetryTest.java | 160 ++++++++++++------ .../OpenTelemetryTestArguments.java | 14 +- .../JavaAgent/prometheus.yml | 4 + .../Standalone/prometheus.yml | 4 + 4 files changed, 123 insertions(+), 59 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 6450827c..12b1f562 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -3,6 +3,10 @@ import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; @@ -10,16 +14,11 @@ import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; import org.testcontainers.containers.wait.strategy.Wait; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -import java.util.stream.Stream; - public class OpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:latest"; - private static final long MEMORY_BYTES = 1073741824; // 1GB + + private static final long MEMORY_BYTES = 1073741824; // 1 GB private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; private Network network; @@ -28,8 +27,7 @@ public class OpenTelemetryTest { private GenericContainer javaAgentApplicationContainer; private GenericContainer standaloneExporterContainer; - @TestEngine.Argument - public OpenTelemetryTestArguments openTelemetryTestArguments; + @TestEngine.Argument public OpenTelemetryTestArguments openTelemetryTestArguments; /** * Method to get the list of TestArguments @@ -41,20 +39,27 @@ public static Stream arguments() { List openTelemetryTestArguments = new ArrayList<>(); List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:latest"); + prometheusDockerImageNames.add(PROMETHEUS_DOCKER_IMAGE_NAME); - prometheusDockerImageNames.forEach(prometheusDockerImage -> DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage + " / " + javaDockerImageName + " / " + jmxExporterMode, - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - })); + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + })); return openTelemetryTestArguments.stream(); } @@ -69,14 +74,51 @@ public void prepare() { @TestEngine.BeforeAll public void beforeAll() throws Throwable { switch (openTelemetryTestArguments.getJmxExporterMode()) { - case Standalone: { - setupStandalone(); - break; - } - case JavaAgent: { - setUpJavaAgent(); - break; - } + case JavaAgent: + { + prometheusContainer = + createPrometheusContainer( + openTelemetryTestArguments.getJmxExporterMode(), + network, + openTelemetryTestArguments.getPrometheusDockerImageName(), + getClass().getName()); + + javaAgentApplicationContainer = + createJavaAgentApplicationContainer( + network, + openTelemetryTestArguments.getJavaDockerImageName(), + getClass().getName()); + + prometheusContainer.start(); + javaAgentApplicationContainer.start(); + break; + } + case Standalone: + { + prometheusContainer = + createPrometheusContainer( + openTelemetryTestArguments.getJmxExporterMode(), + network, + openTelemetryTestArguments.getPrometheusDockerImageName(), + getClass().getName()); + + standaloneApplicationContainer = + createStandaloneApplicationContainer( + network, + openTelemetryTestArguments.getJavaDockerImageName(), + getClass().getName()); + + standaloneExporterContainer = + createStandaloneExporterContainer( + network, + openTelemetryTestArguments.getJavaDockerImageName(), + getClass().getName()); + + prometheusContainer.start(); + standaloneApplicationContainer.start(); + standaloneExporterContainer.start(); + break; + } } } @@ -89,18 +131,22 @@ public void testOpenTelemetry() throws Throwable { public void afterAll() { if (javaAgentApplicationContainer != null) { javaAgentApplicationContainer.close(); + javaAgentApplicationContainer = null; } if (standaloneExporterContainer != null) { standaloneExporterContainer.close(); + standaloneExporterContainer = null; } if (standaloneApplicationContainer != null) { standaloneApplicationContainer.close(); + standaloneApplicationContainer = null; } if (prometheusContainer != null) { prometheusContainer.close(); + prometheusContainer = null; } } @@ -111,25 +157,6 @@ public void conclude() { } } - private void setUpJavaAgent() { - prometheusContainer = createPrometheusContainer(network, openTelemetryTestArguments.getPrometheusDockerImageName(), getClass().getName()); - javaAgentApplicationContainer = createJavaAgentApplicationContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); - - prometheusContainer.start(); - javaAgentApplicationContainer.start(); - } - - - private void setupStandalone() { - prometheusContainer = createPrometheusContainer(network, openTelemetryTestArguments.getPrometheusDockerImageName(), getClass().getName()); - standaloneApplicationContainer = createStandaloneApplicationContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); - standaloneExporterContainer = createStandaloneExporterContainer(network, openTelemetryTestArguments.getJavaDockerImageName(), getClass().getName()); - - prometheusContainer.start(); - standaloneApplicationContainer.start(); - standaloneExporterContainer.start(); - } - /** * Method to create a Prometheus container * @@ -138,12 +165,33 @@ private void setupStandalone() { * @param testName testName * @return the return value */ - private static GenericContainer createPrometheusContainer(Network network, String prometheusDockerImageName, String testName) { + private static GenericContainer createPrometheusContainer( + JmxExporterMode jmxExporterMode, + Network network, + String prometheusDockerImageName, + String testName) { return new GenericContainer<>(prometheusDockerImageName) - .withExposedPorts(777) - .withNetwork(network) .withClasspathResourceMapping( - testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) + testName.replace(".", "/") + "/" + jmxExporterMode + "/prometheus.yml", + "/etc/prometheus/prometheus.yml", + BindMode.READ_ONLY) + /* + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(PROMETHEUS_MEMORY_BYTES) + .withMemorySwap(PROMETHEUS_MEMORY_SWAP_BYTES)) + */ + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withExposedPorts(7777) + .withNetwork(network) + .withNetworkAliases("prometheus") .withStartupTimeout(Duration.ofMillis(30000)); } @@ -172,7 +220,7 @@ private static GenericContainer createStandaloneApplicationContainer( c.getHostConfig() .withUlimits( new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) + new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh application.sh") .withExposedPorts(9999) @@ -215,7 +263,7 @@ private static GenericContainer createStandaloneExporterContainer( c.getHostConfig() .withUlimits( new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) + new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh exporter.sh") .withExposedPorts(8888) @@ -258,7 +306,7 @@ private static GenericContainer createJavaAgentApplicationContainer( c.getHostConfig() .withUlimits( new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) + new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh application.sh") .withExposedPorts(8888) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java index 71e29a2f..546db741 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java @@ -10,7 +10,11 @@ public class OpenTelemetryTestArguments implements Argument Date: Wed, 19 Jun 2024 17:17:42 -0400 Subject: [PATCH 04/77] Removed unused code Signed-off-by: dhoard --- .../jmx/test/opentelemetry/OpenTelemetryTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 12b1f562..4f72c811 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -175,13 +175,6 @@ private static GenericContainer createPrometheusContainer( testName.replace(".", "/") + "/" + jmxExporterMode + "/prometheus.yml", "/etc/prometheus/prometheus.yml", BindMode.READ_ONLY) - /* - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(PROMETHEUS_MEMORY_BYTES) - .withMemorySwap(PROMETHEUS_MEMORY_SWAP_BYTES)) - */ .withCreateContainerCmdModifier( c -> c.getHostConfig() From 1b566488b84ed1d66a2656fdce84ce1838f3143e Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 00:29:53 -0400 Subject: [PATCH 05/77] Added code to start required containers and test that Prometheus is running Signed-off-by: dhoard --- .../integration_tests/pom.xml | 14 +- .../jmx/test/support/http/HttpClient.java | 9 ++ .../jmx/test/support/http/HttpRequest.java | 26 +++- .../jmx/test/support/http/HttpResponse.java | 2 +- .../support/http/HttpResponseAssertions.java | 6 +- .../CompleteHttpServerConfigurationTest.java | 8 +- .../test/opentelemetry/OpenTelemetryTest.java | 124 ++++++++++++++---- .../OpenTelemetryTest/JavaAgent/exporter.yaml | 4 + .../Standalone/exporter.yaml | 4 + .../jmx/common/yaml/YamlMapAccessor.java | 25 +++- 10 files changed, 179 insertions(+), 43 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 355f2c09..fa8a5c78 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.0 + 7.x.x-SNAPSHOT @@ -105,6 +105,11 @@ test-engine-api ${antublue.test.engine.version} + + io.prometheus.jmx + jmx_prometheus_common + ${project.version} + io.prometheus prometheus-metrics-model @@ -141,10 +146,9 @@ 3.26.0 - org.antublue - test-engine - ${antublue.test.engine.version} - test + org.yaml + snakeyaml + 2.2 diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpClient.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpClient.java index 8b56eadf..23505256 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpClient.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpClient.java @@ -22,6 +22,7 @@ import java.time.Duration; import java.util.Base64; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; @@ -43,6 +44,14 @@ public HttpClient(String baseUrl) { this.baseUrl = baseUrl; } + public HttpResponse send(HttpRequest httpRequest) { + return httpRequest.send(this); + } + + public void send(HttpRequest httpRequest, Consumer httpResponseConsumer) { + httpResponseConsumer.accept(httpRequest.send(this)); + } + public Request.Builder createRequest(String path) { return new Request.Builder().url(baseUrl + path); } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java index 786001af..598171b7 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java @@ -16,16 +16,18 @@ package io.prometheus.jmx.test.support.http; +import java.util.function.Consumer; import okhttp3.Headers; -/** Base class for all tests */ -public abstract class HttpRequest { +/** Class to implement HttpRequest */ +public class HttpRequest { protected HttpClient httpClient; protected Headers.Builder headersBuilder; protected String path; protected HttpCredentials httpCredentials; + /** Constructor */ public HttpRequest() { headersBuilder = new Headers.Builder(); } @@ -33,11 +35,11 @@ public HttpRequest() { /** * Constructor * - * @param httpClient httpClient + * @param path path */ - public HttpRequest(HttpClient httpClient) { - this.httpClient = httpClient; - this.headersBuilder = new Headers.Builder(); + public HttpRequest(String path) { + headersBuilder = new Headers.Builder(); + path(path); } /** @@ -81,7 +83,7 @@ public HttpRequest credentials(HttpCredentials httpCredentials) { } /** - * Method to execute the request + * Method to send the request * * @param httpClient httpClient * @return the response @@ -109,4 +111,14 @@ public HttpResponse send(HttpClient httpClient) { throw new RuntimeException(t); } } + + /** + * Method to send the request + * + * @param httpClient httpClient + * @param httpResponseConsumer httpResponseConsumer + */ + public void send(HttpClient httpClient, Consumer httpResponseConsumer) { + httpResponseConsumer.accept(send(httpClient)); + } } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java index 348d3710..9e1e310f 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java @@ -26,7 +26,7 @@ public HttpResponse(okhttp3.Response response) throws IOException { } } - public int code() { + public int getStatusCode() { return code; } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java index 6af309f4..c43f5bfa 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java @@ -9,7 +9,7 @@ private HttpResponseAssertions() { } public static void assertHttpResponseCode(HttpResponse httpResponse, int code) { - assertThat(httpResponse.code()).isEqualTo(code); + assertThat(httpResponse.getStatusCode()).isEqualTo(code); } public static void assertHttpResponseHasHeaders(HttpResponse httpResponse) { @@ -28,7 +28,7 @@ public static void assertHttpResponseHasBody(HttpResponse httpResponse) { public static void assertHttpHealthyResponse(HttpResponse httpResponse) { assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.code()).isEqualTo(200); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); assertThat(httpResponse.body()).isNotNull(); assertThat(httpResponse.body().string().length()).isGreaterThan(0); assertThat(httpResponse.body().string()).isEqualTo("Exporter is healthy.\n"); @@ -36,7 +36,7 @@ public static void assertHttpHealthyResponse(HttpResponse httpResponse) { public static void assertHttpMetricsResponse(HttpResponse httpResponse) { assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.code()).isEqualTo(200); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); assertHttpResponseHasHeaders(httpResponse); assertHttpResponseHasHeader(httpResponse, HttpHeader.CONTENT_TYPE); assertHttpResponseHasBody(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index 0e7e97d6..717d351a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -109,7 +109,7 @@ public void testMetrics() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.code() == HttpResponse.OK) { + if (response.getStatusCode() == HttpResponse.OK) { accept(response); } }); @@ -133,7 +133,7 @@ public void testMetricsOpenMetricsFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.code() == HttpResponse.OK) { + if (response.getStatusCode() == HttpResponse.OK) { accept(response); } }); @@ -157,7 +157,7 @@ public void testMetricsPrometheusFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.code() == HttpResponse.OK) { + if (response.getStatusCode() == HttpResponse.OK) { accept(response); } }); @@ -181,7 +181,7 @@ public void testMetricsPrometheusProtobufFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.code() == HttpResponse.OK) { + if (response.getStatusCode() == HttpResponse.OK) { accept(response); } }); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 4f72c811..93f2b0b1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -1,11 +1,19 @@ package io.prometheus.jmx.test.opentelemetry; +import static org.assertj.core.api.Assertions.assertThat; + import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpClient; +import io.prometheus.jmx.test.support.http.HttpRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; import org.testcontainers.containers.BindMode; @@ -13,19 +21,21 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; public class OpenTelemetryTest { - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:latest"; - private static final long MEMORY_BYTES = 1073741824; // 1 GB private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; + private static final String BASE_URL = "http://localhost"; + private Network network; private GenericContainer prometheusContainer; private GenericContainer standaloneApplicationContainer; private GenericContainer javaAgentApplicationContainer; private GenericContainer standaloneExporterContainer; + private HttpClient httpClient; @TestEngine.Argument public OpenTelemetryTestArguments openTelemetryTestArguments; @@ -39,7 +49,14 @@ public static Stream arguments() { List openTelemetryTestArguments = new ArrayList<>(); List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add(PROMETHEUS_DOCKER_IMAGE_NAME); + prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); + prometheusDockerImageNames.add("prom/prometheus:v2.47.2"); + prometheusDockerImageNames.add("prom/prometheus:v2.48.1"); + prometheusDockerImageNames.add("prom/prometheus:v2.49.1"); + prometheusDockerImageNames.add("prom/prometheus:v2.50.1"); + prometheusDockerImageNames.add("prom/prometheus:v2.51.2"); + prometheusDockerImageNames.add("prom/prometheus:v2.52.0"); + prometheusDockerImageNames.add("prom/prometheus:v2.53.0"); prometheusDockerImageNames.forEach( prometheusDockerImage -> @@ -55,12 +72,14 @@ public static Stream arguments() { + javaDockerImageName + " / " + jmxExporterMode, - PROMETHEUS_DOCKER_IMAGE_NAME, + prometheusDockerImage, javaDockerImageName, jmxExporterMode)); } })); + System.out.println("test argument count [" + openTelemetryTestArguments.size() + "]"); + return openTelemetryTestArguments.stream(); } @@ -91,6 +110,7 @@ public void beforeAll() throws Throwable { prometheusContainer.start(); javaAgentApplicationContainer.start(); + break; } case Standalone: @@ -117,14 +137,32 @@ public void beforeAll() throws Throwable { prometheusContainer.start(); standaloneApplicationContainer.start(); standaloneExporterContainer.start(); + break; } } + + httpClient = createPrometheusHttpClient(prometheusContainer, BASE_URL, 9090); } @TestEngine.Test - public void testOpenTelemetry() throws Throwable { - System.out.println("testOpenTelemetry()"); + public void testOpenTelemetry() { + // Thread.sleep(30); + + sendQuery("up") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + System.out.println(httpResponse.body().string()); + + Map map = new Yaml().load(httpResponse.body().string()); + String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); + }); } @TestEngine.AfterAll @@ -157,6 +195,16 @@ public void conclude() { } } + private HttpResponse sendQuery(String query) { + return httpClient.send( + new HttpRequest( + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8))); + } + + private HttpResponse sendRequest(String path) { + return httpClient.send(new HttpRequest(path)); + } + /** * Method to create a Prometheus container * @@ -175,6 +223,18 @@ private static GenericContainer createPrometheusContainer( testName.replace(".", "/") + "/" + jmxExporterMode + "/prometheus.yml", "/etc/prometheus/prometheus.yml", BindMode.READ_ONLY) + .withWorkingDirectory("/prometheus") + .withCommand( + "--config.file=/etc/prometheus/prometheus.yml", + "--storage.tsdb.path=/prometheus", + "--web.console.libraries=/usr/share/prometheus/console_libraries", + "--web.console.templates=/usr/share/prometheus/consoles", + "--enable-feature=otlp-write-receiver") + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -182,9 +242,17 @@ private static GenericContainer createPrometheusContainer( new Ulimit[] { new Ulimit("nofile", 65536L, 65536L) })) - .withExposedPorts(7777) + .withExposedPorts(9090) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) .withNetwork(network) .withNetworkAliases("prometheus") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)); } @@ -196,13 +264,13 @@ private static GenericContainer createPrometheusContainer( * @param testName testName * @return the return value */ - private static GenericContainer createStandaloneApplicationContainer( + private static GenericContainer createJavaAgentApplicationContainer( Network network, String dockerImageName, String testName) { return new GenericContainer<>(dockerImageName) .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( - testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) + testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -216,7 +284,7 @@ private static GenericContainer createStandaloneApplicationContainer( new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh application.sh") - .withExposedPorts(9999) + .withExposedPorts(8888) .withLogConsumer( outputFrame -> { String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); @@ -232,17 +300,17 @@ private static GenericContainer createStandaloneApplicationContainer( } /** - * Method to create an exporter container + * Method to create an application container * * @param network network * @param dockerImageName dockerImageName * @param testName testName * @return the return value */ - private static GenericContainer createStandaloneExporterContainer( + private static GenericContainer createStandaloneApplicationContainer( Network network, String dockerImageName, String testName) { return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forListeningPort()) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) @@ -258,8 +326,8 @@ private static GenericContainer createStandaloneExporterContainer( new Ulimit[] { new Ulimit("nofile", 65536L, 65536L) })) - .withCommand("/bin/sh exporter.sh") - .withExposedPorts(8888) + .withCommand("/bin/sh application.sh") + .withExposedPorts(9999) .withLogConsumer( outputFrame -> { String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); @@ -268,27 +336,27 @@ private static GenericContainer createStandaloneExporterContainer( } }) .withNetwork(network) - .withNetworkAliases("exporter") + .withNetworkAliases("application") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) .withWorkingDirectory("/temp"); } /** - * Method to create an application container + * Method to create an exporter container * * @param network network * @param dockerImageName dockerImageName * @param testName testName * @return the return value */ - private static GenericContainer createJavaAgentApplicationContainer( + private static GenericContainer createStandaloneExporterContainer( Network network, String dockerImageName, String testName) { return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + .waitingFor(Wait.forListeningPort()) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( - testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) + testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -301,7 +369,7 @@ private static GenericContainer createJavaAgentApplicationContainer( new Ulimit[] { new Ulimit("nofile", 65536L, 65536L) })) - .withCommand("/bin/sh application.sh") + .withCommand("/bin/sh exporter.sh") .withExposedPorts(8888) .withLogConsumer( outputFrame -> { @@ -311,9 +379,21 @@ private static GenericContainer createJavaAgentApplicationContainer( } }) .withNetwork(network) - .withNetworkAliases("application") + .withNetworkAliases("exporter") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) .withWorkingDirectory("/temp"); } + + /** + * Method to create an HttpClient + * + * @param genericContainer genericContainer + * @param baseUrl baseUrl + * @return the return value + */ + private static HttpClient createPrometheusHttpClient( + GenericContainer genericContainer, String baseUrl, int mappedPort) { + return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); + } } diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml index cb19fee9..0d270292 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml @@ -1,2 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 rules: - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml index 67cbff69..8fafb2d6 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml @@ -1,3 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 hostPort: application:9999 rules: - pattern: ".*" \ No newline at end of file diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/yaml/YamlMapAccessor.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/yaml/YamlMapAccessor.java index db1ef151..a23a17b8 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/yaml/YamlMapAccessor.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/yaml/YamlMapAccessor.java @@ -21,12 +21,18 @@ import java.util.Optional; import java.util.function.Supplier; import java.util.regex.Pattern; +import org.yaml.snakeyaml.Yaml; /** Class to implement a MapAccessor to work with nested Maps / values */ @SuppressWarnings("unchecked") public class YamlMapAccessor { - private final Map map; + private Map map; + + /** Constructor */ + public YamlMapAccessor() { + map = new LinkedHashMap<>(); + } /** * Constructor @@ -41,6 +47,23 @@ public YamlMapAccessor(Map map) { this.map = map; } + public YamlMapAccessor load(Object object) { + if (object == null) { + throw new IllegalArgumentException("object is null"); + } + + try { + if (object instanceof String) { + this.map = new Yaml().load((String) object); + } else { + this.map = (Map) object; + } + return this; + } catch (ClassCastException e) { + throw new IllegalArgumentException("object is not a Map"); + } + } + /** * Method to determine if a path exists * From bee7befa7285a9607ea1dd6f5754d39c5082ce6a Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 00:48:56 -0400 Subject: [PATCH 06/77] Renamed methods Signed-off-by: dhoard --- .../test/opentelemetry/OpenTelemetryTest.java | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 93f2b0b1..a992776a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -146,10 +146,8 @@ public void beforeAll() throws Throwable { } @TestEngine.Test - public void testOpenTelemetry() { - // Thread.sleep(30); - - sendQuery("up") + public void testPrometheusIsUp() { + sendPrometheusQuery("up") .accept( httpResponse -> { assertThat(httpResponse).isNotNull(); @@ -157,8 +155,6 @@ public void testOpenTelemetry() { assertThat(httpResponse.body()).isNotNull(); assertThat(httpResponse.body().string()).isNotNull(); - System.out.println(httpResponse.body().string()); - Map map = new Yaml().load(httpResponse.body().string()); String status = (String) map.get("status"); assertThat(status).isEqualTo("success"); @@ -195,16 +191,39 @@ public void conclude() { } } - private HttpResponse sendQuery(String query) { - return httpClient.send( - new HttpRequest( - "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8))); + /** + * Method to send a Prometheus query + * + * @param query query + * @return an HttpResponse + */ + private HttpResponse sendPrometheusQuery(String query) { + return sendRequest( + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); } + /** + * Method to send a Http GET request + * + * @param path path + * @return an HttpResponse + */ private HttpResponse sendRequest(String path) { return httpClient.send(new HttpRequest(path)); } + /** + * Method to create an HttpClient + * + * @param genericContainer genericContainer + * @param baseUrl baseUrl + * @return the return value + */ + private static HttpClient createPrometheusHttpClient( + GenericContainer genericContainer, String baseUrl, int mappedPort) { + return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); + } + /** * Method to create a Prometheus container * @@ -384,16 +403,4 @@ private static GenericContainer createStandaloneExporterContainer( .withStartupTimeout(Duration.ofMillis(30000)) .withWorkingDirectory("/temp"); } - - /** - * Method to create an HttpClient - * - * @param genericContainer genericContainer - * @param baseUrl baseUrl - * @return the return value - */ - private static HttpClient createPrometheusHttpClient( - GenericContainer genericContainer, String baseUrl, int mappedPort) { - return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); - } } From acf00090c511f5d0981f289dad893ac9e68a4b13 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 16:52:51 -0400 Subject: [PATCH 07/77] Refactored OpenTelemetryTest to allow multi-threaded execution Signed-off-by: dhoard --- .../integration_tests/pom.xml | 5 + ...st.java => AbstractOpenTelemetryTest.java} | 104 +++++++++--------- .../OpenTelemetryTest_v2_45_5.java | 47 ++++++++ .../OpenTelemetryTest_v2_46_0.java | 47 ++++++++ .../OpenTelemetryTest_v2_47_2.java | 47 ++++++++ .../OpenTelemetryTest_v2_48_1.java | 47 ++++++++ .../OpenTelemetryTest_v2_49_1.java | 47 ++++++++ .../OpenTelemetryTest_v2_50_1.java | 47 ++++++++ .../OpenTelemetryTest_v2_52_0.java | 47 ++++++++ .../OpenTelemetryTest_v2_53_0.java | 47 ++++++++ .../JavaAgent/application.sh | 0 .../JavaAgent/exporter.yaml | 0 .../JavaAgent/prometheus.yml | 0 .../Standalone/application.sh | 0 .../Standalone/exporter.sh | 0 .../Standalone/exporter.yaml | 0 .../Standalone/prometheus.yml | 0 .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 6 + .../JavaAgent/prometheus.yml | 4 + .../Standalone/application.sh | 13 +++ .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 7 ++ .../Standalone/prometheus.yml | 4 + 66 files changed, 748 insertions(+), 52 deletions(-) rename integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest.java => AbstractOpenTelemetryTest.java} (84%) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/JavaAgent/application.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/JavaAgent/exporter.yaml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/JavaAgent/prometheus.yml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/Standalone/application.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/Standalone/exporter.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/Standalone/exporter.yaml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest => OpenTelemetryTest_v2_45_5}/Standalone/prometheus.yml (100%) create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index fa8a5c78..1ad0facb 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -105,6 +105,11 @@ test-engine-api ${antublue.test.engine.version} + + org.antublue + test-engine + ${antublue.test.engine.version} + io.prometheus.jmx jmx_prometheus_common diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java similarity index 84% rename from integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java rename to integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index a992776a..371bf522 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import com.github.dockerjava.api.model.Ulimit; -import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpClient; import io.prometheus.jmx.test.support.http.HttpRequest; @@ -11,10 +10,9 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.Duration; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import java.util.stream.Stream; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.antublue.test.engine.api.TestEngine; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; @@ -23,7 +21,8 @@ import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; -public class OpenTelemetryTest { +/** Class to implement AbstractOpenTelemetryTest */ +public abstract class AbstractOpenTelemetryTest { private static final long MEMORY_BYTES = 1073741824; // 1 GB private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; @@ -39,50 +38,6 @@ public class OpenTelemetryTest { @TestEngine.Argument public OpenTelemetryTestArguments openTelemetryTestArguments; - /** - * Method to get the list of TestArguments - * - * @return the return value - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); - prometheusDockerImageNames.add("prom/prometheus:v2.47.2"); - prometheusDockerImageNames.add("prom/prometheus:v2.48.1"); - prometheusDockerImageNames.add("prom/prometheus:v2.49.1"); - prometheusDockerImageNames.add("prom/prometheus:v2.50.1"); - prometheusDockerImageNames.add("prom/prometheus:v2.51.2"); - prometheusDockerImageNames.add("prom/prometheus:v2.52.0"); - prometheusDockerImageNames.add("prom/prometheus:v2.53.0"); - - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); - - System.out.println("test argument count [" + openTelemetryTestArguments.size() + "]"); - - return openTelemetryTestArguments.stream(); - } - @TestEngine.Prepare public void prepare() { // Get the Network and get the id to force the network creation @@ -91,7 +46,7 @@ public void prepare() { } @TestEngine.BeforeAll - public void beforeAll() throws Throwable { + public void beforeAll() { switch (openTelemetryTestArguments.getJmxExporterMode()) { case JavaAgent: { @@ -145,7 +100,9 @@ public void beforeAll() throws Throwable { httpClient = createPrometheusHttpClient(prometheusContainer, BASE_URL, 9090); } + /** Method to test that Prometheus is up */ @TestEngine.Test + @TestEngine.Order(order = 0) public void testPrometheusIsUp() { sendPrometheusQuery("up") .accept( @@ -157,10 +114,53 @@ public void testPrometheusIsUp() { Map map = new Yaml().load(httpResponse.body().string()); String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); }); } + /** Method to test that metrics exist in Prometheus */ + @TestEngine.Test + public void testPrometheusMetrics() { + AtomicInteger pollCount = new AtomicInteger(10); + AtomicBoolean wasSuccessful = new AtomicBoolean(); + + do { + sendPrometheusQuery("jmx_exporter_build_info") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + Map map = + new Yaml().load(httpResponse.body().string()); + String status = (String) map.get("status"); + + if ("success".equals(status) && map.containsKey("$.data.result")) { + // TODO real logic + pollCount.set(0); + wasSuccessful.set(true); + } + + pollCount.decrementAndGet(); + }); + + if (wasSuccessful.get()) { + break; + } + + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // DO NOTHING + } + } while (pollCount.get() > 0); + + assertThat(wasSuccessful).isTrue(); + } + @TestEngine.AfterAll public void afterAll() { if (javaAgentApplicationContainer != null) { @@ -197,7 +197,7 @@ public void conclude() { * @param query query * @return an HttpResponse */ - private HttpResponse sendPrometheusQuery(String query) { + protected HttpResponse sendPrometheusQuery(String query) { return sendRequest( "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); } @@ -208,7 +208,7 @@ private HttpResponse sendPrometheusQuery(String query) { * @param path path * @return an HttpResponse */ - private HttpResponse sendRequest(String path) { + protected HttpResponse sendRequest(String path) { return httpClient.send(new HttpRequest(path)); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java new file mode 100644 index 00000000..24535adf --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_46_0 */ +public class OpenTelemetryTest_v2_45_5 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java new file mode 100644 index 00000000..187db0bc --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_46_0 */ +public class OpenTelemetryTest_v2_46_0 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java new file mode 100644 index 00000000..ba56441e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_47_2 */ +public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.47.2"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java new file mode 100644 index 00000000..aac72bc1 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_48_1 */ +public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.48.1"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java new file mode 100644 index 00000000..070111dd --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_49_1 */ +public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.49.1"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java new file mode 100644 index 00000000..861c3f2e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_50_1 */ +public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.50.1"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java new file mode 100644 index 00000000..c8f4d258 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_52_0 */ +public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.52.0"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java new file mode 100644 index 00000000..e955b5bf --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -0,0 +1,47 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_53_0 */ +public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { + + /** + * Method to get the list of TestArguments + * + * @return the return value + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + List openTelemetryTestArguments = new ArrayList<>(); + + List prometheusDockerImageNames = new ArrayList<>(); + prometheusDockerImageNames.add("prom/prometheus:v2.53.0"); + + prometheusDockerImageNames.forEach( + prometheusDockerImage -> + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestArguments.add( + OpenTelemetryTestArguments.of( + prometheusDockerImage + + " / " + + javaDockerImageName + + " / " + + jmxExporterMode, + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestArguments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml new file mode 100644 index 00000000..0d270292 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml new file mode 100644 index 00000000..8fafb2d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090 + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file From d2a1cb809955118900fae58643d97eb081f9f795 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 19:31:16 -0400 Subject: [PATCH 08/77] Adding more test functionality Signed-off-by: dhoard --- .../AbstractOpenTelemetryTest.java | 80 ++++++++++--------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 371bf522..c3493b20 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -11,8 +11,6 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import org.antublue.test.engine.api.TestEngine; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; @@ -121,44 +119,23 @@ public void testPrometheusIsUp() { /** Method to test that metrics exist in Prometheus */ @TestEngine.Test - public void testPrometheusMetrics() { - AtomicInteger pollCount = new AtomicInteger(10); - AtomicBoolean wasSuccessful = new AtomicBoolean(); - - do { - sendPrometheusQuery("jmx_exporter_build_info") - .accept( - httpResponse -> { - assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); - assertThat(httpResponse.body()).isNotNull(); - assertThat(httpResponse.body().string()).isNotNull(); - - Map map = - new Yaml().load(httpResponse.body().string()); - String status = (String) map.get("status"); - - if ("success".equals(status) && map.containsKey("$.data.result")) { - // TODO real logic - pollCount.set(0); - wasSuccessful.set(true); - } - - pollCount.decrementAndGet(); - }); - - if (wasSuccessful.get()) { - break; - } + public void testGetPrometheusMetrics() { + String name = "jmx_build_info"; + String[] labels = new String[0]; - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // DO NOTHING - } - } while (pollCount.get() > 0); + sendPrometheusQuery("jmx_build_info") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); - assertThat(wasSuccessful).isTrue(); + Double value = parseResponse(httpResponse, name, labels); + + assertThat(value).isNotNull(); + assertThat(value).isEqualTo(1.0); + }); } @TestEngine.AfterAll @@ -224,6 +201,33 @@ private static HttpClient createPrometheusHttpClient( return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); } + private static Double parseResponse(HttpResponse httpResponse, String name, String... labels) { + Double value = null; + String scrapeResponseJson = httpResponse.body().string(); + + assertThat(scrapeResponseJson).isNotNull(); + assertThat(scrapeResponseJson).isNotEmpty(); + + /* + Criteria criteria = Criteria.where("metric.__name__").eq(name); + + if (labels != null) { + for (int i = 0; i < labels.length; i += 2) { + criteria = criteria.and("metric." + labels[i]).eq(labels[i + 1]); + } + } + + JSONArray result = + JsonPath.parse(scrapeResponseJson) + .read("$.data.result" + Filter.filter(criteria) + ".value[1]"); + if (result != null && result.size() == 1) { + value = Double.valueOf(result.get(0).toString()); + } + */ + + return value; + } + /** * Method to create a Prometheus container * From ea94e1927568b4cf8de16f11b1883624b58f8542 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 19:33:44 -0400 Subject: [PATCH 09/77] Updated AntuBLUE test engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 1ad0facb..9a3e8a22 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.x.x-SNAPSHOT + 7.0.0-ALPHA-1 From c9548eaedc42859c64c168f38ce659f8d8f0b6c5 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 20 Jun 2024 20:14:05 -0400 Subject: [PATCH 10/77] Updated AntuBLUE test engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 9a3e8a22..7b5eda61 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.0-ALPHA-1 + 7.0.1-ALPHA-1 From c16c05e1a0482950693267841fdd50ef928ccbc8 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 21 Jun 2024 00:53:34 -0400 Subject: [PATCH 11/77] Formatting Signed-off-by: dhoard --- collector/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/collector/pom.xml b/collector/pom.xml index a4abdaab..f9c8bc6d 100644 --- a/collector/pom.xml +++ b/collector/pom.xml @@ -89,7 +89,6 @@ prometheus-metrics-instrumentation-jvm test - From 55e76c5dedd2b3b7944c042fc545ee1e9673a691 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 21 Jun 2024 00:54:47 -0400 Subject: [PATCH 12/77] Removed groupId since it's inherited Signed-off-by: dhoard --- jmx_prometheus_common/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/jmx_prometheus_common/pom.xml b/jmx_prometheus_common/pom.xml index 2d7ff9c1..c7fb366b 100644 --- a/jmx_prometheus_common/pom.xml +++ b/jmx_prometheus_common/pom.xml @@ -8,7 +8,6 @@ 1.x.x - io.prometheus.jmx jmx_prometheus_common Prometheus JMX Exporter - Common From 1655b3ab4f0821341e622052f9b0b3b6f8e11283 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 21 Jun 2024 00:55:45 -0400 Subject: [PATCH 13/77] Added shading configuration. Formatting Signed-off-by: dhoard --- jmx_prometheus_httpserver/pom.xml | 12 ++++++ jmx_prometheus_javaagent/pom.xml | 70 ++++++++++++++++++------------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/jmx_prometheus_httpserver/pom.xml b/jmx_prometheus_httpserver/pom.xml index 497b6dd4..9c4b7e30 100644 --- a/jmx_prometheus_httpserver/pom.xml +++ b/jmx_prometheus_httpserver/pom.xml @@ -154,6 +154,18 @@ META-INF/MANIFEST.MF + + io.prometheus:prometheus-metrics-exporter-opentelemetry + + META-INF/MANIFEST.MF + + + + io.prometheus:prometheus-metrics-shaded-opentelemetry + + META-INF/MANIFEST.MF + + org.yaml:snakeyaml diff --git a/jmx_prometheus_javaagent/pom.xml b/jmx_prometheus_javaagent/pom.xml index 88eea855..d9e0d756 100644 --- a/jmx_prometheus_javaagent/pom.xml +++ b/jmx_prometheus_javaagent/pom.xml @@ -28,35 +28,6 @@ UTF-8 - - - io.prometheus.jmx - collector - ${project.version} - - - io.prometheus.jmx - jmx_prometheus_common - ${project.version} - - - io.prometheus - prometheus-metrics-instrumentation-jvm - - - org.junit.jupiter - junit-jupiter - 5.10.2 - test - - - org.assertj - assertj-core - 3.26.0 - test - - - @@ -183,6 +154,18 @@ META-INF/MANIFEST.MF + + io.prometheus:prometheus-metrics-exporter-opentelemetry + + META-INF/MANIFEST.MF + + + + io.prometheus:prometheus-metrics-shaded-opentelemetry + + META-INF/MANIFEST.MF + + org.yaml:snakeyaml @@ -259,4 +242,33 @@ + + + io.prometheus.jmx + collector + ${project.version} + + + io.prometheus.jmx + jmx_prometheus_common + ${project.version} + + + io.prometheus + prometheus-metrics-instrumentation-jvm + + + org.junit.jupiter + junit-jupiter + 5.10.2 + test + + + org.assertj + assertj-core + 3.26.0 + test + + + From 58bfc2bb94ff895abf3b32301c7f62f57e6bb43d Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 21 Jun 2024 17:24:20 -0400 Subject: [PATCH 14/77] Added AntuBLUE Test Engine Extras Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 7b5eda61..fb892410 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.1-ALPHA-1 + 7.x.x-SNAPSHOT @@ -105,6 +105,11 @@ test-engine-api ${antublue.test.engine.version} + + org.antublue + test-engine-extras + ${antublue.test.engine.version} + org.antublue test-engine From b78468db787ea43d7d5adae3fcbca50e34fd03f2 Mon Sep 17 00:00:00 2001 From: dhoard Date: Sat, 22 Jun 2024 00:46:40 -0400 Subject: [PATCH 15/77] Fixed tests Signed-off-by: dhoard --- .../integration_tests/pom.xml | 2 +- .../AbstractOpenTelemetryTest.java | 147 ++++++++----- .../opentelemetry/ExpectedMetricsNames.java | 197 ++++++++++++++++++ .../OpenTelemetryTest_v2_45_5.java | 47 ----- .../OpenTelemetryTest_v2_46_0.java | 47 ----- .../test/resources/docker-image-names.all.txt | 2 +- .../JavaAgent/application.sh | 6 - .../JavaAgent/exporter.yaml | 6 - .../JavaAgent/prometheus.yml | 4 - .../Standalone/application.sh | 13 -- .../Standalone/exporter.sh | 5 - .../Standalone/exporter.yaml | 7 - .../Standalone/prometheus.yml | 4 - .../JavaAgent/application.sh | 6 - .../JavaAgent/exporter.yaml | 6 - .../JavaAgent/prometheus.yml | 4 - .../Standalone/application.sh | 13 -- .../Standalone/exporter.sh | 5 - .../Standalone/exporter.yaml | 7 - .../Standalone/prometheus.yml | 4 - .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- .../JavaAgent/exporter.yaml | 2 +- .../Standalone/exporter.yaml | 2 +- 32 files changed, 302 insertions(+), 254 deletions(-) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index fb892410..d86da32b 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.x.x-SNAPSHOT + 7.0.1-ALPHA-2 diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index c3493b20..dc326911 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -1,6 +1,8 @@ package io.prometheus.jmx.test.opentelemetry; +import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.fail; import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.JmxExporterMode; @@ -11,7 +13,11 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; import org.antublue.test.engine.api.TestEngine; +import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; +import org.antublue.test.engine.extras.throttle.Throttle; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; @@ -102,39 +108,62 @@ public void beforeAll() { @TestEngine.Test @TestEngine.Order(order = 0) public void testPrometheusIsUp() { - sendPrometheusQuery("up") - .accept( - httpResponse -> { - assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); - assertThat(httpResponse.body()).isNotNull(); - assertThat(httpResponse.body().string()).isNotNull(); - - Map map = new Yaml().load(httpResponse.body().string()); - String status = (String) map.get("status"); - - assertThat(status).isEqualTo("success"); - }); + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); + AtomicBoolean success = new AtomicBoolean(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery("up") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + + if (httpResponse.getStatusCode() != 200) { + return; + } + + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + Map map = + new Yaml().load(httpResponse.body().string()); + + String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); + + success.set(true); + }); + + if (success.get()) { + break; + } + + throttle.throttle(); + } + + if (!success.get()) { + fail("Prometheus is not up"); + } } /** Method to test that metrics exist in Prometheus */ @TestEngine.Test - public void testGetPrometheusMetrics() { - String name = "jmx_build_info"; - String[] labels = new String[0]; - - sendPrometheusQuery("jmx_build_info") - .accept( - httpResponse -> { - assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); - assertThat(httpResponse.body()).isNotNull(); - assertThat(httpResponse.body().string()).isNotNull(); - - Double value = parseResponse(httpResponse, name, labels); - - assertThat(value).isNotNull(); - assertThat(value).isEqualTo(1.0); + public void testPrometheusMetrics() { + ExpectedMetricsNames.getMetricsNames().stream() + .filter( + metricName -> { + if (openTelemetryTestArguments.getJmxExporterMode() + == JmxExporterMode.Standalone + && metricName.startsWith("jvm_") + || metricName.startsWith("process_")) { + return false; + } + return true; + }) + .forEach( + metricName -> { + Double value = getPrometheusMetric(metricName); + assertThat(value).as("metricName [%s]", metricName).isNotNull(); + assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); }); } @@ -168,6 +197,39 @@ public void conclude() { } } + protected Double getPrometheusMetric(String metricName) { + return getPrometheusMetric(metricName, null); + } + + protected Double getPrometheusMetric(String metricName, String[] labels) { + Throttle throttle = new ExponentialBackoffThrottle(100, 6400); + AtomicReference value = new AtomicReference<>(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery(metricName) + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + // TODO parse response and return value + if (httpResponse.body().string().contains(metricName)) { + value.set(1.0); + } + }); + + if (value.get() != null) { + break; + } + + throttle.throttle(); + } + + return value.get(); + } + /** * Method to send a Prometheus query * @@ -201,33 +263,6 @@ private static HttpClient createPrometheusHttpClient( return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); } - private static Double parseResponse(HttpResponse httpResponse, String name, String... labels) { - Double value = null; - String scrapeResponseJson = httpResponse.body().string(); - - assertThat(scrapeResponseJson).isNotNull(); - assertThat(scrapeResponseJson).isNotEmpty(); - - /* - Criteria criteria = Criteria.where("metric.__name__").eq(name); - - if (labels != null) { - for (int i = 0; i < labels.length; i += 2) { - criteria = criteria.and("metric." + labels[i]).eq(labels[i + 1]); - } - } - - JSONArray result = - JsonPath.parse(scrapeResponseJson) - .read("$.data.result" + Filter.filter(criteria) + ".value[1]"); - if (result != null && result.size() == 1) { - value = Double.valueOf(result.get(0).toString()); - } - */ - - return value; - } - /** * Method to create a Prometheus container * diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java new file mode 100644 index 00000000..b1d79bba --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java @@ -0,0 +1,197 @@ +package io.prometheus.jmx.test.opentelemetry; + +import java.util.ArrayList; +import java.util.List; + +/** Class to implement ExpectedMetricsNames */ +public class ExpectedMetricsNames { + + private static final List metricNames = new ArrayList<>(); + + static { + metricNames.add("io_prometheus_jmx_autoIncrementing_Value"); + + // This metric doesn't exist for Java 11+ + + // metricNames.add("io_prometheus_jmx_optionalValue_Value"); + + metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_avail"); + metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_pcent"); + metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size"); + metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_used"); + metricNames.add("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_avail"); + metricNames.add("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent"); + metricNames.add("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_size"); + metricNames.add("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_used"); + metricNames.add( + "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_ActiveSessions"); + metricNames.add( + "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_Bootstraps"); + metricNames.add( + "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_BootstrapsDeferred"); + metricNames.add("java_lang_ClassLoading_LoadedClassCount"); + metricNames.add("java_lang_ClassLoading_TotalLoadedClassCount"); + metricNames.add("java_lang_ClassLoading_UnloadedClassCount"); + metricNames.add("java_lang_ClassLoading_Verbose"); + metricNames.add("java_lang_Compilation_CompilationTimeMonitoringSupported"); + metricNames.add("java_lang_Compilation_TotalCompilationTime"); + + // These metrics don't exist for Java 11+ + + /* + metricNames.add("java_lang_GarbageCollector_CollectionCount"); + metricNames.add("java_lang_GarbageCollector_CollectionTime"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_GcThreadCount"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_duration"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_endTime"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_id"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageAfterGc_committed"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageAfterGc_init"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageAfterGc_max"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageAfterGc_used"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageBeforeGc_committed"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageBeforeGc_init"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageBeforeGc_max"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_memoryUsageBeforeGc_used"); + metricNames.add("java_lang_GarbageCollector_LastGcInfo_startTime"); + metricNames.add("java_lang_GarbageCollector_Valid"); + metricNames.add("java_lang_MemoryManager_Valid"); + metricNames.add("java_lang_MemoryPool_CollectionUsageThreshold"); + metricNames.add("java_lang_MemoryPool_CollectionUsageThresholdCount"); + metricNames.add("java_lang_MemoryPool_CollectionUsageThresholdExceeded"); + metricNames.add("java_lang_MemoryPool_CollectionUsageThresholdSupported"); + metricNames.add("java_lang_MemoryPool_CollectionUsage_committed"); + metricNames.add("java_lang_MemoryPool_CollectionUsage_init"); + metricNames.add("java_lang_MemoryPool_CollectionUsage_max"); + metricNames.add("java_lang_MemoryPool_CollectionUsage_used"); + metricNames.add("java_lang_MemoryPool_PeakUsage_committed"); + metricNames.add("java_lang_MemoryPool_PeakUsage_init"); + metricNames.add("java_lang_MemoryPool_PeakUsage_max"); + metricNames.add("java_lang_MemoryPool_PeakUsage_used"); + metricNames.add("java_lang_MemoryPool_UsageThreshold"); + metricNames.add("java_lang_MemoryPool_UsageThresholdCount"); + metricNames.add("java_lang_MemoryPool_UsageThresholdExceeded"); + metricNames.add("java_lang_MemoryPool_UsageThresholdSupported"); + metricNames.add("java_lang_MemoryPool_Usage_committed"); + metricNames.add("java_lang_MemoryPool_Usage_init"); + metricNames.add("java_lang_MemoryPool_Usage_max"); + metricNames.add("java_lang_MemoryPool_Usage_used"); + metricNames.add("java_lang_MemoryPool_Valid"); + metricNames.add("java_lang_Memory_HeapMemoryUsage_committed"); + metricNames.add("java_lang_Memory_HeapMemoryUsage_init"); + metricNames.add("java_lang_Memory_HeapMemoryUsage_max"); + metricNames.add("java_lang_Memory_HeapMemoryUsage_used"); + metricNames.add("java_lang_Memory_NonHeapMemoryUsage_committed"); + metricNames.add("java_lang_Memory_NonHeapMemoryUsage_init"); + metricNames.add("java_lang_Memory_NonHeapMemoryUsage_max"); + metricNames.add("java_lang_Memory_NonHeapMemoryUsage_used"); + metricNames.add("java_lang_Memory_ObjectPendingFinalizationCount"); + metricNames.add("java_lang_Memory_Verbose"); + */ + + metricNames.add("java_lang_OperatingSystem_AvailableProcessors"); + metricNames.add("java_lang_OperatingSystem_CommittedVirtualMemorySize"); + metricNames.add("java_lang_OperatingSystem_FreePhysicalMemorySize"); + metricNames.add("java_lang_OperatingSystem_FreeSwapSpaceSize"); + metricNames.add("java_lang_OperatingSystem_MaxFileDescriptorCount"); + metricNames.add("java_lang_OperatingSystem_OpenFileDescriptorCount"); + metricNames.add("java_lang_OperatingSystem_ProcessCpuLoad"); + metricNames.add("java_lang_OperatingSystem_ProcessCpuTime"); + metricNames.add("java_lang_OperatingSystem_SystemCpuLoad"); + metricNames.add("java_lang_OperatingSystem_SystemLoadAverage"); + metricNames.add("java_lang_OperatingSystem_TotalPhysicalMemorySize"); + metricNames.add("java_lang_OperatingSystem_TotalSwapSpaceSize"); + metricNames.add("java_lang_Runtime_BootClassPathSupported"); + metricNames.add("java_lang_Runtime_StartTime"); + metricNames.add("java_lang_Runtime_Uptime"); + + // These metrics don't exist for ibmjava + + /*metricNames.add("java_lang_Threading_CurrentThreadAllocatedBytes"); + metricNames.add("java_lang_Threading_CurrentThreadCpuTime"); + metricNames.add("java_lang_Threading_CurrentThreadCpuTimeSupported"); + metricNames.add("java_lang_Threading_CurrentThreadUserTime"); + metricNames.add("java_lang_Threading_DaemonThreadCount"); + metricNames.add("java_lang_Threading_ObjectMonitorUsageSupported"); + metricNames.add("java_lang_Threading_PeakThreadCount"); + metricNames.add("java_lang_Threading_SynchronizerUsageSupported"); + metricNames.add("java_lang_Threading_ThreadAllocatedMemoryEnabled"); + metricNames.add("java_lang_Threading_ThreadAllocatedMemorySupported"); + metricNames.add("java_lang_Threading_ThreadContentionMonitoringEnabled"); + metricNames.add("java_lang_Threading_ThreadContentionMonitoringSupported"); + metricNames.add("java_lang_Threading_ThreadCount"); + metricNames.add("java_lang_Threading_ThreadCpuTimeEnabled"); + metricNames.add("java_lang_Threading_ThreadCpuTimeSupported"); + metricNames.add("java_lang_Threading_TotalStartedThreadCount"); + */ + + // These metrics don't exist for Java 11+ + + /* + metricNames.add("java_nio_BufferPool_Count"); + metricNames.add("java_nio_BufferPool_MemoryUsed"); + metricNames.add("java_nio_BufferPool_TotalCapacity"); + */ + + metricNames.add("jmx_config_reload_failure_total"); + metricNames.add("jmx_config_reload_success_total"); + metricNames.add("jmx_exporter_build"); + metricNames.add("jmx_scrape_cached_beans"); + metricNames.add("jmx_scrape_duration_seconds"); + metricNames.add("jmx_scrape_error"); + metricNames.add("jvm_buffer_pool_capacity_bytes"); + metricNames.add("jvm_buffer_pool_used_buffers"); + metricNames.add("jvm_buffer_pool_used_bytes"); + metricNames.add("jvm_classes_currently_loaded"); + metricNames.add("jvm_classes_loaded_total"); + metricNames.add("jvm_classes_unloaded_total"); + metricNames.add("jvm_compilation_time_seconds_total"); + metricNames.add("jvm_gc_collection_seconds_count"); + metricNames.add("jvm_gc_collection_seconds_sum"); + metricNames.add("jvm_memory_committed_bytes"); + metricNames.add("jvm_memory_init_bytes"); + metricNames.add("jvm_memory_max_bytes"); + metricNames.add("jvm_memory_objects_pending_finalization"); + metricNames.add("jvm_memory_pool_allocated_bytes_total"); + metricNames.add("jvm_memory_pool_collection_committed_bytes"); + metricNames.add("jvm_memory_pool_collection_init_bytes"); + metricNames.add("jvm_memory_pool_collection_max_bytes"); + metricNames.add("jvm_memory_pool_collection_used_bytes"); + metricNames.add("jvm_memory_pool_committed_bytes"); + metricNames.add("jvm_memory_pool_init_bytes"); + metricNames.add("jvm_memory_pool_max_bytes"); + metricNames.add("jvm_memory_pool_used_bytes"); + metricNames.add("jvm_memory_used_bytes"); + metricNames.add("jvm_runtime"); + metricNames.add("jvm_threads_current"); + metricNames.add("jvm_threads_daemon"); + metricNames.add("jvm_threads_deadlocked"); + metricNames.add("jvm_threads_deadlocked_monitor"); + metricNames.add("jvm_threads_peak"); + metricNames.add("jvm_threads_started_total"); + metricNames.add("jvm_threads_state"); + metricNames.add("org_exist_management_exist_ProcessReport_RunningQueries_elapsedTime"); + metricNames.add("org_exist_management_exist_ProcessReport_RunningQueries_id"); + metricNames.add("org_exist_management_exist_ProcessReport_RunningQueries_startedAtTime"); + metricNames.add("process_cpu_seconds_total"); + metricNames.add("process_max_fds"); + metricNames.add("process_open_fds"); + metricNames.add("process_resident_memory_bytes"); + metricNames.add("process_start_time_seconds"); + metricNames.add("process_virtual_memory_bytes"); + } + + /** Constructor */ + private ExpectedMetricsNames() { + // DO NOTHING + } + + /** + * Method to get metrics names + * + * @return a List of metrics names + */ + public static List getMetricsNames() { + return metricNames; + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java deleted file mode 100644 index 24535adf..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.DockerImageNames; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_46_0 */ -public class OpenTelemetryTest_v2_45_5 extends AbstractOpenTelemetryTest { - - /** - * Method to get the list of TestArguments - * - * @return the return value - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); - - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); - - return openTelemetryTestArguments.stream(); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java deleted file mode 100644 index 187db0bc..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.DockerImageNames; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_46_0 */ -public class OpenTelemetryTest_v2_46_0 extends AbstractOpenTelemetryTest { - - /** - * Method to get the list of TestArguments - * - * @return the return value - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.46.0"); - - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); - - return openTelemetryTestArguments.stream(); - } -} diff --git a/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt b/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt index 3653b614..fc84e183 100644 --- a/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt +++ b/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt @@ -80,4 +80,4 @@ registry.access.redhat.com/ubi9/openjdk-21-runtime:latest sapmachine:11 sapmachine:17 sapmachine:21 -sapmachine:22 +sapmachine:22 \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml deleted file mode 100644 index 0d270292..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090 - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml deleted file mode 100644 index 8fafb2d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090 - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_45_5/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml deleted file mode 100644 index 0d270292..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090 - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml deleted file mode 100644 index 8fafb2d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090 - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_46_0/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml index 0d270292..46567227 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 rules: diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml index 8fafb2d6..5f35cee0 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml @@ -1,5 +1,5 @@ openTelemetry: - endpoint: http://prometheus:9090 + endpoint: http://prometheus:9090/api/v1/otlp protocol: http/protobuf interval: 1 hostPort: application:9999 From e4a660a2dd8af5c0b4eaa2e14f33ab00bf97a141 Mon Sep 17 00:00:00 2001 From: dhoard Date: Sat, 22 Jun 2024 00:47:29 -0400 Subject: [PATCH 16/77] Formatting Signed-off-by: dhoard --- .../jmx/test/opentelemetry/AbstractOpenTelemetryTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index dc326911..bc225103 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -1,6 +1,5 @@ package io.prometheus.jmx.test.opentelemetry; -import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; From 887db75d525b83de2c1c6e416730af5e05eca340 Mon Sep 17 00:00:00 2001 From: dhoard Date: Sat, 22 Jun 2024 09:18:17 -0400 Subject: [PATCH 17/77] Removed unused member variable Signed-off-by: dhoard --- .../java/io/prometheus/jmx/test/support/http/HttpRequest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java index 598171b7..080da069 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpRequest.java @@ -22,7 +22,6 @@ /** Class to implement HttpRequest */ public class HttpRequest { - protected HttpClient httpClient; protected Headers.Builder headersBuilder; protected String path; protected HttpCredentials httpCredentials; From 11779b8fa086941bd542285830a3ca9be41cb913 Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 25 Jun 2024 09:12:44 -0400 Subject: [PATCH 18/77] Renamed method. Add code to close response Signed-off-by: dhoard --- .../jmx/test/support/http/HttpResponse.java | 22 ++++++++++++++----- .../support/http/HttpResponseAssertions.java | 6 ++--- .../CompleteHttpServerConfigurationTest.java | 8 +++---- .../AbstractOpenTelemetryTest.java | 4 ++-- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java index 9e1e310f..7f1929d6 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponse.java @@ -18,15 +18,25 @@ public HttpResponse(okhttp3.Response response) throws IOException { this.code = response.code(); this.headers = response.headers(); - ResponseBody responseBody = response.body(); - if (responseBody != null) { - body = new HttpResponseBody(responseBody.bytes()); - } else { - body = null; + try { + ResponseBody responseBody = response.body(); + if (responseBody != null) { + body = new HttpResponseBody(responseBody.bytes()); + } else { + body = null; + } + } finally { + if (response != null) { + try { + response.close(); + } catch (Throwable t) { + // DO NOTHING + } + } } } - public int getStatusCode() { + public int statusCode() { return code; } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java index c43f5bfa..307ef5d8 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/http/HttpResponseAssertions.java @@ -9,7 +9,7 @@ private HttpResponseAssertions() { } public static void assertHttpResponseCode(HttpResponse httpResponse, int code) { - assertThat(httpResponse.getStatusCode()).isEqualTo(code); + assertThat(httpResponse.statusCode()).isEqualTo(code); } public static void assertHttpResponseHasHeaders(HttpResponse httpResponse) { @@ -28,7 +28,7 @@ public static void assertHttpResponseHasBody(HttpResponse httpResponse) { public static void assertHttpHealthyResponse(HttpResponse httpResponse) { assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.statusCode()).isEqualTo(200); assertThat(httpResponse.body()).isNotNull(); assertThat(httpResponse.body().string().length()).isGreaterThan(0); assertThat(httpResponse.body().string()).isEqualTo("Exporter is healthy.\n"); @@ -36,7 +36,7 @@ public static void assertHttpHealthyResponse(HttpResponse httpResponse) { public static void assertHttpMetricsResponse(HttpResponse httpResponse) { assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.statusCode()).isEqualTo(200); assertHttpResponseHasHeaders(httpResponse); assertHttpResponseHasHeader(httpResponse, HttpHeader.CONTENT_TYPE); assertHttpResponseHasBody(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index 717d351a..240d1fdc 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -109,7 +109,7 @@ public void testMetrics() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.getStatusCode() == HttpResponse.OK) { + if (response.statusCode() == HttpResponse.OK) { accept(response); } }); @@ -133,7 +133,7 @@ public void testMetricsOpenMetricsFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.getStatusCode() == HttpResponse.OK) { + if (response.statusCode() == HttpResponse.OK) { accept(response); } }); @@ -157,7 +157,7 @@ public void testMetricsPrometheusFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.getStatusCode() == HttpResponse.OK) { + if (response.statusCode() == HttpResponse.OK) { accept(response); } }); @@ -181,7 +181,7 @@ public void testMetricsPrometheusProtobufFormat() { .accept( response -> { assertHttpResponseCode(response, code.get()); - if (response.getStatusCode() == HttpResponse.OK) { + if (response.statusCode() == HttpResponse.OK) { accept(response); } }); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index bc225103..2be2df42 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -116,7 +116,7 @@ public void testPrometheusIsUp() { httpResponse -> { assertThat(httpResponse).isNotNull(); - if (httpResponse.getStatusCode() != 200) { + if (httpResponse.statusCode() != 200) { return; } @@ -209,7 +209,7 @@ protected Double getPrometheusMetric(String metricName, String[] labels) { .accept( httpResponse -> { assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.getStatusCode()).isEqualTo(200); + assertThat(httpResponse.statusCode()).isEqualTo(200); assertThat(httpResponse.body()).isNotNull(); assertThat(httpResponse.body().string()).isNotNull(); From 0421bd2dcef5ed9f2916f66bc2ca00b1297655e7 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 26 Jun 2024 23:13:53 -0400 Subject: [PATCH 19/77] Updated AntuBLUE Test Engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index d86da32b..b56116b9 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.1-ALPHA-2 + 7.0.1 From 3b02389de0c871a6ecb0904a503a101f19e1c797 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 00:14:12 -0400 Subject: [PATCH 20/77] Refactored OpenTelemetry tests Signed-off-by: dhoard --- .../AbstractOpenTelemetryTest.java | 300 +--------------- .../OpenTelemetryTestArguments.java | 61 ---- .../OpenTelemetryTestEnvironment.java | 328 ++++++++++++++++++ .../OpenTelemetryTest_v2_47_2.java | 43 +-- .../OpenTelemetryTest_v2_48_1.java | 43 +-- .../OpenTelemetryTest_v2_49_1.java | 43 +-- .../OpenTelemetryTest_v2_50_1.java | 43 +-- .../OpenTelemetryTest_v2_52_0.java | 43 +-- .../OpenTelemetryTest_v2_53_0.java | 43 +-- 9 files changed, 448 insertions(+), 499 deletions(-) delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 2be2df42..406da702 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -3,43 +3,26 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpClient; import io.prometheus.jmx.test.support.http.HttpRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.time.Duration; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.antublue.test.engine.api.TestEngine; import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; import org.antublue.test.engine.extras.throttle.Throttle; -import org.testcontainers.containers.BindMode; -import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; -import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; -import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; /** Class to implement AbstractOpenTelemetryTest */ public abstract class AbstractOpenTelemetryTest { - private static final long MEMORY_BYTES = 1073741824; // 1 GB - private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; - - private static final String BASE_URL = "http://localhost"; - private Network network; - private GenericContainer prometheusContainer; - private GenericContainer standaloneApplicationContainer; - private GenericContainer javaAgentApplicationContainer; - private GenericContainer standaloneExporterContainer; - private HttpClient httpClient; - @TestEngine.Argument public OpenTelemetryTestArguments openTelemetryTestArguments; + @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; @TestEngine.Prepare public void prepare() { @@ -50,57 +33,7 @@ public void prepare() { @TestEngine.BeforeAll public void beforeAll() { - switch (openTelemetryTestArguments.getJmxExporterMode()) { - case JavaAgent: - { - prometheusContainer = - createPrometheusContainer( - openTelemetryTestArguments.getJmxExporterMode(), - network, - openTelemetryTestArguments.getPrometheusDockerImageName(), - getClass().getName()); - - javaAgentApplicationContainer = - createJavaAgentApplicationContainer( - network, - openTelemetryTestArguments.getJavaDockerImageName(), - getClass().getName()); - - prometheusContainer.start(); - javaAgentApplicationContainer.start(); - - break; - } - case Standalone: - { - prometheusContainer = - createPrometheusContainer( - openTelemetryTestArguments.getJmxExporterMode(), - network, - openTelemetryTestArguments.getPrometheusDockerImageName(), - getClass().getName()); - - standaloneApplicationContainer = - createStandaloneApplicationContainer( - network, - openTelemetryTestArguments.getJavaDockerImageName(), - getClass().getName()); - - standaloneExporterContainer = - createStandaloneExporterContainer( - network, - openTelemetryTestArguments.getJavaDockerImageName(), - getClass().getName()); - - prometheusContainer.start(); - standaloneApplicationContainer.start(); - standaloneExporterContainer.start(); - - break; - } - } - - httpClient = createPrometheusHttpClient(prometheusContainer, BASE_URL, 9090); + openTelemetryTestEnvironment.initialize(getClass(), network); } /** Method to test that Prometheus is up */ @@ -150,7 +83,7 @@ public void testPrometheusMetrics() { ExpectedMetricsNames.getMetricsNames().stream() .filter( metricName -> { - if (openTelemetryTestArguments.getJmxExporterMode() + if (openTelemetryTestEnvironment.getJmxExporterMode() == JmxExporterMode.Standalone && metricName.startsWith("jvm_") || metricName.startsWith("process_")) { @@ -168,25 +101,7 @@ public void testPrometheusMetrics() { @TestEngine.AfterAll public void afterAll() { - if (javaAgentApplicationContainer != null) { - javaAgentApplicationContainer.close(); - javaAgentApplicationContainer = null; - } - - if (standaloneExporterContainer != null) { - standaloneExporterContainer.close(); - standaloneExporterContainer = null; - } - - if (standaloneApplicationContainer != null) { - standaloneApplicationContainer.close(); - standaloneApplicationContainer = null; - } - - if (prometheusContainer != null) { - prometheusContainer.close(); - prometheusContainer = null; - } + openTelemetryTestEnvironment.destroy(); } @TestEngine.Conclude @@ -196,10 +111,23 @@ public void conclude() { } } + /** + * Method to get a Prometheus metric + * + * @param metricName metricName + * @return the metric value, or null if it doesn't exist + */ protected Double getPrometheusMetric(String metricName) { return getPrometheusMetric(metricName, null); } + /** + * Method to get a Promethehus metrics + * + * @param metricName metricName + * @param labels labels + * @return the metric value, or null if it doesn't exist + */ protected Double getPrometheusMetric(String metricName, String[] labels) { Throttle throttle = new ExponentialBackoffThrottle(100, 6400); AtomicReference value = new AtomicReference<>(); @@ -247,198 +175,6 @@ protected HttpResponse sendPrometheusQuery(String query) { * @return an HttpResponse */ protected HttpResponse sendRequest(String path) { - return httpClient.send(new HttpRequest(path)); - } - - /** - * Method to create an HttpClient - * - * @param genericContainer genericContainer - * @param baseUrl baseUrl - * @return the return value - */ - private static HttpClient createPrometheusHttpClient( - GenericContainer genericContainer, String baseUrl, int mappedPort) { - return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); - } - - /** - * Method to create a Prometheus container - * - * @param network network - * @param prometheusDockerImageName prometheusDockerImageName - * @param testName testName - * @return the return value - */ - private static GenericContainer createPrometheusContainer( - JmxExporterMode jmxExporterMode, - Network network, - String prometheusDockerImageName, - String testName) { - return new GenericContainer<>(prometheusDockerImageName) - .withClasspathResourceMapping( - testName.replace(".", "/") + "/" + jmxExporterMode + "/prometheus.yml", - "/etc/prometheus/prometheus.yml", - BindMode.READ_ONLY) - .withWorkingDirectory("/prometheus") - .withCommand( - "--config.file=/etc/prometheus/prometheus.yml", - "--storage.tsdb.path=/prometheus", - "--web.console.libraries=/usr/share/prometheus/console_libraries", - "--web.console.templates=/usr/share/prometheus/consoles", - "--enable-feature=otlp-write-receiver") - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withExposedPorts(9090) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("prometheus") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)); - } - - /** - * Method to create an application container - * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName - * @return the return value - */ - private static GenericContainer createJavaAgentApplicationContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forLogMessage(".*Running.*", 1)) - .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) - .withClasspathResourceMapping( - testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withCommand("/bin/sh application.sh") - .withExposedPorts(8888) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("application") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); - } - - /** - * Method to create an application container - * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName - * @return the return value - */ - private static GenericContainer createStandaloneApplicationContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forLogMessage(".*Running.*", 1)) - .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) - .withClasspathResourceMapping( - testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withCommand("/bin/sh application.sh") - .withExposedPorts(9999) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("application") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); - } - - /** - * Method to create an exporter container - * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName - * @return the return value - */ - private static GenericContainer createStandaloneExporterContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forListeningPort()) - .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) - .withClasspathResourceMapping( - testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withCommand("/bin/sh exporter.sh") - .withExposedPorts(8888) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("exporter") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); + return openTelemetryTestEnvironment.getPrometheusHttpClient().send(new HttpRequest(path)); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java deleted file mode 100644 index 546db741..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestArguments.java +++ /dev/null @@ -1,61 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JmxExporterMode; -import org.antublue.test.engine.api.Argument; - -public class OpenTelemetryTestArguments implements Argument { - - private final String name; - private final String prometheusDockerImageName; - private final String javaDockerImageName; - private final JmxExporterMode jmxExporterMode; - - private OpenTelemetryTestArguments( - String name, - String prometheusDockerImageName, - String javaDockerImageName, - JmxExporterMode jmxExporterMode) { - this.name = name; - this.prometheusDockerImageName = prometheusDockerImageName; - this.javaDockerImageName = javaDockerImageName; - this.jmxExporterMode = jmxExporterMode; - } - - @Override - public String getName() { - return name; - } - - @Override - public OpenTelemetryTestArguments getPayload() { - return this; - } - - public String getPrometheusDockerImageName() { - return prometheusDockerImageName; - } - - public String getJavaDockerImageName() { - return javaDockerImageName; - } - - public JmxExporterMode getJmxExporterMode() { - return jmxExporterMode; - } - - @Override - public String toString() { - return String.format( - "TestArgument{name=[%s],dockerImageName=[%s],mode=[%s]}", - name, javaDockerImageName, jmxExporterMode); - } - - public static OpenTelemetryTestArguments of( - String name, - String prometheusDockerImageName, - String javaDockerImageName, - JmxExporterMode jmxExporterMode) { - return new OpenTelemetryTestArguments( - name, prometheusDockerImageName, javaDockerImageName, jmxExporterMode); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java new file mode 100644 index 00000000..158c619d --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -0,0 +1,328 @@ +package io.prometheus.jmx.test.opentelemetry; + +import com.github.dockerjava.api.model.Ulimit; +import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpClient; +import java.time.Duration; +import org.antublue.test.engine.api.Argument; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; +import org.testcontainers.containers.wait.strategy.Wait; + +public class OpenTelemetryTestEnvironment implements Argument { + + private static final long MEMORY_BYTES = 1073741824; // 1 GB + private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; + private static final String BASE_URL = "http://localhost"; + + private final String prometheusDockerImageName; + private final String javaDockerImageName; + private final JmxExporterMode jmxExporterMode; + + private Class testClass; + private Network network; + private GenericContainer prometheusContainer; + private GenericContainer standaloneApplicationContainer; + private GenericContainer javaAgentApplicationContainer; + private GenericContainer standaloneExporterContainer; + private HttpClient httpClient; + + public OpenTelemetryTestEnvironment( + String prometheusDockerImageName, + String javaDockerImageName, + JmxExporterMode jmxExporterMode) { + this.prometheusDockerImageName = prometheusDockerImageName; + this.javaDockerImageName = javaDockerImageName; + this.jmxExporterMode = jmxExporterMode; + } + + @Override + public String getName() { + return prometheusDockerImageName + " / " + javaDockerImageName + " / " + jmxExporterMode; + } + + @Override + public OpenTelemetryTestEnvironment getPayload() { + return this; + } + + /** + * Method to get the Prometheus Docker image name + * + * @return the Prometheus Docker image name + */ + public String getPrometheusDockerImageName() { + return prometheusDockerImageName; + } + + /** + * Method to get the Java Docker image name + * + * @return the Java Docker image name + */ + public String getJavaDockerImageName() { + return javaDockerImageName; + } + + /** + * Method to get the JMX Exporter mode + * + * @return the JMX Exporter mode + */ + public JmxExporterMode getJmxExporterMode() { + return jmxExporterMode; + } + + /** + * Method to initialize the test environment + * + * @param network network + */ + public void initialize(Class testClass, Network network) { + this.testClass = testClass; + this.network = network; + + switch (jmxExporterMode) { + case JavaAgent: + { + prometheusContainer = createPrometheusContainer(); + javaAgentApplicationContainer = createJavaAgentApplicationContainer(); + + prometheusContainer.start(); + javaAgentApplicationContainer.start(); + + break; + } + case Standalone: + { + prometheusContainer = createPrometheusContainer(); + standaloneApplicationContainer = createStandaloneApplicationContainer(); + standaloneExporterContainer = createStandaloneExporterContainer(); + + prometheusContainer.start(); + standaloneApplicationContainer.start(); + standaloneExporterContainer.start(); + + break; + } + } + + httpClient = createPrometheusHttpClient(prometheusContainer, BASE_URL, 9090); + } + + /** + * Method to get an HttpClient for the test environment + * + * @return an HttpClient + */ + public HttpClient getPrometheusHttpClient() { + return httpClient; + } + + /** Method to destroy the test environment */ + public void destroy() { + if (javaAgentApplicationContainer != null) { + javaAgentApplicationContainer.close(); + javaAgentApplicationContainer = null; + } + + if (standaloneExporterContainer != null) { + standaloneExporterContainer.close(); + standaloneExporterContainer = null; + } + + if (standaloneApplicationContainer != null) { + standaloneApplicationContainer.close(); + standaloneApplicationContainer = null; + } + + if (prometheusContainer != null) { + prometheusContainer.close(); + prometheusContainer = null; + } + } + + /** + * Method to create a Prometheus container + * + * @return the return value + */ + private GenericContainer createPrometheusContainer() { + return new GenericContainer<>(prometheusDockerImageName) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + + "/" + + jmxExporterMode + + "/prometheus.yml", + "/etc/prometheus/prometheus.yml", + BindMode.READ_ONLY) + .withWorkingDirectory("/prometheus") + .withCommand( + "--config.file=/etc/prometheus/prometheus.yml", + "--storage.tsdb.path=/prometheus", + "--web.console.libraries=/usr/share/prometheus/console_libraries", + "--web.console.templates=/usr/share/prometheus/consoles", + "--enable-feature=otlp-write-receiver") + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withExposedPorts(9090) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("prometheus") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)); + } + + /** + * Method to create an application container + * + * @return the return value + */ + private GenericContainer createJavaAgentApplicationContainer() { + return new GenericContainer<>(javaDockerImageName) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + "/JavaAgent", + "/temp", + BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh application.sh") + .withExposedPorts(8888) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("application") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } + + /** + * Method to create an application container + * + * @return the return value + */ + private GenericContainer createStandaloneApplicationContainer() { + return new GenericContainer<>(javaDockerImageName) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + "/Standalone", + "/temp", + BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh application.sh") + .withExposedPorts(9999) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("application") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } + + /** + * Method to create an exporter container + * + * @return the return value + */ + private GenericContainer createStandaloneExporterContainer() { + return new GenericContainer<>(javaDockerImageName) + .waitingFor(Wait.forListeningPort()) + .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + "/Standalone", + "/temp", + BindMode.READ_ONLY) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withCommand("/bin/sh exporter.sh") + .withExposedPorts(8888) + .withLogConsumer( + outputFrame -> { + String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("exporter") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)) + .withWorkingDirectory("/temp"); + } + + /** + * Method to create an HttpClient + * + * @param genericContainer genericContainer + * @param baseUrl baseUrl + * @return the return value + */ + private static HttpClient createPrometheusHttpClient( + GenericContainer genericContainer, String baseUrl, int mappedPort) { + return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java index ba56441e..98d8dd94 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_47_2 */ public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.47.2"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.47.2"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index aac72bc1..3d5a866c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_48_1 */ public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.48.1"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.48.1"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index 070111dd..3a1a5fde 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_49_1 */ public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.49.1"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.49.1"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index 861c3f2e..873b1259 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_50_1 */ public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.50.1"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.50.1"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index c8f4d258..a4a5ee0f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_52_0 */ public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.52.0"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.52.0"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index e955b5bf..8f994263 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -3,45 +3,36 @@ import io.prometheus.jmx.test.support.DockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; /** Class to implement OpenTelemetryTest_v2_53_0 */ public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.53.0"; + /** * Method to get the list of TestArguments * * @return the return value */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - List openTelemetryTestArguments = new ArrayList<>(); - - List prometheusDockerImageNames = new ArrayList<>(); - prometheusDockerImageNames.add("prom/prometheus:v2.53.0"); + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); - prometheusDockerImageNames.forEach( - prometheusDockerImage -> - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestArguments.add( - OpenTelemetryTestArguments.of( - prometheusDockerImage - + " / " - + javaDockerImageName - + " / " - + jmxExporterMode, - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + DockerImageNames.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + PROMETHEUS_DOCKER_IMAGE_NAME, + javaDockerImageName, + jmxExporterMode)); + } + }); - return openTelemetryTestArguments.stream(); + return openTelemetryTestEnvironments.stream(); } } From d8dce81d1495ec666176e32ba0d8bc94afc888f2 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 00:15:01 -0400 Subject: [PATCH 21/77] Code cleanup Signed-off-by: dhoard --- .../jmx/test/opentelemetry/AbstractOpenTelemetryTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 406da702..a1fdf9d1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -14,6 +14,7 @@ import org.antublue.test.engine.api.TestEngine; import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; import org.antublue.test.engine.extras.throttle.Throttle; +import org.junit.jupiter.api.Assertions; import org.testcontainers.containers.Network; import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; @@ -73,7 +74,7 @@ public void testPrometheusIsUp() { } if (!success.get()) { - fail("Prometheus is not up"); + Assertions.fail("Prometheus is not up"); } } From 789649b230d4efc64065632b58572fcf9c6e1e06 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 00:15:26 -0400 Subject: [PATCH 22/77] Code cleanup Signed-off-by: dhoard --- .../jmx/test/opentelemetry/AbstractOpenTelemetryTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index a1fdf9d1..36322a85 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -1,7 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpRequest; From 038ad85543aceed2dc6f250c29d777ce0c8ce1e0 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 00:25:55 -0400 Subject: [PATCH 23/77] Fixed spelling Signed-off-by: dhoard --- .../jmx/test/opentelemetry/AbstractOpenTelemetryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 36322a85..132cc6f4 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -122,7 +122,7 @@ protected Double getPrometheusMetric(String metricName) { } /** - * Method to get a Promethehus metrics + * Method to get a Prometheus metrics * * @param metricName metricName * @param labels labels From 2702d30de4fc8fc32bfdf72d6f4c9c0bdbb559a0 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 01:04:26 -0400 Subject: [PATCH 24/77] Renamed test methods Signed-off-by: dhoard --- .../jmx/test/opentelemetry/AbstractOpenTelemetryTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 132cc6f4..edea8cff 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -39,7 +39,7 @@ public void beforeAll() { /** Method to test that Prometheus is up */ @TestEngine.Test @TestEngine.Order(order = 0) - public void testPrometheusIsUp() { + public void testIsPrometheusUp() { Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicBoolean success = new AtomicBoolean(); @@ -79,7 +79,7 @@ public void testPrometheusIsUp() { /** Method to test that metrics exist in Prometheus */ @TestEngine.Test - public void testPrometheusMetrics() { + public void testPrometheusHasMetrics() { ExpectedMetricsNames.getMetricsNames().stream() .filter( metricName -> { From 96396a130c6f7a55c7a07f0034e489afa5ffd7d5 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 01:12:35 -0400 Subject: [PATCH 25/77] Refactored common code to abstract base class. Renamed DockerImageNames to JavaDockerImageNames Signed-off-by: dhoard --- ...geNames.java => JavaDockerImageNames.java} | 8 +++--- .../io/prometheus/jmx/test/AbstractTest.java | 4 +-- .../AbstractOpenTelemetryTest.java | 23 ++++++++++++++++ .../OpenTelemetryTest_v2_47_2.java | 25 +++++------------- .../OpenTelemetryTest_v2_48_1.java | 26 ++++++------------- .../OpenTelemetryTest_v2_49_1.java | 26 ++++++------------- .../OpenTelemetryTest_v2_50_1.java | 26 ++++++------------- .../OpenTelemetryTest_v2_52_0.java | 26 ++++++------------- .../OpenTelemetryTest_v2_53_0.java | 26 ++++++------------- 9 files changed, 76 insertions(+), 114 deletions(-) rename integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/{DockerImageNames.java => JavaDockerImageNames.java} (95%) diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/DockerImageNames.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java similarity index 95% rename from integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/DockerImageNames.java rename to integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java index 5d1fa79c..e4a1f278 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/DockerImageNames.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java @@ -29,7 +29,7 @@ import java.util.stream.Stream; /** Class to get Docker image names */ -public final class DockerImageNames { +public final class JavaDockerImageNames { private static final String DOCKER_IMAGE_NAMES_CONFIGURATION = "docker.image.names"; @@ -44,7 +44,7 @@ public final class DockerImageNames { public static final Predicate ALL_JAVA_VERSIONS = name -> true; /** Constructor */ - private DockerImageNames() { + private JavaDockerImageNames() { // DO NOTHING } @@ -66,7 +66,7 @@ public static Stream names() { public static Stream names(Predicate predicate) { Objects.requireNonNull(predicate); - synchronized (DockerImageNames.class) { + synchronized (JavaDockerImageNames.class) { if (ALL_DOCKER_IMAGE_NAMES == null) { ALL_DOCKER_IMAGE_NAMES = load(ALL_DOCKER_IMAGE_NAMES_RESOURCE); } @@ -131,7 +131,7 @@ private static String[] load(String resource) { bufferedReader = new BufferedReader( new InputStreamReader( - DockerImageNames.class.getResourceAsStream(resource), + JavaDockerImageNames.class.getResourceAsStream(resource), StandardCharsets.UTF_8)); while (true) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java index 92c5413e..abea0275 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java @@ -17,7 +17,7 @@ package io.prometheus.jmx.test; import com.github.dockerjava.api.model.Ulimit; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.TestArguments; import io.prometheus.jmx.test.support.TestEnvironment; @@ -52,7 +52,7 @@ public abstract class AbstractTest { public static Stream arguments() { List testArguments = new ArrayList<>(); - DockerImageNames.names() + JavaDockerImageNames.names() .forEach( dockerImageName -> { for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index edea8cff..1ddcd145 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -7,6 +7,9 @@ import io.prometheus.jmx.test.support.http.HttpResponse; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -24,6 +27,26 @@ public abstract class AbstractOpenTelemetryTest { @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; + protected static Collection buildTestEnvironments( + String prometheusDockerImageName, + List javaDockerImageNames, + JmxExporterMode[] jmsExporterModes) { + Collection openTelemetryTestEnvironments = new ArrayList<>(); + + javaDockerImageNames.forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImageName, + javaDockerImageName, + jmxExporterMode)); + } + }); + + return openTelemetryTestEnvironments; + } + @TestEngine.Prepare public void prepare() { // Get the Network and get the id to force the network creation diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java index 98d8dd94..12158455 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -1,9 +1,8 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +18,10 @@ public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index 3d5a866c..4722d410 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -1,9 +1,9 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; + +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +19,10 @@ public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index 3a1a5fde..b5abe5a4 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -1,9 +1,9 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; + +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +19,10 @@ public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index 873b1259..9d59862d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -1,9 +1,9 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; + +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +19,10 @@ public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index a4a5ee0f..0716ef99 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -1,9 +1,9 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; + +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +19,10 @@ public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index 8f994263..096059e9 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -1,9 +1,9 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.DockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.ArrayList; -import java.util.Collection; + +import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,20 +19,10 @@ public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { */ @TestEngine.ArgumentSupplier public static Stream arguments() { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - DockerImageNames.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - PROMETHEUS_DOCKER_IMAGE_NAME, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImageNames.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); } } From 0748089f6a783ea2a1b4fa70ec26c14297e814ff Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 01:12:55 -0400 Subject: [PATCH 26/77] Refactored common code to abstract base class. Renamed DockerImageNames to JavaDockerImageNames Signed-off-by: dhoard --- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java | 1 - .../jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java | 1 - .../jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java | 1 - .../jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java | 1 - .../jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java | 1 - 5 files changed, 5 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index 4722d410..bc3309a4 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; - import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index b5abe5a4..55d98623 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; - import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index 9d59862d..3186dd50 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; - import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index 0716ef99..423b8ce4 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; - import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index 096059e9..e2a9158b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImageNames; import io.prometheus.jmx.test.support.JmxExporterMode; - import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; From 9fe682200992aedd146fa5f8f5fd216d773d496c Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 01:15:09 -0400 Subject: [PATCH 27/77] Updated Javadoc Signed-off-by: dhoard --- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java | 4 ++-- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java | 4 ++-- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java | 4 ++-- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java | 4 ++-- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java | 4 ++-- .../jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java index 12158455..b0750a08 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.47.2"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index bc3309a4..7e10f81d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.48.1"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index 55d98623..7f15fba1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.49.1"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index 3186dd50..3426cba7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.50.1"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index 423b8ce4..02135731 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.52.0"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index e2a9158b..7bed7f49 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -12,9 +12,9 @@ public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.53.0"; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier public static Stream arguments() { From 5f80863bdeec02c019c0c0ae92b1b316e9e968ed Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 08:35:22 -0400 Subject: [PATCH 28/77] Refactored Docker Java image handling Signed-off-by: dhoard --- .circleci/config.yml | 2 +- integration_test_suite/README.md | 4 +- ...rImageNames.java => JavaDockerImages.java} | 40 ++++++++++--------- .../jmx/test/support/TestEnvironment.java | 2 +- .../io/prometheus/jmx/test/AbstractTest.java | 4 +- .../AbstractOpenTelemetryTest.java | 8 ++-- .../OpenTelemetryTest_v2_47_2.java | 4 +- .../OpenTelemetryTest_v2_48_1.java | 4 +- .../OpenTelemetryTest_v2_49_1.java | 4 +- .../OpenTelemetryTest_v2_50_1.java | 4 +- .../OpenTelemetryTest_v2_52_0.java | 4 +- .../OpenTelemetryTest_v2_53_0.java | 4 +- ...e-names.all.txt => java-docker-images.txt} | 0 ....txt => smoke-test-java-docker-images.txt} | 0 ...ages.all.sh => pull-java-docker-images.sh} | 2 +- ...st.sh => pull-smoke-test-docker-images.sh} | 2 +- 16 files changed, 45 insertions(+), 43 deletions(-) rename integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/{JavaDockerImageNames.java => JavaDockerImages.java} (75%) rename integration_test_suite/integration_tests/src/test/resources/{docker-image-names.all.txt => java-docker-images.txt} (100%) rename integration_test_suite/integration_tests/src/test/resources/{docker-image-names.smoke-test.txt => smoke-test-java-docker-images.txt} (100%) rename integration_test_suite/{docker-pull-images.all.sh => pull-java-docker-images.sh} (79%) rename integration_test_suite/{docker-pull-images.smoke-test.sh => pull-smoke-test-docker-images.sh} (78%) diff --git a/.circleci/config.yml b/.circleci/config.yml index f563b708..b7d5e1d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: - checkout - restore_cache: key: maven-dependencies-{{ checksum "pom.xml" }} - - run: ./integration_test_suite/docker-pull-images.smoke-test.sh + - run: ./integration_test_suite/pull-smoke-test-docker-images.sh - run: ./mvnw clean install - run: ./mvnw javadoc:jar - save_cache: diff --git a/integration_test_suite/README.md b/integration_test_suite/README.md index e4403800..8ec7e527 100644 --- a/integration_test_suite/README.md +++ b/integration_test_suite/README.md @@ -44,13 +44,13 @@ Pulling Docker images (not required, but you may see request timeouts/pull failu Smoke test Docker images ```shell -./integration_test_suite/docker-pull-images.smoke-test.sh +./integration_test_suite/pull-smoke-test-docker-images.sh ``` All Docker images ```shell -./integration_test_suite/docker-pull-images.all.sh +./integration_test_suite/pull-java-docker-images.sh ``` ## Notes diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java similarity index 75% rename from integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java rename to integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java index e4a1f278..458135f6 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImageNames.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java @@ -29,22 +29,24 @@ import java.util.stream.Stream; /** Class to get Docker image names */ -public final class JavaDockerImageNames { +public final class JavaDockerImages { - private static final String DOCKER_IMAGE_NAMES_CONFIGURATION = "docker.image.names"; + private static final String JAVA_DOCKER_IMAGES_CONFIGURATION = "java.docker.images"; - private static final String ALL_DOCKER_IMAGE_NAMES_RESOURCE = "/docker-image-names.all.txt"; - private static String[] ALL_DOCKER_IMAGE_NAMES; + private static final String JAVA_DOCKER_IMAGES_RESOURCE = "/java-docker-images.txt"; - private static final String SMOKE_TEST_DOCKER_IMAGE_NAMES_RESOURCE = - "/docker-image-names.smoke-test.txt"; - private static String[] SMOKE_TEST_DOCKER_IMAGE_NAMES; + private static final String SMOKE_TEST_JAVA_DOCKER_IMAGES_RESOURCE = + "/smoke-test-java-docker-images.txt"; + + private static String[] ALL_JAVA_DOCKER_IMAGE_NAMES; + + private static String[] SMOKE_TEST_JAVA_DOCKER_IMAGES; /** Predicate to accept all Docker image names */ public static final Predicate ALL_JAVA_VERSIONS = name -> true; /** Constructor */ - private JavaDockerImageNames() { + private JavaDockerImages() { // DO NOTHING } @@ -66,12 +68,12 @@ public static Stream names() { public static Stream names(Predicate predicate) { Objects.requireNonNull(predicate); - synchronized (JavaDockerImageNames.class) { - if (ALL_DOCKER_IMAGE_NAMES == null) { - ALL_DOCKER_IMAGE_NAMES = load(ALL_DOCKER_IMAGE_NAMES_RESOURCE); + synchronized (JavaDockerImages.class) { + if (ALL_JAVA_DOCKER_IMAGE_NAMES == null) { + ALL_JAVA_DOCKER_IMAGE_NAMES = load(JAVA_DOCKER_IMAGES_RESOURCE); } - if (SMOKE_TEST_DOCKER_IMAGE_NAMES == null) { - SMOKE_TEST_DOCKER_IMAGE_NAMES = load(SMOKE_TEST_DOCKER_IMAGE_NAMES_RESOURCE); + if (SMOKE_TEST_JAVA_DOCKER_IMAGES == null) { + SMOKE_TEST_JAVA_DOCKER_IMAGES = load(SMOKE_TEST_JAVA_DOCKER_IMAGES_RESOURCE); } } @@ -79,7 +81,7 @@ public static Stream names(Predicate predicate) { String dockerImageNameValue = System.getenv( - DOCKER_IMAGE_NAMES_CONFIGURATION + JAVA_DOCKER_IMAGES_CONFIGURATION .toUpperCase(Locale.ENGLISH) .replace('.', '_')); @@ -91,7 +93,7 @@ public static Stream names(Predicate predicate) { } if (dockerImageNameValue == null) { - dockerImageNameValue = System.getProperty(DOCKER_IMAGE_NAMES_CONFIGURATION); + dockerImageNameValue = System.getProperty(JAVA_DOCKER_IMAGES_CONFIGURATION); if (dockerImageNameValue != null) { if (dockerImageNameValue.isBlank()) { dockerImageNameValue = null; @@ -100,9 +102,9 @@ public static Stream names(Predicate predicate) { } if (dockerImageNameValue == null) { - dockerImageNames = SMOKE_TEST_DOCKER_IMAGE_NAMES; + dockerImageNames = SMOKE_TEST_JAVA_DOCKER_IMAGES; } else if (dockerImageNameValue.equalsIgnoreCase("ALL")) { - dockerImageNames = ALL_DOCKER_IMAGE_NAMES; + dockerImageNames = ALL_JAVA_DOCKER_IMAGE_NAMES; } else { dockerImageNames = dockerImageNameValue.split("\\s+"); } @@ -131,7 +133,7 @@ private static String[] load(String resource) { bufferedReader = new BufferedReader( new InputStreamReader( - JavaDockerImageNames.class.getResourceAsStream(resource), + JavaDockerImages.class.getResourceAsStream(resource), StandardCharsets.UTF_8)); while (true) { @@ -149,7 +151,7 @@ private static String[] load(String resource) { return dockerImageNames.toArray(new String[0]); } catch (IOException e) { throw new RuntimeException( - "Exception reading resource " + ALL_DOCKER_IMAGE_NAMES_RESOURCE, e); + "Exception reading resource " + JAVA_DOCKER_IMAGES_RESOURCE, e); } } } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java index d4b96215..2d6e13ff 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java @@ -20,7 +20,7 @@ import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; -/** Class to a TestContext */ +/** Class to TestEnvironment */ public class TestEnvironment { private Network network; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java index abea0275..da34aa27 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java @@ -17,7 +17,7 @@ package io.prometheus.jmx.test; import com.github.dockerjava.api.model.Ulimit; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.TestArguments; import io.prometheus.jmx.test.support.TestEnvironment; @@ -52,7 +52,7 @@ public abstract class AbstractTest { public static Stream arguments() { List testArguments = new ArrayList<>(); - JavaDockerImageNames.names() + JavaDockerImages.names() .forEach( dockerImageName -> { for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 1ddcd145..a8053aa3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -28,17 +28,17 @@ public abstract class AbstractOpenTelemetryTest { @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; protected static Collection buildTestEnvironments( - String prometheusDockerImageName, - List javaDockerImageNames, + String prometheusDockerImage, + List javaDockerImages, JmxExporterMode[] jmsExporterModes) { Collection openTelemetryTestEnvironments = new ArrayList<>(); - javaDockerImageNames.forEach( + javaDockerImages.forEach( javaDockerImageName -> { for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { openTelemetryTestEnvironments.add( new OpenTelemetryTestEnvironment( - prometheusDockerImageName, + prometheusDockerImage, javaDockerImageName, jmxExporterMode)); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java index b0750a08..99cf96b1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index 7e10f81d..078a0b71 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index 7f15fba1..ae01b287 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index 3426cba7..e9d9d39c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index 02135731..83545114 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index 7bed7f49..9b6d6582 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -1,6 +1,6 @@ package io.prometheus.jmx.test.opentelemetry; -import io.prometheus.jmx.test.support.JavaDockerImageNames; +import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,7 +20,7 @@ public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { public static Stream arguments() { return buildTestEnvironments( PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImageNames.names().collect(Collectors.toList()), + JavaDockerImages.names().collect(Collectors.toList()), JmxExporterMode.values()) .stream(); } diff --git a/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt b/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt rename to integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt diff --git a/integration_test_suite/integration_tests/src/test/resources/docker-image-names.smoke-test.txt b/integration_test_suite/integration_tests/src/test/resources/smoke-test-java-docker-images.txt similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/docker-image-names.smoke-test.txt rename to integration_test_suite/integration_tests/src/test/resources/smoke-test-java-docker-images.txt diff --git a/integration_test_suite/docker-pull-images.all.sh b/integration_test_suite/pull-java-docker-images.sh similarity index 79% rename from integration_test_suite/docker-pull-images.all.sh rename to integration_test_suite/pull-java-docker-images.sh index 1464ce1f..b7c90fd0 100755 --- a/integration_test_suite/docker-pull-images.all.sh +++ b/integration_test_suite/pull-java-docker-images.sh @@ -17,7 +17,7 @@ function check_exit_code() { fi } -grep -v '^#' integration_tests/src/test/resources/docker-image-names.all.txt | while read -r LINE; +grep -v '^#' integration_tests/src/test/resources/java-docker-images.txt | while read -r LINE; do docker pull "${LINE}" check_exit_code "${LINE}" diff --git a/integration_test_suite/docker-pull-images.smoke-test.sh b/integration_test_suite/pull-smoke-test-docker-images.sh similarity index 78% rename from integration_test_suite/docker-pull-images.smoke-test.sh rename to integration_test_suite/pull-smoke-test-docker-images.sh index 5f25e001..27a44de7 100755 --- a/integration_test_suite/docker-pull-images.smoke-test.sh +++ b/integration_test_suite/pull-smoke-test-docker-images.sh @@ -17,7 +17,7 @@ function check_exit_code() { fi } -grep -v '^#' integration_tests/src/test/resources/docker-image-names.smoke-test.txt | while read -r LINE; +grep -v '^#' integration_tests/src/test/resources/smoke-test-java-docker-images.txt | while read -r LINE; do docker pull "${LINE}" check_exit_code "${LINE}" From 6e2002dc7dcb70958ce8a16b95cde3a708110270 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 27 Jun 2024 12:38:50 -0400 Subject: [PATCH 29/77] Updated README.md Signed-off-by: dhoard --- integration_test_suite/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/integration_test_suite/README.md b/integration_test_suite/README.md index 8ec7e527..77b24223 100644 --- a/integration_test_suite/README.md +++ b/integration_test_suite/README.md @@ -4,11 +4,11 @@ Integration Test Suite ### Smoke test Docker images tested -[Smoke test Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/docker-image-names.smoke-test.txt) +[Smoke test Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/smoke-test-java-docker-images.txt) ### Docker images tested (all) -[All Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt) +[All Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt) ### Running the integration test suite (smoke test Docker images) @@ -19,21 +19,21 @@ Integration Test Suite ### Run the integration test suite (all Docker images) ```shell -export DOCKER_IMAGE_NAMES=ALL +export JAVA_DOCKER_IMAGES=ALL ./mvnw clean verify ``` ### Run the integration test suite on a specific Docker image ```shell -export DOCKER_IMAGE_NAMES="" +export JAVA_DOCKER_IMAGES="" ./mvnw clean verify ``` Example: ```shell -export DOCKER_IMAGE_NAMES="azul/zulu-openjdk:17" +export JAVA_DOCKER_IMAGES="azul/zulu-openjdk:17" ./mvnw clean verify ``` From a846e5cf21bebe5983886b1e7e6f0cc6671cb234 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 00:32:56 -0400 Subject: [PATCH 30/77] Changed script name Signed-off-by: dhoard --- .../pull-smoke-test-java-docker-images.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 integration_test_suite/pull-smoke-test-java-docker-images.sh diff --git a/integration_test_suite/pull-smoke-test-java-docker-images.sh b/integration_test_suite/pull-smoke-test-java-docker-images.sh new file mode 100755 index 00000000..27a44de7 --- /dev/null +++ b/integration_test_suite/pull-smoke-test-java-docker-images.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PWD="$PWD" +function exit_trap() { + cd "${PWD}" + echo $? +} +trap exit_trap EXIT +SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd "${SCRIPT_DIRECTORY}" + +function check_exit_code() { + if [ "$?" != "0" ]; + then + echo "Failed to pull Docker image ${1}"; + exit $? + fi +} + +grep -v '^#' integration_tests/src/test/resources/smoke-test-java-docker-images.txt | while read -r LINE; +do + docker pull "${LINE}" + check_exit_code "${LINE}" +done From 356cd79701cb100a1f46baf88346f7b92fa2d8ed Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 00:33:20 -0400 Subject: [PATCH 31/77] Removed old script Signed-off-by: dhoard --- .../pull-smoke-test-docker-images.sh | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100755 integration_test_suite/pull-smoke-test-docker-images.sh diff --git a/integration_test_suite/pull-smoke-test-docker-images.sh b/integration_test_suite/pull-smoke-test-docker-images.sh deleted file mode 100755 index 27a44de7..00000000 --- a/integration_test_suite/pull-smoke-test-docker-images.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -PWD="$PWD" -function exit_trap() { - cd "${PWD}" - echo $? -} -trap exit_trap EXIT -SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) -cd "${SCRIPT_DIRECTORY}" - -function check_exit_code() { - if [ "$?" != "0" ]; - then - echo "Failed to pull Docker image ${1}"; - exit $? - fi -} - -grep -v '^#' integration_tests/src/test/resources/smoke-test-java-docker-images.txt | while read -r LINE; -do - docker pull "${LINE}" - check_exit_code "${LINE}" -done From b4349f794d726eefaf3f391590b903648377041a Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 08:14:56 -0400 Subject: [PATCH 32/77] Updated README.md Signed-off-by: dhoard --- integration_test_suite/README.md | 41 +++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/integration_test_suite/README.md b/integration_test_suite/README.md index 77b24223..fb70544b 100644 --- a/integration_test_suite/README.md +++ b/integration_test_suite/README.md @@ -1,12 +1,10 @@ -Integration Test Suite ---- ---- +# Integration Test Suite -### Smoke test Docker images tested +### Smoke test Java Docker images tested [Smoke test Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/smoke-test-java-docker-images.txt) -### Docker images tested (all) +### All Java Docker images tested (all) [All Docker images](https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt) @@ -44,7 +42,7 @@ Pulling Docker images (not required, but you may see request timeouts/pull failu Smoke test Docker images ```shell -./integration_test_suite/pull-smoke-test-docker-images.sh +./integration_test_suite/pull-smoke-test-java-docker-images.sh ``` All Docker images @@ -56,3 +54,34 @@ All Docker images ## Notes - You may need to set up Docker hub login to pull images + +# Docker networks + +By default, Docker is not configured to run a large number images simultaneously. + +You can increase Docker networks by creating a Docker network configuration file... + +``` +/etc/docker/daemon.json +``` + +... with the content... + +```yaml +{ + "default-address-pools": [ + { + "base": "172.16.0.0/16", + "size": 24 + }, + { + "base": "192.168.0.0/16", + "size": 24 + } + ] +} +``` + +## Notes + +- Docker will need to be restarted \ No newline at end of file From 66a8eea5bd952c1309574b423698b3231d4382de Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 09:00:30 -0400 Subject: [PATCH 33/77] Updated AntuBLUE Test Engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index b56116b9..c05a9a9b 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.1 + 7.0.3 From 09561e0c2bf88793201028b3236339ed77df5b66 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 09:22:54 -0400 Subject: [PATCH 34/77] Code cleanup Signed-off-by: dhoard --- .../integration_tests/pom.xml | 3 +- .../OpenTelemetryTestEnvironment.java | 30 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index c05a9a9b..03e19082 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,8 @@ 11 UTF-8 UTF-8 - 7.0.3 + + 7.x.x-SNAPSHOT diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 158c619d..857cb160 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -17,8 +17,8 @@ public class OpenTelemetryTestEnvironment implements Argument testClass; @@ -30,17 +30,17 @@ public class OpenTelemetryTestEnvironment implements Argument createPrometheusContainer() { - return new GenericContainer<>(prometheusDockerImageName) + return new GenericContainer<>(prometheusDockerImage) .withClasspathResourceMapping( testClass.getName().replace(".", "/") + "/" @@ -197,7 +197,7 @@ private GenericContainer createPrometheusContainer() { * @return the return value */ private GenericContainer createJavaAgentApplicationContainer() { - return new GenericContainer<>(javaDockerImageName) + return new GenericContainer<>(javaDockerImage) .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( @@ -238,7 +238,7 @@ private GenericContainer createJavaAgentApplicationContainer() { * @return the return value */ private GenericContainer createStandaloneApplicationContainer() { - return new GenericContainer<>(javaDockerImageName) + return new GenericContainer<>(javaDockerImage) .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( @@ -279,7 +279,7 @@ private GenericContainer createStandaloneApplicationContainer() { * @return the return value */ private GenericContainer createStandaloneExporterContainer() { - return new GenericContainer<>(javaDockerImageName) + return new GenericContainer<>(javaDockerImage) .waitingFor(Wait.forListeningPort()) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( From 82bcedfb20daf7d2aba5d25f89abfc7b37fabb0a Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 09:24:21 -0400 Subject: [PATCH 35/77] Updated Javadoc Signed-off-by: dhoard --- .../opentelemetry/OpenTelemetryTestEnvironment.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 857cb160..efd812c6 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -11,6 +11,7 @@ import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; import org.testcontainers.containers.wait.strategy.Wait; +/** Class to implement OpenTelemetryTestEnvironment */ public class OpenTelemetryTestEnvironment implements Argument { private static final long MEMORY_BYTES = 1073741824; // 1 GB @@ -29,6 +30,13 @@ public class OpenTelemetryTestEnvironment implements Argument standaloneExporterContainer; private HttpClient httpClient; + /** + * Constructor + * + * @param prometheusDockerImage prometheusDockerImage + * @param javaDockerImage javaDockerImage + * @param jmxExporterMode jmxExporterMode + */ public OpenTelemetryTestEnvironment( String prometheusDockerImage, String javaDockerImage, @@ -315,7 +323,7 @@ private GenericContainer createStandaloneExporterContainer() { } /** - * Method to create an HttpClient + * Method to create a Prometheus HttpClient * * @param genericContainer genericContainer * @param baseUrl baseUrl From ac9a46a378ddd1e0559a5656c081703f301cc4c3 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 09:25:56 -0400 Subject: [PATCH 36/77] Code cleanup Signed-off-by: dhoard --- .../test/opentelemetry/AbstractOpenTelemetryTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index a8053aa3..9bd070c2 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -27,6 +27,14 @@ public abstract class AbstractOpenTelemetryTest { @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; + /** + * Method to build the combinations of test environment + * + * @param prometheusDockerImage prometheusDockerImage + * @param javaDockerImages javaDockerImages + * @param jmsExporterModes jmsExporterModes + * @return a List of OpenTelemetryTestEnvironments + */ protected static Collection buildTestEnvironments( String prometheusDockerImage, List javaDockerImages, @@ -35,7 +43,7 @@ protected static Collection buildTestEnvironments( javaDockerImages.forEach( javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + for (JmxExporterMode jmxExporterMode : jmsExporterModes) { openTelemetryTestEnvironments.add( new OpenTelemetryTestEnvironment( prometheusDockerImage, From 6710f187bcaea855bc61c11cd6884f83b10817ba Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 10:11:10 -0400 Subject: [PATCH 37/77] Changed default interval to 60 seconds Signed-off-by: dhoard --- .../jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java index 0f0ce146..2e6bdbb3 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java @@ -109,7 +109,7 @@ public void initialize(File exporterYamlFile) throws ConfigurationException { "Invalid configuration for" + " /openTelemetry/interval must be" + " between greater than 0"))) - .orElse(1); + .orElse(60); openTelemetryExporter = OpenTelemetryExporter.builder() From ec0ecb9b9c696e3c21e1b98045ee00cab0faf197 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 10:11:26 -0400 Subject: [PATCH 38/77] Formatting Signed-off-by: dhoard --- .../jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index efd812c6..9fc13937 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -38,9 +38,7 @@ public class OpenTelemetryTestEnvironment implements Argument Date: Fri, 28 Jun 2024 10:13:21 -0400 Subject: [PATCH 39/77] Changed default protocol to grpc Signed-off-by: dhoard --- .../common/opentelemetry/OpenTelemetryMetricsExporter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java index 2e6bdbb3..fb37d91e 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java @@ -88,9 +88,7 @@ public void initialize(File exporterYamlFile) throws ConfigurationException { "Invalid configuration for" + " /openTelemetry/protocol" + " must not be blank"))) - .orElseThrow( - ConfigurationException.supplier( - "/openTelemetry/protocol a required string")); + .orElse("grpc"); int interval = openTelemetryYamlMapAccessor From d97a074b19af9ff25c0db160fbf04ef5d08a7b16 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 10:17:14 -0400 Subject: [PATCH 40/77] Changed code to use default OpenTelemetry default endpoint Signed-off-by: dhoard --- .../common/opentelemetry/OpenTelemetryMetricsExporter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java index fb37d91e..ff9a34ad 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java @@ -69,9 +69,7 @@ public void initialize(File exporterYamlFile) throws ConfigurationException { "Invalid configuration for" + " /openTelemetry/endpoint" + " must be a URL"))) - .orElseThrow( - ConfigurationException.supplier( - "/openTelemetry/endpoint a required string")); + .orElse("http://localhost:4317"); String protocol = openTelemetryYamlMapAccessor From 6db01dae62f5fceb549b9d0bf34c89011d590b84 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 28 Jun 2024 10:37:47 -0400 Subject: [PATCH 41/77] Fixed test engine version Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 03e19082..c05a9a9b 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,8 +28,7 @@ 11 UTF-8 UTF-8 - - 7.x.x-SNAPSHOT + 7.0.3 From 5330c276e2349f62a7172d047943d66efb17f079 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 3 Jul 2024 01:15:46 -0400 Subject: [PATCH 42/77] Updated AntuBLUE Test Engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index c05a9a9b..c98849ef 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.0.3 + 7.1.0-BETA-1 From 3717030135879501847f1a1404343a6bd13732c0 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 3 Jul 2024 10:01:48 -0400 Subject: [PATCH 43/77] Code cleanup Signed-off-by: dhoard --- .../jmx/common/http/HTTPServerFactory.java | 15 ++++++ ...java => OpenTelemetryExporterFactory.java} | 47 +++++++++++++------ .../java/io/prometheus/jmx/WebServer.java | 17 +++---- .../java/io/prometheus/jmx/JavaAgent.java | 9 ++-- 4 files changed, 61 insertions(+), 27 deletions(-) rename jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/{OpenTelemetryMetricsExporter.java => OpenTelemetryExporterFactory.java} (85%) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java index cf2b3802..11b2e4d5 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/http/HTTPServerFactory.java @@ -108,6 +108,21 @@ public HTTPServer createHTTPServer( PrometheusRegistry prometheusRegistry, File exporterYamlFile) throws IOException { + if (inetAddress == null) { + throw new IllegalArgumentException("inetAddress is null"); + } + + if (port < 1 || port > 65535) { + throw new IllegalArgumentException("post is out of range [1 - 65535]"); + } + + if (prometheusRegistry == null) { + throw new IllegalArgumentException("prometheusRegistry is null"); + } + + if (exporterYamlFile == null) { + throw new IllegalArgumentException("exporterYamlFile is null"); + } HTTPServer.Builder httpServerBuilder = HTTPServer.builder() diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java similarity index 85% rename from jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java rename to jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java index ff9a34ad..8e602a3a 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryMetricsExporter.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java @@ -18,18 +18,28 @@ import java.util.Map; import org.yaml.snakeyaml.Yaml; -/** Class to implement a OpenTelemetry exporter */ -public class OpenTelemetryMetricsExporter { +/** Class to implement OpenTelemetryExporterFactory */ +public class OpenTelemetryExporterFactory { - private OpenTelemetryExporter openTelemetryExporter; + /** Constructor */ + private OpenTelemetryExporterFactory() { + // DO NOTHING + } /** - * Method to initialize the OpenTelemetry exporter + * Method to create an OpenTelemetryExporter using the supplied arguments * * @param exporterYamlFile exporterYamlFile + * @return OpenTelemetryExporter OpenTelemetryExporter * @throws ConfigurationException ConfigurationException */ - public void initialize(File exporterYamlFile) throws ConfigurationException { + public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationException { + if (exporterYamlFile == null) { + throw new IllegalArgumentException("exporterYamlFile is null"); + } + + OpenTelemetryExporter openTelemetryExporter = null; + try { try (Reader reader = new FileReader(exporterYamlFile)) { Map yamlMap = new Yaml().load(reader); @@ -119,17 +129,24 @@ public void initialize(File exporterYamlFile) throws ConfigurationException { throw new ConfigurationException( format("Exception loading file [%s]", exporterYamlFile), e); } + + return openTelemetryExporter; } - /** Method to close the OpenTelemetryMetricsExporter */ - public void close() { - if (openTelemetryExporter != null) { - try { - openTelemetryExporter.close(); - openTelemetryExporter = null; - } catch (Throwable t) { - // DO NOTHING - } - } + /** + * Method to get an instance of the OpenTelemetryExporterFactory + * + * @return the OpenTelemetryExporterFactory + */ + public static OpenTelemetryExporterFactory getInstance() { + return SingletonHolder.SINGLETON; + } + + /** Class to hold the singleton */ + private static class SingletonHolder { + + /** The singleton */ + public static final OpenTelemetryExporterFactory SINGLETON = + new OpenTelemetryExporterFactory(); } } diff --git a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java index ad52e11a..161253d9 100644 --- a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java +++ b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java @@ -18,8 +18,9 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; -import io.prometheus.jmx.common.opentelemetry.OpenTelemetryMetricsExporter; +import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; import io.prometheus.metrics.exporter.httpserver.HTTPServer; +import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; import java.net.InetAddress; @@ -33,6 +34,9 @@ public class WebServer { new SimpleDateFormat("yyyy-MM-dd | HH:mm:ss.SSS", Locale.getDefault()); public static void main(String[] args) throws Exception { + HTTPServer httpServer = null; + OpenTelemetryExporter openTelemetryExporter = null; + if (args.length < 2) { System.err.println("Usage: WebServer <[hostname:]port> "); System.exit(1); @@ -53,9 +57,6 @@ public static void main(String[] args) throws Exception { new JmxCollector(new File(args[1]), JmxCollector.Mode.STANDALONE) .register(PrometheusRegistry.defaultRegistry); - HTTPServer httpServer = null; - OpenTelemetryMetricsExporter openTelemetryMetricsExporter = null; - try { httpServer = HTTPServerFactory.getInstance() @@ -65,8 +66,8 @@ public static void main(String[] args) throws Exception { PrometheusRegistry.defaultRegistry, new File(args[1])); - openTelemetryMetricsExporter = new OpenTelemetryMetricsExporter(); - openTelemetryMetricsExporter.initialize(new File(args[1])); + openTelemetryExporter = + OpenTelemetryExporterFactory.getInstance().create(new File(args[1])); System.out.println( String.format( @@ -84,8 +85,8 @@ public static void main(String[] args) throws Exception { System.err.println("Exception starting"); t.printStackTrace(); } finally { - if (openTelemetryMetricsExporter != null) { - openTelemetryMetricsExporter.close(); + if (openTelemetryExporter != null) { + openTelemetryExporter.close(); } if (httpServer != null) { httpServer.close(); diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index fbaf5203..71b53fc8 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -18,8 +18,9 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; -import io.prometheus.jmx.common.opentelemetry.OpenTelemetryMetricsExporter; +import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; import io.prometheus.metrics.exporter.httpserver.HTTPServer; +import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; import io.prometheus.metrics.instrumentation.jvm.JvmMetrics; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; @@ -40,7 +41,7 @@ public class JavaAgent { private static final String DEFAULT_HOST = "0.0.0.0"; private static HTTPServer httpServer; - private static OpenTelemetryMetricsExporter openTelemetryMetricsExporter; + private static OpenTelemetryExporter openTelemetryExporter; public static void agentmain(String agentArgument, Instrumentation instrumentation) throws Exception { @@ -67,8 +68,8 @@ public static void premain(String agentArgument, Instrumentation instrumentation PrometheusRegistry.defaultRegistry, new File(config.file)); - openTelemetryMetricsExporter = new OpenTelemetryMetricsExporter(); - openTelemetryMetricsExporter.initialize(new File(config.file)); + openTelemetryExporter = + OpenTelemetryExporterFactory.getInstance().create(new File(config.file)); } catch (Throwable t) { synchronized (System.err) { System.err.println("Failed to start Prometheus JMX Exporter"); From 39a7ec531df9e27980fd0970c804d61b3ce25505 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 3 Jul 2024 17:07:48 -0400 Subject: [PATCH 44/77] Added OpenTelemtry test for Prometheus 2.51.2 Signed-off-by: dhoard --- .../OpenTelemetryTest_v2_51_2.java | 27 +++++++++++++++++++ .../JavaAgent/application.sh | 6 +++++ .../JavaAgent/exporter.yaml | 6 +++++ .../JavaAgent/prometheus.yml | 4 +++ .../Standalone/application.sh | 13 +++++++++ .../Standalone/exporter.sh | 5 ++++ .../Standalone/exporter.yaml | 7 +++++ .../Standalone/prometheus.yml | 4 +++ 8 files changed, 72 insertions(+) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java new file mode 100644 index 00000000..9e0eb166 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java @@ -0,0 +1,27 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.JavaDockerImages; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_50_1 */ +public class OpenTelemetryTest_v2_51_2 extends AbstractOpenTelemetryTest { + + private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.51.2"; + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + return buildTestEnvironments( + PROMETHEUS_DOCKER_IMAGE_NAME, + JavaDockerImages.names().collect(Collectors.toList()), + JmxExporterMode.values()) + .stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml new file mode 100644 index 00000000..46567227 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml @@ -0,0 +1,6 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml new file mode 100644 index 00000000..5f35cee0 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml @@ -0,0 +1,7 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file From 50bb660eed5f9dd7d299be5063b2ef0044fce470 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 4 Jul 2024 01:12:23 -0400 Subject: [PATCH 45/77] Changed JavaDockerImages.name() to return a List Signed-off-by: dhoard --- .../jmx/test/support/JavaDockerImages.java | 18 ++++++++---------- .../io/prometheus/jmx/test/AbstractTest.java | 4 ++-- .../AbstractOpenTelemetryTest.java | 9 +++++---- .../OpenTelemetryTest_v2_47_2.java | 6 +----- .../OpenTelemetryTest_v2_48_1.java | 6 +----- .../OpenTelemetryTest_v2_49_1.java | 6 +----- .../OpenTelemetryTest_v2_50_1.java | 6 +----- .../OpenTelemetryTest_v2_51_2.java | 6 +----- .../OpenTelemetryTest_v2_52_0.java | 6 +----- .../OpenTelemetryTest_v2_53_0.java | 6 +----- 10 files changed, 22 insertions(+), 51 deletions(-) diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java index 458135f6..f3a48bb2 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java @@ -21,12 +21,10 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.Objects; import java.util.function.Predicate; -import java.util.stream.Stream; /** Class to get Docker image names */ public final class JavaDockerImages { @@ -51,21 +49,21 @@ private JavaDockerImages() { } /** - * Method to get Stream of all Docker image names + * Method to get List of all Docker image names * - * @return the Stream of Docker image names + * @return the List of Docker image names */ - public static Stream names() { + public static List names() { return names(ALL_JAVA_VERSIONS); } /** - * Method to get Stream of Docker image names filtered by a Predicate + * Method to get List of Docker image names filtered by a Predicate * * @param predicate predicate - * @return the Stream of Docker image names + * @return the List of Docker image names */ - public static Stream names(Predicate predicate) { + public static List names(Predicate predicate) { Objects.requireNonNull(predicate); synchronized (JavaDockerImages.class) { @@ -109,14 +107,14 @@ public static Stream names(Predicate predicate) { dockerImageNames = dockerImageNameValue.split("\\s+"); } - Collection dockerImageNamesCollection = new ArrayList<>(); + List dockerImageNamesCollection = new ArrayList<>(); for (String dockerImageName : dockerImageNames) { if (predicate.test(dockerImageName)) { dockerImageNamesCollection.add(dockerImageName); } } - return dockerImageNamesCollection.stream(); + return dockerImageNamesCollection; } /** diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java index da34aa27..598674fa 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java @@ -44,7 +44,7 @@ public abstract class AbstractTest { protected TestEnvironment testEnvironment; /** - * Method to get the list of TestArguments + * Method to get the Collection of TestArguments * * @return the return value */ @@ -69,7 +69,7 @@ public static Stream arguments() { @TestEngine.Prepare public final void prepare() { - // Get the Network and get the id to force the network creation + // Create a Network and get the id to force the network creation Network network = Network.newNetwork(); network.getId(); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java index 9bd070c2..5da0a93f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; import org.antublue.test.engine.extras.throttle.Throttle; @@ -33,9 +34,9 @@ public abstract class AbstractOpenTelemetryTest { * @param prometheusDockerImage prometheusDockerImage * @param javaDockerImages javaDockerImages * @param jmsExporterModes jmsExporterModes - * @return a List of OpenTelemetryTestEnvironments + * @return a Stream of OpenTelemetryTestEnvironments */ - protected static Collection buildTestEnvironments( + protected static Stream buildTestEnvironments( String prometheusDockerImage, List javaDockerImages, JmxExporterMode[] jmsExporterModes) { @@ -52,12 +53,12 @@ protected static Collection buildTestEnvironments( } }); - return openTelemetryTestEnvironments; + return openTelemetryTestEnvironments.stream(); } @TestEngine.Prepare public void prepare() { - // Get the Network and get the id to force the network creation + // Create a Network and get the id to force the network creation network = Network.newNetwork(); network.getId(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java index 99cf96b1..6c1135ee 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java index 078a0b71..787c8da3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java index ae01b287..ef114bad 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java index e9d9d39c..ce7ede27 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java index 9e0eb166..bf212335 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_51_2 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java index 83545114..8fa68772 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java index 9b6d6582..acafd66e 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java @@ -2,7 +2,6 @@ import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -19,9 +18,6 @@ public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { @TestEngine.ArgumentSupplier public static Stream arguments() { return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, - JavaDockerImages.names().collect(Collectors.toList()), - JmxExporterMode.values()) - .stream(); + PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); } } From 9800f50d0c9fc0477e61b4c965e331f3720ba63e Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 9 Jul 2024 08:15:30 -0400 Subject: [PATCH 46/77] Updated AntuBLUE test engine. Refactored OpenTelemetry tests to use new test engine parallelized functionality Signed-off-by: dhoard --- .../integration_tests/pom.xml | 2 +- .../test/opentelemetry/OpenTelemetryTest.java | 53 +++++++++++++++++++ .../OpenTelemetryTest_v2_47_2.java | 23 -------- .../OpenTelemetryTest_v2_48_1.java | 23 -------- .../OpenTelemetryTest_v2_49_1.java | 23 -------- .../OpenTelemetryTest_v2_50_1.java | 23 -------- .../OpenTelemetryTest_v2_51_2.java | 23 -------- .../OpenTelemetryTest_v2_52_0.java | 23 -------- .../OpenTelemetryTest_v2_53_0.java | 23 -------- .../JavaAgent/application.sh | 0 .../JavaAgent/exporter.yaml | 0 .../JavaAgent/prometheus.yml | 0 .../Standalone/application.sh | 0 .../Standalone/exporter.sh | 0 .../Standalone/exporter.yaml | 0 .../Standalone/prometheus.yml | 0 .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- .../JavaAgent/application.sh | 6 --- .../JavaAgent/exporter.yaml | 6 --- .../JavaAgent/prometheus.yml | 4 -- .../Standalone/application.sh | 13 ----- .../Standalone/exporter.sh | 5 -- .../Standalone/exporter.yaml | 7 --- .../Standalone/prometheus.yml | 4 -- 58 files changed, 54 insertions(+), 432 deletions(-) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/JavaAgent/application.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/JavaAgent/exporter.yaml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/JavaAgent/prometheus.yml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/Standalone/application.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/Standalone/exporter.sh (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/Standalone/exporter.yaml (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/{OpenTelemetryTest_v2_47_2 => OpenTelemetryTest}/Standalone/prometheus.yml (100%) delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml delete mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index c98849ef..6871978e 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.1.0-BETA-1 + 7.1.0-BETA-2 diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java new file mode 100644 index 00000000..c868274f --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -0,0 +1,53 @@ +package io.prometheus.jmx.test.opentelemetry; + +import io.prometheus.jmx.test.support.JavaDockerImages; +import io.prometheus.jmx.test.support.JmxExporterMode; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +/** Class to implement OpenTelemetryTest_v2_53_0 */ +@TestEngine.Parallelize +public class OpenTelemetryTest extends AbstractOpenTelemetryTest { + + private static final List PROMETHEUS_DOCKER_IMAGES = new ArrayList<>(); + + static { + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.47.2"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.48.1"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.49.1"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.50.1"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.51.2"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.52.0"); + PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.53.0"); + } + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); + + PROMETHEUS_DOCKER_IMAGES.forEach( + prometheusDockerImage -> + JavaDockerImages.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestEnvironments.stream(); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java deleted file mode 100644 index 6c1135ee..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_47_2 */ -public class OpenTelemetryTest_v2_47_2 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.47.2"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java deleted file mode 100644 index 787c8da3..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_48_1 */ -public class OpenTelemetryTest_v2_48_1 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.48.1"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java deleted file mode 100644 index ef114bad..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_49_1 */ -public class OpenTelemetryTest_v2_49_1 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.49.1"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java deleted file mode 100644 index ce7ede27..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_50_1 */ -public class OpenTelemetryTest_v2_50_1 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.50.1"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java deleted file mode 100644 index bf212335..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_50_1 */ -public class OpenTelemetryTest_v2_51_2 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.51.2"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java deleted file mode 100644 index 8fa68772..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_52_0 */ -public class OpenTelemetryTest_v2_52_0 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.52.0"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java deleted file mode 100644 index acafd66e..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import io.prometheus.jmx.test.support.JavaDockerImages; -import io.prometheus.jmx.test.support.JmxExporterMode; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; - -/** Class to implement OpenTelemetryTest_v2_53_0 */ -public class OpenTelemetryTest_v2_53_0 extends AbstractOpenTelemetryTest { - - private static final String PROMETHEUS_DOCKER_IMAGE_NAME = "prom/prometheus:v2.53.0"; - - /** - * Method to get the Stream of test environments - * - * @return the Stream of test environments - */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - return buildTestEnvironments( - PROMETHEUS_DOCKER_IMAGE_NAME, JavaDockerImages.names(), JmxExporterMode.values()); - } -} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/application.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/exporter.yaml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/exporter.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/JavaAgent/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/application.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/application.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.sh rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/exporter.yaml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_47_2/Standalone/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_48_1/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_49_1/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_50_1/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_51_2/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_52_0/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh deleted file mode 100644 index 9e5717d6..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/application.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml deleted file mode 100644 index 46567227..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/JavaAgent/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh deleted file mode 100644 index 80c2b344..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/application.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -Dcom.sun.management.jmxremote=true \ - -Dcom.sun.management.jmxremote.authenticate=false \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.port=9999 \ - -Dcom.sun.management.jmxremote.registry.ssl=false \ - -Dcom.sun.management.jmxremote.rmi.port=9999 \ - -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh deleted file mode 100644 index a04f3b63..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -java \ - -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml deleted file mode 100644 index 5f35cee0..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/exporter.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openTelemetry: - endpoint: http://prometheus:9090/api/v1/otlp - protocol: http/protobuf - interval: 1 -hostPort: application:9999 -rules: - - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml deleted file mode 100644 index 5b174f8e..00000000 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest_v2_53_0/Standalone/prometheus.yml +++ /dev/null @@ -1,4 +0,0 @@ -global: - scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets - -scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file From dedcacd29546fd641845d50b77db78cc5b351963 Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 9 Jul 2024 08:42:26 -0400 Subject: [PATCH 47/77] Changed poms to apply Spotless pluging during compilation Signed-off-by: dhoard --- collector/pom.xml | 22 ++ .../integration_tests/pom.xml | 22 ++ .../AbstractOpenTelemetryTest.java | 212 ------------------ .../test/opentelemetry/OpenTelemetryTest.java | 177 ++++++++++++++- .../jmx_example_application/pom.xml | 22 ++ jmx_prometheus_common/pom.xml | 22 ++ jmx_prometheus_httpserver/pom.xml | 22 ++ jmx_prometheus_javaagent/pom.xml | 22 ++ 8 files changed, 307 insertions(+), 214 deletions(-) delete mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java diff --git a/collector/pom.xml b/collector/pom.xml index f9c8bc6d..35c971d1 100644 --- a/collector/pom.xml +++ b/collector/pom.xml @@ -48,6 +48,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 6871978e..99b60340 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -96,6 +96,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java deleted file mode 100644 index 5da0a93f..00000000 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/AbstractOpenTelemetryTest.java +++ /dev/null @@ -1,212 +0,0 @@ -package io.prometheus.jmx.test.opentelemetry; - -import static org.assertj.core.api.Assertions.assertThat; - -import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpRequest; -import io.prometheus.jmx.test.support.http.HttpResponse; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; -import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; -import org.antublue.test.engine.extras.throttle.Throttle; -import org.junit.jupiter.api.Assertions; -import org.testcontainers.containers.Network; -import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; - -/** Class to implement AbstractOpenTelemetryTest */ -public abstract class AbstractOpenTelemetryTest { - - private Network network; - - @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; - - /** - * Method to build the combinations of test environment - * - * @param prometheusDockerImage prometheusDockerImage - * @param javaDockerImages javaDockerImages - * @param jmsExporterModes jmsExporterModes - * @return a Stream of OpenTelemetryTestEnvironments - */ - protected static Stream buildTestEnvironments( - String prometheusDockerImage, - List javaDockerImages, - JmxExporterMode[] jmsExporterModes) { - Collection openTelemetryTestEnvironments = new ArrayList<>(); - - javaDockerImages.forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : jmsExporterModes) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - }); - - return openTelemetryTestEnvironments.stream(); - } - - @TestEngine.Prepare - public void prepare() { - // Create a Network and get the id to force the network creation - network = Network.newNetwork(); - network.getId(); - } - - @TestEngine.BeforeAll - public void beforeAll() { - openTelemetryTestEnvironment.initialize(getClass(), network); - } - - /** Method to test that Prometheus is up */ - @TestEngine.Test - @TestEngine.Order(order = 0) - public void testIsPrometheusUp() { - Throttle throttle = new ExponentialBackoffThrottle(100, 5000); - AtomicBoolean success = new AtomicBoolean(); - - for (int i = 0; i < 10; i++) { - sendPrometheusQuery("up") - .accept( - httpResponse -> { - assertThat(httpResponse).isNotNull(); - - if (httpResponse.statusCode() != 200) { - return; - } - - assertThat(httpResponse.body()).isNotNull(); - assertThat(httpResponse.body().string()).isNotNull(); - - Map map = - new Yaml().load(httpResponse.body().string()); - - String status = (String) map.get("status"); - assertThat(status).isEqualTo("success"); - - success.set(true); - }); - - if (success.get()) { - break; - } - - throttle.throttle(); - } - - if (!success.get()) { - Assertions.fail("Prometheus is not up"); - } - } - - /** Method to test that metrics exist in Prometheus */ - @TestEngine.Test - public void testPrometheusHasMetrics() { - ExpectedMetricsNames.getMetricsNames().stream() - .filter( - metricName -> { - if (openTelemetryTestEnvironment.getJmxExporterMode() - == JmxExporterMode.Standalone - && metricName.startsWith("jvm_") - || metricName.startsWith("process_")) { - return false; - } - return true; - }) - .forEach( - metricName -> { - Double value = getPrometheusMetric(metricName); - assertThat(value).as("metricName [%s]", metricName).isNotNull(); - assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); - }); - } - - @TestEngine.AfterAll - public void afterAll() { - openTelemetryTestEnvironment.destroy(); - } - - @TestEngine.Conclude - public void conclude() { - if (network != null) { - network.close(); - } - } - - /** - * Method to get a Prometheus metric - * - * @param metricName metricName - * @return the metric value, or null if it doesn't exist - */ - protected Double getPrometheusMetric(String metricName) { - return getPrometheusMetric(metricName, null); - } - - /** - * Method to get a Prometheus metrics - * - * @param metricName metricName - * @param labels labels - * @return the metric value, or null if it doesn't exist - */ - protected Double getPrometheusMetric(String metricName, String[] labels) { - Throttle throttle = new ExponentialBackoffThrottle(100, 6400); - AtomicReference value = new AtomicReference<>(); - - for (int i = 0; i < 10; i++) { - sendPrometheusQuery(metricName) - .accept( - httpResponse -> { - assertThat(httpResponse).isNotNull(); - assertThat(httpResponse.statusCode()).isEqualTo(200); - assertThat(httpResponse.body()).isNotNull(); - assertThat(httpResponse.body().string()).isNotNull(); - - // TODO parse response and return value - if (httpResponse.body().string().contains(metricName)) { - value.set(1.0); - } - }); - - if (value.get() != null) { - break; - } - - throttle.throttle(); - } - - return value.get(); - } - - /** - * Method to send a Prometheus query - * - * @param query query - * @return an HttpResponse - */ - protected HttpResponse sendPrometheusQuery(String query) { - return sendRequest( - "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); - } - - /** - * Method to send a Http GET request - * - * @param path path - * @return an HttpResponse - */ - protected HttpResponse sendRequest(String path) { - return openTelemetryTestEnvironment.getPrometheusHttpClient().send(new HttpRequest(path)); - } -} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index c868274f..5c890e00 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -1,19 +1,34 @@ package io.prometheus.jmx.test.opentelemetry; +import static org.assertj.core.api.Assertions.assertThat; + import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; +import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; +import org.antublue.test.engine.extras.throttle.Throttle; +import org.junit.jupiter.api.Assertions; +import org.testcontainers.containers.Network; +import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; -/** Class to implement OpenTelemetryTest_v2_53_0 */ +/** Class to implement OpenTelemetryTest */ @TestEngine.Parallelize -public class OpenTelemetryTest extends AbstractOpenTelemetryTest { +public class OpenTelemetryTest { private static final List PROMETHEUS_DOCKER_IMAGES = new ArrayList<>(); + // List of Prometheus Docker Images static { PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.47.2"); PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.48.1"); @@ -24,6 +39,10 @@ public class OpenTelemetryTest extends AbstractOpenTelemetryTest { PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.53.0"); } + private Network network; + + @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; + /** * Method to get the Stream of test environments * @@ -50,4 +69,158 @@ public static Stream arguments() { return openTelemetryTestEnvironments.stream(); } + + @TestEngine.Prepare + public void prepare() { + // Create a Network and get the id to force the network creation + network = Network.newNetwork(); + network.getId(); + } + + @TestEngine.BeforeAll + public void beforeAll() { + openTelemetryTestEnvironment.initialize(getClass(), network); + } + + /** Method to test that Prometheus is up */ + @TestEngine.Test + @TestEngine.Order(order = 0) + public void testIsPrometheusUp() { + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); + AtomicBoolean success = new AtomicBoolean(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery("up") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + + if (httpResponse.statusCode() != 200) { + return; + } + + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + Map map = + new Yaml().load(httpResponse.body().string()); + + String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); + + success.set(true); + }); + + if (success.get()) { + break; + } + + throttle.throttle(); + } + + if (!success.get()) { + Assertions.fail("Prometheus is not up"); + } + } + + /** Method to test that metrics exist in Prometheus */ + @TestEngine.Test + public void testPrometheusHasMetrics() { + ExpectedMetricsNames.getMetricsNames().stream() + .filter( + metricName -> { + if (openTelemetryTestEnvironment.getJmxExporterMode() + == JmxExporterMode.Standalone + && metricName.startsWith("jvm_") + || metricName.startsWith("process_")) { + return false; + } + return true; + }) + .forEach( + metricName -> { + Double value = getPrometheusMetric(metricName); + assertThat(value).as("metricName [%s]", metricName).isNotNull(); + assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); + }); + } + + @TestEngine.AfterAll + public void afterAll() { + openTelemetryTestEnvironment.destroy(); + } + + @TestEngine.Conclude + public void conclude() { + if (network != null) { + network.close(); + } + } + + /** + * Method to get a Prometheus metric + * + * @param metricName metricName + * @return the metric value, or null if it doesn't exist + */ + protected Double getPrometheusMetric(String metricName) { + return getPrometheusMetric(metricName, null); + } + + /** + * Method to get a Prometheus metrics + * + * @param metricName metricName + * @param labels labels + * @return the metric value, or null if it doesn't exist + */ + protected Double getPrometheusMetric(String metricName, String[] labels) { + Throttle throttle = new ExponentialBackoffThrottle(100, 6400); + AtomicReference value = new AtomicReference<>(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery(metricName) + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.statusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + // TODO parse response and return value + if (httpResponse.body().string().contains(metricName)) { + value.set(1.0); + } + }); + + if (value.get() != null) { + break; + } + + throttle.throttle(); + } + + return value.get(); + } + + /** + * Method to send a Prometheus query + * + * @param query query + * @return an HttpResponse + */ + protected HttpResponse sendPrometheusQuery(String query) { + return sendRequest( + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); + } + + /** + * Method to send a Http GET request + * + * @param path path + * @return an HttpResponse + */ + protected HttpResponse sendRequest(String path) { + return openTelemetryTestEnvironment.getPrometheusHttpClient().send(new HttpRequest(path)); + } } diff --git a/integration_test_suite/jmx_example_application/pom.xml b/integration_test_suite/jmx_example_application/pom.xml index bbd389bf..06ff5ae0 100644 --- a/integration_test_suite/jmx_example_application/pom.xml +++ b/integration_test_suite/jmx_example_application/pom.xml @@ -164,6 +164,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + diff --git a/jmx_prometheus_common/pom.xml b/jmx_prometheus_common/pom.xml index c7fb366b..7f520deb 100644 --- a/jmx_prometheus_common/pom.xml +++ b/jmx_prometheus_common/pom.xml @@ -61,6 +61,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + diff --git a/jmx_prometheus_httpserver/pom.xml b/jmx_prometheus_httpserver/pom.xml index 9c4b7e30..d91be272 100644 --- a/jmx_prometheus_httpserver/pom.xml +++ b/jmx_prometheus_httpserver/pom.xml @@ -273,6 +273,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + diff --git a/jmx_prometheus_javaagent/pom.xml b/jmx_prometheus_javaagent/pom.xml index d9e0d756..34060ebd 100644 --- a/jmx_prometheus_javaagent/pom.xml +++ b/jmx_prometheus_javaagent/pom.xml @@ -239,6 +239,28 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + 1.22.0 + + true + + + + + + + apply + + compile + + + From f9b5759a225be1b60355d4960235958414ec608a Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 9 Jul 2024 14:51:17 -0400 Subject: [PATCH 48/77] Fixed grammar Signed-off-by: dhoard --- .../io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 5c890e00..eff5617f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -215,7 +215,7 @@ protected HttpResponse sendPrometheusQuery(String query) { } /** - * Method to send a Http GET request + * Method to send an Http GET request * * @param path path * @return an HttpResponse From 2852d59eaedf2090181557892484def839368c95 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 11 Jul 2024 08:44:14 -0400 Subject: [PATCH 49/77] Updated AntuBLUE test engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- .../io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 99b60340..f657a5b5 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.1.0-BETA-2 + 7.1.0-BETA-3 diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index eff5617f..4dba2db5 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -23,7 +23,7 @@ import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; /** Class to implement OpenTelemetryTest */ -@TestEngine.Parallelize +@TestEngine.ParallelArgumentTest public class OpenTelemetryTest { private static final List PROMETHEUS_DOCKER_IMAGES = new ArrayList<>(); From a96b9c7395a778540acfdc975efa16dde43e61a9 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 11 Jul 2024 21:34:01 -0400 Subject: [PATCH 50/77] Refactored/simplified integration tests Signed-off-by: dhoard --- .../integration_tests/pom.xml | 12 +- .../jmx/test/support/JavaDockerImages.java | 19 +- .../jmx/test/support/TestArguments.java | 62 ----- .../jmx/test/support/TestEnvironment.java | 171 ------------ .../support/metrics/LabelsSubsetFilter.java | 42 --- .../support/metrics/MapMetricAssertion.java | 215 ++++++++++++++++ .../jmx/test/support/metrics/Metric.java | 16 +- .../test/support/metrics/MetricAssertion.java | 49 ++-- .../test/support/metrics/MetricsParser.java | 31 ++- .../jmx/test/AutoIncrementingMBeanTest.java | 28 +- .../jmx/test/BlacklistObjectNamesTest.java | 47 +--- .../jmx/test/CompositeKeyDataTest.java | 45 +--- ...leAutoExcludeObjectNameAttributesTest.java | 41 +-- .../test/ExcludeObjectNameAttributesTest.java | 41 +-- .../jmx/test/ExcludeObjectNamesTest.java | 46 +--- .../IncludeAndExcludeObjectNamesTest.java | 46 +--- .../jmx/test/IncludeObjectNamesTest.java | 60 ++--- .../LowerCaseOutputAndLabelNamesTest.java | 49 +--- .../test/LowerCaseOutputLabelNamesTest.java | 54 +--- .../jmx/test/LowerCaseOutputNamesTest.java | 48 +--- .../io/prometheus/jmx/test/MinimalTest.java | 79 ++---- .../jmx/test/OptionalValueMBeanTest.java | 75 ++---- .../WhitelistAndBlacklistObjectNamesTest.java | 46 +--- .../jmx/test/WhitelistObjectNamesTest.java | 61 ++--- .../jmx/test/common/AbstractExporterTest.java | 124 +++++++++ .../common/AuthenticationCredentials.java | 61 +++++ .../ExporterTestEnvironment.java} | 243 +++++++++--------- ...WithHmacExporterTestEnvironmentFilter.java | 33 +++ ...KeyStoreExporterTestEnvironmentFilter.java | 35 +++ .../CompleteHttpServerConfigurationTest.java | 82 +++--- .../AbstractBasicAuthenticationTest.java | 237 ++++++++++------- ...cAuthenticationPBKDF2WithHmacSHA1Test.java | 179 ++----------- ...uthenticationPBKDF2WithHmacSHA256Test.java | 179 ++----------- ...uthenticationPBKDF2WithHmacSHA512Test.java | 179 ++----------- .../BasicAuthenticationPlaintextTest.java | 169 ++---------- .../BasicAuthenticationSHA1Test.java | 169 ++---------- .../BasicAuthenticationSHA256Test.java | 169 ++---------- .../BasicAuthenticationSHA512Test.java | 169 ++---------- .../jmx/test/http/ssl/AbstractSSLTest.java | 23 ++ ...uthenticationPBKDF2WithHmacSHA512Test.java | 195 +++----------- ...thJKSKeyStoreMultipleCertificatesTest.java | 96 +++---- .../test/http/ssl/SSLWithJKSKeyStoreTest.java | 96 +++---- .../http/ssl/SSLWithJKSKeyStoreTest2.java | 96 +++---- ...KCS12KeyStoreMultipleCertificatesTest.java | 124 ++------- .../http/ssl/SSLWithPKCS12KeyStoreTest.java | 124 ++------- .../http/ssl/SSLWithPKCS12KeyStoreTest2.java | 124 ++------- .../threads/ThreadsConfigurationTest.java | 75 ++---- .../opentelemetry/ExpectedMetricsNames.java | 14 +- .../test/opentelemetry/OpenTelemetryTest.java | 54 ++-- .../opentelemetry/PrometheusDockerImages.java | 37 +++ .../jmx/test/rmi/ssl/MinimalRMISSLTest.java | 97 +++---- .../rmi/ssl/RMIRegistrySSLDisabledTest.java | 98 +++---- .../MessageDigestAuthenticatorTest.java | 3 +- .../PBKDF2AuthenticatorTest.java | 7 +- pom.xml | 2 +- 55 files changed, 1560 insertions(+), 3116 deletions(-) delete mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestArguments.java delete mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java delete mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/LabelsSubsetFilter.java create mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MapMetricAssertion.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AuthenticationCredentials.java rename integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/{AbstractTest.java => common/ExporterTestEnvironment.java} (53%) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PBKDF2WithHmacExporterTestEnvironmentFilter.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PKCS12KeyStoreExporterTestEnvironmentFilter.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index f657a5b5..38d301b5 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.1.0-BETA-3 + 7.1.0-BETA-4 @@ -62,11 +62,11 @@ - clean-resources - clean - - clean - + clean-resources + clean + + clean + diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java index f3a48bb2..e0e110f3 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java @@ -21,12 +21,13 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; +import java.util.Collections; import java.util.Locale; import java.util.Objects; import java.util.function.Predicate; -/** Class to get Docker image names */ +/** Class to implement JavaDockerImages */ public final class JavaDockerImages { private static final String JAVA_DOCKER_IMAGES_CONFIGURATION = "java.docker.images"; @@ -49,11 +50,11 @@ private JavaDockerImages() { } /** - * Method to get List of all Docker image names + * Method to get Collection of all Docker image names * - * @return the List of Docker image names + * @return the Collection of Docker image names */ - public static List names() { + public static Collection names() { return names(ALL_JAVA_VERSIONS); } @@ -63,7 +64,7 @@ public static List names() { * @param predicate predicate * @return the List of Docker image names */ - public static List names(Predicate predicate) { + public static Collection names(Predicate predicate) { Objects.requireNonNull(predicate); synchronized (JavaDockerImages.class) { @@ -107,14 +108,14 @@ public static List names(Predicate predicate) { dockerImageNames = dockerImageNameValue.split("\\s+"); } - List dockerImageNamesCollection = new ArrayList<>(); + Collection dockerImageNamesCollection = new ArrayList<>(); for (String dockerImageName : dockerImageNames) { if (predicate.test(dockerImageName)) { dockerImageNamesCollection.add(dockerImageName); } } - return dockerImageNamesCollection; + return Collections.unmodifiableCollection(dockerImageNamesCollection); } /** @@ -124,7 +125,7 @@ public static List names(Predicate predicate) { * @return the String array of lines */ private static String[] load(String resource) { - List dockerImageNames = new ArrayList<>(); + Collection dockerImageNames = new ArrayList<>(); BufferedReader bufferedReader; try { diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestArguments.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestArguments.java deleted file mode 100644 index 8b66367b..00000000 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestArguments.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2023 The Prometheus jmx_exporter Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.prometheus.jmx.test.support; - -import org.antublue.test.engine.api.Argument; - -public class TestArguments implements Argument { - - private final String name; - private final String dockerImageName; - private final JmxExporterMode jmxExporterMode; - - private TestArguments(String name, String dockerImageName, JmxExporterMode jmxExporterMode) { - this.name = name; - this.dockerImageName = dockerImageName; - this.jmxExporterMode = jmxExporterMode; - } - - @Override - public String getName() { - return name; - } - - @Override - public TestArguments getPayload() { - return this; - } - - public String getDockerImageName() { - return dockerImageName; - } - - public JmxExporterMode getJmxExporterMode() { - return jmxExporterMode; - } - - @Override - public String toString() { - return String.format( - "TestArgument{name=[%s],dockerImageName=[%s],mode=[%s]}", - name, dockerImageName, jmxExporterMode); - } - - public static TestArguments of( - String name, String dockerImageName, JmxExporterMode jmxExporterMode) { - return new TestArguments(name, dockerImageName, jmxExporterMode); - } -} diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java deleted file mode 100644 index 2d6e13ff..00000000 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/TestEnvironment.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2023 The Prometheus jmx_exporter Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.prometheus.jmx.test.support; - -import io.prometheus.jmx.test.support.http.HttpClient; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; - -/** Class to TestEnvironment */ -public class TestEnvironment { - - private Network network; - private GenericContainer applicationContainer; - private GenericContainer exporterContainer; - private String baseUrl; - private HttpClient httpClient; - - /** Constructor */ - public TestEnvironment() { - // DO NOTHING - } - - /** - * Method to set the Network - * - * @param network network - * @return this - */ - public TestEnvironment setNetwork(Network network) { - this.network = network; - return this; - } - - /** - * Method to get the Network - * - * @return the Network - */ - public Network getNetwork() { - return network; - } - - /** - * Method to set the application container - * - * @param applicationContainer application container - * @return this - */ - public TestEnvironment setApplicationContainer(GenericContainer applicationContainer) { - this.applicationContainer = applicationContainer; - return this; - } - - /** - * Method to get the application container - * - * @return the application container - */ - public GenericContainer getApplicationContainer() { - return applicationContainer; - } - - /** - * Method to set the exporter container - * - * @param exporterContainer exporter container - * @return this - */ - public TestEnvironment setExporterContainer(GenericContainer exporterContainer) { - this.exporterContainer = exporterContainer; - return this; - } - - /** - * Method to get the exporter container - * - * @return the exporter container - */ - public GenericContainer getExporterContainer() { - return exporterContainer; - } - - /** - * Method to set the base URL - * - * @param baseUrl baseURL - * @return this - */ - public TestEnvironment setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - return this; - } - - /** - * Method to get the base URL - * - * @return the base URL - */ - public String getBaseUrl() { - return baseUrl; - } - - /** - * Method to set the HttpClient - * - * @param httpClient httpClient - * @return this - */ - public TestEnvironment setHttpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /** - * Method to get the HttpClient - * - * @return the HttpClient - */ - public HttpClient getHttpClient() { - return httpClient; - } - - /** Method to reset the test state (containers) */ - public void reset() { - if (exporterContainer != null) { - exporterContainer.close(); - } - - if (applicationContainer != null) { - applicationContainer.close(); - } - - setApplicationContainer(null); - setExporterContainer(null); - setHttpClient(null); - } - - /** Method to dispose the test state (containers and network) */ - public void destroy() { - if (exporterContainer != null) { - exporterContainer.close(); - exporterContainer = null; - } - - if (applicationContainer != null) { - applicationContainer.close(); - applicationContainer = null; - } - - if (network != null) { - network.close(); - network = null; - } - - httpClient = null; - } -} diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/LabelsSubsetFilter.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/LabelsSubsetFilter.java deleted file mode 100644 index 85e17234..00000000 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/LabelsSubsetFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2023 The Prometheus jmx_exporter Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.prometheus.jmx.test.support.metrics; - -import java.util.Map; -import java.util.TreeMap; -import java.util.function.Predicate; - -/** Class to filter to test if a Metric contains a subset of labels */ -public class LabelsSubsetFilter implements Predicate { - - private final TreeMap labels; - - /** - * Constructor - * - * @param labels labels - */ - public LabelsSubsetFilter(TreeMap labels) { - this.labels = labels; - } - - @Override - public boolean test(Metric metric) { - Map labels = metric.labels(); - return labels.entrySet().containsAll(this.labels.entrySet()); - } -} diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MapMetricAssertion.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MapMetricAssertion.java new file mode 100644 index 00000000..58c3d6a7 --- /dev/null +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MapMetricAssertion.java @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2023 The Prometheus jmx_exporter Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.prometheus.jmx.test.support.metrics; + +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; +import java.util.stream.Collectors; +import org.opentest4j.AssertionFailedError; + +/** Class to assert a MapMetricAssertion */ +public class MapMetricAssertion { + + private final Map> metrics; + private Metric.Type type; + private String name; + private String help; + private TreeMap labels; + private Double value; + + /** + * Constructor + * + * @param metrics metrics + */ + MapMetricAssertion(Map> metrics) { + if (metrics == null) { + throw new IllegalArgumentException("metrics is null"); + } + this.metrics = metrics; + } + + /** + * Method to set the type to match against + * + * @param type type + * @return this MetricAssertion + */ + public MapMetricAssertion ofType(Metric.Type type) { + if (type == null) { + throw new IllegalArgumentException("Type is null"); + } + this.type = type; + return this; + } + + /** + * Method to set the name to match against + * + * @param name name + * @return this MetricAssertion + */ + public MapMetricAssertion withName(String name) { + this.name = name; + return this; + } + + /** + * Method to set the help to match against + * + * @param help help + * @return this MetricAssertion + */ + public MapMetricAssertion help(String help) { + this.help = help; + return this; + } + + /** + * Method to add a label to match against + * + * @param name name + * @param value value + * @return this MetricAssertion + */ + public MapMetricAssertion withLabel(String name, String value) { + if (name == null || value == null) { + throw new IllegalArgumentException( + String.format("Label name [%s] or value [%s] is null", name, value)); + } + if (labels == null) { + labels = new TreeMap<>(); + } + labels.put(name, value); + return this; + } + + /** + * Method to set the value to match against + * + * @param value value + * @return this MetricAssertion + */ + public MapMetricAssertion withValue(Double value) { + this.value = value; + return this; + } + + /** + * Method to assert the Metric is present + * + * @return this MetricAssertion + */ + public MapMetricAssertion isPresent() { + return isPresentWhen(true); + } + + /** + * Method to assert the Metric is present + * + * @param condition condition + * @return this MetricAssertion + */ + public MapMetricAssertion isPresentWhen(boolean condition) { + Collection metrics = this.metrics.get(name); + + if (condition && metrics == null) { + throw new AssertionFailedError( + String.format( + "Metric type [%s] help [%s] name [%s] labels [%s] value [%f]" + + " matches multiple metrics", + type, help, name, labels, value)); + } else if (!condition && metrics != null) { + throw new AssertionFailedError( + String.format( + "Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is" + + " present", + type, help, name, labels, value)); + } else if (!condition) { + return this; + } + + Collection subMetrics = + metrics.stream() + .filter(metric -> type == null || metric.type().equals(type)) + .filter(metric -> help == null || metric.help().equals(help)) + .filter( + metric -> + labels == null + || metric.labels() + .entrySet() + .containsAll(labels.entrySet())) + .filter(metric -> value == null || metric.value() == value) + .collect(Collectors.toList()); + + if (condition) { + if (subMetrics.size() > 1) { + throw new AssertionFailedError( + String.format( + "Metric type [%s] help [%s] name [%s] labels [%s] value [%f]" + + " matches multiple metrics", + type, help, name, labels, value)); + } else if (subMetrics.isEmpty()) { + throw new AssertionFailedError( + String.format( + "Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is not" + + " present", + type, help, name, labels, value)); + } + } else { + if (!subMetrics.isEmpty()) { + throw new AssertionFailedError( + String.format( + "Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is" + + " present", + type, help, name, labels, value)); + } + } + + return this; + } + + /** + * Method to assert the Metric is not present + * + * @return this MetricAssertion + */ + public MapMetricAssertion isNotPresent() { + return isPresentWhen(false); + } + + /** + * Method to assert the Metric is not present + * + * @param condition condition + * @return this MetricAssertion + */ + public MapMetricAssertion isNotPresentWhen(boolean condition) { + return isPresentWhen(!condition); + } + + /** + * Method to create a MetricAssertion + * + * @param metrics the collection of metrics + * @return a MetricAssertion + */ + public static MapMetricAssertion assertMetric(Map> metrics) { + return new MapMetricAssertion(metrics); + } +} diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/Metric.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/Metric.java index 825acddf..aaf2b967 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/Metric.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/Metric.java @@ -23,12 +23,22 @@ /** Class to implement a Metric */ public class Metric { - private final String type; + private final Type type; private final String name; private final String help; private final TreeMap labels; private final double value; + /** Metric types */ + public enum Type { + /** Gauge */ + GAUGE, + /** Counter */ + COUNTER, + /** Untyped */ + UNTYPED + } + /** * Constructor * @@ -39,7 +49,7 @@ public class Metric { * @param value value */ public Metric( - String type, String help, String name, TreeMap labels, double value) { + Type type, String help, String name, TreeMap labels, double value) { this.type = type; this.help = help; this.name = name; @@ -52,7 +62,7 @@ public Metric( * * @return the Metric type */ - public String type() { + public Type type() { return type; } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricAssertion.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricAssertion.java index 674bed03..42835cb7 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricAssertion.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricAssertion.java @@ -17,26 +17,17 @@ package io.prometheus.jmx.test.support.metrics; import java.util.Collection; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.Map; import java.util.TreeMap; import java.util.stream.Collectors; import org.opentest4j.AssertionFailedError; -/** Class to assert a DoubleValueMetric */ +/** Class to assert a MetricAssertion */ public class MetricAssertion { - private static final Set VALID_TYPES = new HashSet<>(); - - static { - VALID_TYPES.add("COUNTER"); - VALID_TYPES.add("GAUGE"); - VALID_TYPES.add("UNTYPED"); - } - private final Collection metrics; - private String type; + private Metric.Type type; private String name; private String help; private TreeMap labels; @@ -49,7 +40,7 @@ public class MetricAssertion { */ private MetricAssertion(Collection metrics) { if (metrics == null) { - throw new IllegalArgumentException("Collection is null"); + throw new IllegalArgumentException("metrics is null"); } this.metrics = metrics; } @@ -60,9 +51,9 @@ private MetricAssertion(Collection metrics) { * @param type type * @return this MetricAssertion */ - public MetricAssertion ofType(String type) { - if (type == null || !VALID_TYPES.contains(type)) { - throw new IllegalArgumentException(String.format("Type [%s] is null or invalid", type)); + public MetricAssertion ofType(Metric.Type type) { + if (type == null) { + throw new IllegalArgumentException("Type is null"); } this.type = type; return this; @@ -126,7 +117,7 @@ public MetricAssertion withValue(Double value) { * @return this MetricAssertion */ public MetricAssertion isPresent() { - return isPresent(true); + return isPresentWhen(true); } /** @@ -135,7 +126,7 @@ public MetricAssertion isPresent() { * @param condition condition * @return this MetricAssertion */ - public MetricAssertion isPresent(boolean condition) { + public MetricAssertion isPresentWhen(boolean condition) { List metrics = this.metrics.stream() .filter(metric -> type == null || metric.type().equals(type)) @@ -144,7 +135,9 @@ public MetricAssertion isPresent(boolean condition) { .filter( metric -> labels == null - || new LabelsSubsetFilter(labels).test(metric)) + || metric.labels() + .entrySet() + .containsAll(labels.entrySet())) .filter(metric -> value == null || metric.value() == value) .collect(Collectors.toList()); @@ -163,7 +156,7 @@ public MetricAssertion isPresent(boolean condition) { type, help, name, labels, value)); } } else { - if (metrics.size() > 0) { + if (!metrics.isEmpty()) { throw new AssertionFailedError( String.format( "Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is" @@ -181,7 +174,7 @@ public MetricAssertion isPresent(boolean condition) { * @return this MetricAssertion */ public MetricAssertion isNotPresent() { - return isPresent(false); + return isPresentWhen(false); } /** @@ -190,8 +183,8 @@ public MetricAssertion isNotPresent() { * @param condition condition * @return this MetricAssertion */ - public MetricAssertion isNotPresent(boolean condition) { - return isPresent(!condition); + public MetricAssertion isNotPresentWhen(boolean condition) { + return isPresentWhen(!condition); } /** @@ -203,4 +196,14 @@ public MetricAssertion isNotPresent(boolean condition) { public static MetricAssertion assertMetric(Collection metrics) { return new MetricAssertion(metrics); } + + /** + * Method to create a MetricAssertion + * + * @param metrics the collection of metrics + * @return a MetricAssertion + */ + public static MapMetricAssertion assertMetric(Map> metrics) { + return new MapMetricAssertion(metrics); + } } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricsParser.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricsParser.java index 71f4e3bc..b2da1909 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricsParser.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MetricsParser.java @@ -30,8 +30,10 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.TreeMap; +import java.util.stream.Collectors; /** Class to parse Metrics from an HttpResponse */ public class MetricsParser { @@ -41,13 +43,26 @@ private MetricsParser() { // DO NOTHING } + /** + * Method to parse Metrics from an HttpResponse + * + * @param httpResponse httpResponse + * @return a Map of Metrics + */ + public static Map> parseMap(HttpResponse httpResponse) { + return parseCollection(httpResponse).stream() + .collect( + Collectors.groupingBy( + Metric::name, Collectors.toCollection(ArrayList::new))); + } + /** * Method to parse Metrics from an HttpResponse * * @param httpResponse httpResponse * @return a Collection of Metrics */ - public static Collection parse(HttpResponse httpResponse) { + public static Collection parseCollection(HttpResponse httpResponse) { if (Objects.requireNonNull(httpResponse.headers().get(HttpHeader.CONTENT_TYPE)) .contains(HttpContentType.PROTOBUF)) { return parseProtobufMetrics(httpResponse); @@ -79,7 +94,7 @@ private static Collection parseProtobufMetrics(HttpResponse httpResponse collection.add( new Metric( - "COUNTER", + Metric.Type.COUNTER, help, name, toLabels(metric.getLabelList()), @@ -93,7 +108,7 @@ private static Collection parseProtobufMetrics(HttpResponse httpResponse collection.add( new Metric( - "GAUGE", + Metric.Type.GAUGE, help, name, toLabels(metric.getLabelList()), @@ -107,7 +122,7 @@ private static Collection parseProtobufMetrics(HttpResponse httpResponse collection.add( new Metric( - "UNTYPED", + Metric.Type.UNTYPED, help, name, toLabels(metric.getLabelList()), @@ -199,11 +214,11 @@ private static Metric createMetric(String typeLine, String help, String metricLi double value = Double.parseDouble(metricLine.substring(metricLine.lastIndexOf(" "))); if (typeLine.equalsIgnoreCase("COUNTER")) { - return new Metric("COUNTER", help, name, labels, value); + return new Metric(Metric.Type.COUNTER, help, name, labels, value); } else if (typeLine.equalsIgnoreCase("GAUGE")) { - return new Metric("GAUGE", help, name, labels, value); + return new Metric(Metric.Type.GAUGE, help, name, labels, value); } else { - return new Metric("UNTYPED", help, name, labels, value); + return new Metric(Metric.Type.UNTYPED, help, name, labels, value); } } @@ -258,7 +273,7 @@ private static TreeMap toLabels(List labelPai return labels; } - /** Class to read a Reader line by line */ + /** Class to read a Reader line by line with the ability to push a line back to the Reader */ private static class LineReader implements AutoCloseable { private final LinkedList lineBuffer; diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java index 0e64df3b..099540f7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java @@ -19,54 +19,52 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import org.antublue.test.engine.api.TestEngine; import org.testcontainers.shaded.com.google.common.util.concurrent.AtomicDouble; -public class AutoIncrementingMBeanTest extends AbstractTest { +public class AutoIncrementingMBeanTest extends MinimalTest { @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { + @TestEngine.Order(order = Integer.MAX_VALUE) + public void testAutoIncrementingMBean() { + // Collect the auto incrementing MBean values double value1 = collect(); double value2 = collect(); double value3 = collect(); + // Assert that each collection is the previous value + 1 assertThat(value2).isGreaterThan(value1); assertThat(value2).isEqualTo(value1 + 1); - assertThat(value3).isGreaterThan(value2); assertThat(value3).isEqualTo(value2 + 1); } + /** + * Method to collect a value from the auto incrementing MBean + * + * @return the auto incrementing MBean value + */ private double collect() { final AtomicDouble value = new AtomicDouble(); HttpResponse httpResponse = - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()); + new HttpPrometheusMetricsRequest().send(exporterTestEnvironment.getHttpClient()); assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); metrics.stream() .filter(metric -> metric.name().startsWith("io_prometheus_jmx_autoIncrementing")) .map(Metric::value) .limit(1) .findFirst() - .ifPresent(d -> value.set(d)); + .ifPresent(value::set); return value.doubleValue(); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java index 0cf726f9..3bf42943 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java @@ -19,55 +19,22 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class BlacklistObjectNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class BlacklistObjectNamesTest extends AbstractExporterTest + implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that we don't have any metrics that start with ... @@ -75,6 +42,8 @@ public void accept(HttpResponse httpResponse) { * name = java_lang* */ metrics.forEach( - metric -> assertThat(metric.name().toLowerCase()).doesNotStartWith("java_lang")); + metric -> + assertThat(metric.name().toLowerCase(Locale.ENGLISH)) + .doesNotStartWith("java_lang")); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java index 29489e13..f715caad 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java @@ -19,65 +19,30 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class CompositeKeyDataTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class CompositeKeyDataTest extends AbstractExporterTest implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("org_exist_management_exist_ProcessReport_RunningQueries_id") .withLabel("key_id", "1") .withLabel("key_path", "/db/query1.xq") .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("org_exist_management_exist_ProcessReport_RunningQueries_id") .withLabel("key_id", "2") .withLabel("key_path", "/db/query2.xq") diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java index 3fec3610..9118cda9 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java @@ -19,58 +19,23 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.fail; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class DisableAutoExcludeObjectNameAttributesTest extends AbstractTest +public class DisableAutoExcludeObjectNameAttributesTest extends AbstractExporterTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); Set excludeAttributeNameSet = new HashSet<>(); excludeAttributeNameSet.add("_ClassPath"); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java index a1676ca6..0f44f0eb 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java @@ -19,58 +19,23 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.fail; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class ExcludeObjectNameAttributesTest extends AbstractTest +public class ExcludeObjectNameAttributesTest extends AbstractExporterTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); Set excludeAttributeNameSet = new HashSet<>(); excludeAttributeNameSet.add("_ClassPath"); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java index 43e49937..f59c6192 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java @@ -19,55 +19,21 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class ExcludeObjectNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class ExcludeObjectNamesTest extends AbstractExporterTest implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that we don't have any metrics that start with ... @@ -75,6 +41,8 @@ public void accept(HttpResponse httpResponse) { * name = java_lang* */ metrics.forEach( - metric -> assertThat(metric.name().toLowerCase()).doesNotStartWith("java_lang")); + metric -> + assertThat(metric.name().toLowerCase(Locale.ENGLISH)) + .doesNotStartWith("java_lang")); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java index 6954c962..aa1268b3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java @@ -19,56 +19,22 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class IncludeAndExcludeObjectNamesTest extends AbstractTest +public class IncludeAndExcludeObjectNamesTest extends AbstractExporterTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that we don't have any metrics that start with ... @@ -76,6 +42,8 @@ public void accept(HttpResponse httpResponse) { * name = java_lang* */ metrics.forEach( - metric -> assertThat(metric.name().toLowerCase()).doesNotStartWith("java_lang")); + metric -> + assertThat(metric.name().toLowerCase(Locale.ENGLISH)) + .doesNotStartWith("java_lang")); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java index 11d86b7b..eb3442ea 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java @@ -19,55 +19,21 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class IncludeObjectNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class IncludeObjectNamesTest extends AbstractExporterTest implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * We have to filter metrics that start with ... @@ -81,11 +47,19 @@ public void accept(HttpResponse httpResponse) { * ... because they are registered directly and are not MBeans */ metrics.stream() - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_exporter")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_config")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_scrape")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jvm_")) - .filter(metric -> !metric.name().toLowerCase().startsWith("process_")) + .filter( + metric -> + !metric.name() + .toLowerCase(Locale.ENGLISH) + .startsWith("jmx_exporter")) + .filter( + metric -> + !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jmx_config")) + .filter( + metric -> + !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jmx_scrape")) + .filter(metric -> !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jvm_")) + .filter(metric -> !metric.name().toLowerCase(Locale.ENGLISH).startsWith("process_")) .forEach( metric -> { String name = metric.name(); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java index 792bb34b..d0e01030 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java @@ -19,65 +19,34 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class LowerCaseOutputAndLabelNamesTest extends AbstractTest +public class LowerCaseOutputAndLabelNamesTest extends AbstractExporterTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that all metrics have lower case names and lower case label names */ metrics.forEach( metric -> { - assertThat(metric.name()).isEqualTo(metric.name().toLowerCase()); + assertThat(metric.name()).isEqualTo(metric.name().toLowerCase(Locale.ENGLISH)); metric.labels() - .forEach((key, value) -> assertThat(key).isEqualTo(key.toLowerCase())); + .forEach( + (key, value) -> + assertThat(key) + .isEqualTo(key.toLowerCase(Locale.ENGLISH))); }); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java index 71e02956..e42d5d5a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java @@ -19,63 +19,33 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class LowerCaseOutputLabelNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class LowerCaseOutputLabelNamesTest extends AbstractExporterTest + implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that all metrics have lower case label names */ metrics.forEach( - metric -> { - metric.labels() - .forEach((key, value) -> assertThat(key).isEqualTo(key.toLowerCase())); - }); + metric -> + metric.labels() + .forEach( + (key, value) -> + assertThat(key) + .isEqualTo( + key.toLowerCase(Locale.ENGLISH)))); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java index 02ec86a5..a0c4e5fb 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java @@ -19,59 +19,29 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class LowerCaseOutputNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class LowerCaseOutputNamesTest extends AbstractExporterTest + implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that all metrics have lower case names */ - metrics.forEach(metric -> assertThat(metric.name()).isEqualTo(metric.name().toLowerCase())); + metrics.forEach( + metric -> + assertThat(metric.name()) + .isEqualTo(metric.name().toLowerCase(Locale.ENGLISH))); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java index c72a7391..6abdb65b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java @@ -19,135 +19,104 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class MinimalTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class MinimalTest extends AbstractExporterTest implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName( "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_ActiveSessions") .withValue(2.0d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName( "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_Bootstraps") .withValue(4.0d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName( "io_prometheus_jmx_test_PerformanceMetricsMBean_PerformanceMetrics_BootstrapsDeferred") .withValue(6.0d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java index 7bbc53a5..8284d54c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java @@ -19,121 +19,90 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class OptionalValueMBeanTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class OptionalValueMBeanTest extends AbstractExporterTest implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("io_prometheus_jmx_optionalValue_Value") .withValue(345d); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java index ff0fca3a..e55970ae 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java @@ -19,56 +19,22 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class WhitelistAndBlacklistObjectNamesTest extends AbstractTest +public class WhitelistAndBlacklistObjectNamesTest extends AbstractExporterTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * Assert that we don't have any metrics that start with ... @@ -76,6 +42,8 @@ public void accept(HttpResponse httpResponse) { * name = java_lang* */ metrics.forEach( - metric -> assertThat(metric.name().toLowerCase()).doesNotStartWith("java_lang")); + metric -> + assertThat(metric.name().toLowerCase(Locale.ENGLISH)) + .doesNotStartWith("java_lang")); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java index f4a9dcae..9334c608 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java @@ -19,55 +19,22 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Locale; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class WhitelistObjectNamesTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class WhitelistObjectNamesTest extends AbstractExporterTest + implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Collection metrics = MetricsParser.parseCollection(httpResponse); /* * We have to filter metrics that start with ... @@ -81,11 +48,19 @@ public void accept(HttpResponse httpResponse) { * ... because they are registered directly and are not MBeans */ metrics.stream() - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_exporter")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_config")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jmx_scrape")) - .filter(metric -> !metric.name().toLowerCase().startsWith("jvm_")) - .filter(metric -> !metric.name().toLowerCase().startsWith("process_")) + .filter( + metric -> + !metric.name() + .toLowerCase(Locale.ENGLISH) + .startsWith("jmx_exporter")) + .filter( + metric -> + !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jmx_config")) + .filter( + metric -> + !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jmx_scrape")) + .filter(metric -> !metric.name().toLowerCase(Locale.ENGLISH).startsWith("jvm_")) + .filter(metric -> !metric.name().toLowerCase(Locale.ENGLISH).startsWith("process_")) .forEach( metric -> { String name = metric.name(); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java new file mode 100644 index 00000000..05ee76f1 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2023 The Prometheus jmx_exporter Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.prometheus.jmx.test.common; + +import io.prometheus.jmx.test.support.JavaDockerImages; +import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpHealthyRequest; +import io.prometheus.jmx.test.support.http.HttpMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; +import io.prometheus.jmx.test.support.http.HttpResponseAssertions; +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Consumer; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; +import org.testcontainers.containers.Network; + +public abstract class AbstractExporterTest implements Consumer { + + protected Network network; + + @TestEngine.Argument public ExporterTestEnvironment exporterTestEnvironment; + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + Collection collection = new ArrayList<>(); + + JavaDockerImages.names() + .forEach( + dockerImageName -> { + for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { + collection.add( + new ExporterTestEnvironment( + dockerImageName, jmxExporterMode)); + } + }); + + return collection.stream(); + } + + @TestEngine.Prepare + public final void prepare() { + // Create a Network and get the id to force the network creation + network = Network.newNetwork(); + network.getId(); + } + + @TestEngine.BeforeAll + public void beforeAll() { + exporterTestEnvironment.initialize(getClass(), network); + } + + @TestEngine.Test + public void testHealthy() { + new HttpHealthyRequest() + .send(exporterTestEnvironment.getHttpClient()) + .accept(HttpResponseAssertions::assertHttpHealthyResponse); + } + + @TestEngine.Test + public void testMetrics() { + new HttpMetricsRequest().send(exporterTestEnvironment.getHttpClient()).accept(this); + } + + @TestEngine.Test + public void testMetricsOpenMetricsFormat() { + new HttpOpenMetricsRequest().send(exporterTestEnvironment.getHttpClient()).accept(this); + } + + @TestEngine.Test + public void testMetricsPrometheusFormat() { + new HttpPrometheusMetricsRequest() + .send(exporterTestEnvironment.getHttpClient()) + .accept(this); + } + + @TestEngine.Test + public void testMetricsPrometheusProtobufFormat() { + new HttpPrometheusProtobufMetricsRequest() + .send(exporterTestEnvironment.getHttpClient()) + .accept(this); + } + + @TestEngine.AfterAll + public void afterAll() { + if (exporterTestEnvironment != null) { + exporterTestEnvironment.destroy(); + exporterTestEnvironment = null; + } + } + + @TestEngine.Conclude + public final void conclude() { + if (network != null) { + network.close(); + network = null; + } + } + + @Override + public abstract void accept(HttpResponse httpResponse); +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AuthenticationCredentials.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AuthenticationCredentials.java new file mode 100644 index 00000000..07311764 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AuthenticationCredentials.java @@ -0,0 +1,61 @@ +package io.prometheus.jmx.test.common; + +/** Class to implement AuthenticationTestCredentials */ +public class AuthenticationCredentials { + + private String username; + private String password; + private boolean isValid; + + /** + * Constructor + * + * @param username + * @param password + * @param isValid + */ + private AuthenticationCredentials(String username, String password, boolean isValid) { + this.username = username; + this.password = password; + this.isValid = isValid; + } + + /** + * Method to get the username + * + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * Method to get the password + * + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * Method to return if the credentials are valid + * + * @return true if the credentials are valid, else false + */ + public boolean isValid() { + return isValid; + } + + /** + * Method to create an AuthenticationTestCredentials + * + * @param username username + * @param password password + * @param isValid isValid + * @return an AuthenticationTestCredentials + */ + public static AuthenticationCredentials of(String username, String password, boolean isValid) { + return new AuthenticationCredentials(username, password, isValid); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java similarity index 53% rename from integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java rename to integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java index 598674fa..f747a907 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AbstractTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java @@ -1,152 +1,159 @@ -/* - * Copyright (C) 2023 The Prometheus jmx_exporter Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.prometheus.jmx.test; +package io.prometheus.jmx.test.common; import com.github.dockerjava.api.model.Ulimit; -import io.prometheus.jmx.test.support.JavaDockerImages; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.TestEnvironment; import io.prometheus.jmx.test.support.http.HttpClient; import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.test.engine.api.Argument; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy; import org.testcontainers.containers.wait.strategy.Wait; -public abstract class AbstractTest { +/** Class to implement OpenTelemetryTestEnvironment */ +public class ExporterTestEnvironment implements Argument { - private static final String BASE_URL = "http://localhost"; - private static final long MEMORY_BYTES = 1073741824; // 1GB + private static final long MEMORY_BYTES = 1073741824; // 1 GB private static final long MEMORY_SWAP_BYTES = 2 * MEMORY_BYTES; + private static final String BASE_URL = "http://localhost"; - @TestEngine.Argument public TestArguments testArguments; + private final String javaDockerImage; + private final JmxExporterMode jmxExporterMode; - protected TestEnvironment testEnvironment; + private Class testClass; + private String baseUrl; + private Network network; + private GenericContainer standaloneApplicationContainer; + private GenericContainer javaAgentApplicationContainer; + private GenericContainer standaloneExporterContainer; + private HttpClient httpClient; /** - * Method to get the Collection of TestArguments + * Constructor * - * @return the return value + * @param javaDockerImage javaDockerImage + * @param jmxExporterMode jmxExporterMode */ - @TestEngine.ArgumentSupplier - public static Stream arguments() { - List testArguments = new ArrayList<>(); + public ExporterTestEnvironment(String javaDockerImage, JmxExporterMode jmxExporterMode) { + this.javaDockerImage = javaDockerImage; + this.jmxExporterMode = jmxExporterMode; + this.baseUrl = BASE_URL; + } - JavaDockerImages.names() - .forEach( - dockerImageName -> { - for (JmxExporterMode jmxExporterMode : JmxExporterMode.values()) { - testArguments.add( - TestArguments.of( - dockerImageName + " / " + jmxExporterMode, - dockerImageName, - jmxExporterMode)); - } - }); + @Override + public String getName() { + return javaDockerImage + " / " + jmxExporterMode; + } - return testArguments.stream(); + @Override + public ExporterTestEnvironment getPayload() { + return this; } - @TestEngine.Prepare - public final void prepare() { - // Create a Network and get the id to force the network creation - Network network = Network.newNetwork(); - network.getId(); + /** + * Method to set the base URL + * + * @param baseUrl baseUrl + * @return the ExporterTestEnvironment + */ + public ExporterTestEnvironment setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } - testEnvironment = new TestEnvironment(); - testEnvironment.setNetwork(network); - testEnvironment.setBaseUrl(BASE_URL); + /** + * Method to get the Java Docker image name + * + * @return the Java Docker image name + */ + public String getJavaDockerImage() { + return javaDockerImage; } - @TestEngine.BeforeAll - public final void beforeAll() { - testEnvironment.reset(); + /** + * Method to get the JMX Exporter mode + * + * @return the JMX Exporter mode + */ + public JmxExporterMode getJmxExporterMode() { + return jmxExporterMode; + } - Network network = testEnvironment.getNetwork(); - String dockerImageName = testArguments.getDockerImageName(); - String testName = this.getClass().getName(); - String baseUrl = testEnvironment.getBaseUrl(); + /** + * Method to initialize the test environment + * + * @param network network + */ + public void initialize(Class testClass, Network network) { + this.testClass = testClass; + this.network = network; - switch (testArguments.getJmxExporterMode()) { + switch (jmxExporterMode) { case JavaAgent: { - GenericContainer applicationContainer = - createJavaAgentApplicationContainer(network, dockerImageName, testName); - applicationContainer.start(); - testEnvironment.setApplicationContainer(applicationContainer); + javaAgentApplicationContainer = createJavaAgentApplicationContainer(); + javaAgentApplicationContainer.start(); - HttpClient httpClient = createHttpClient(applicationContainer, baseUrl); - testEnvironment.setHttpClient(httpClient); + httpClient = createHttpClient(javaAgentApplicationContainer, baseUrl, 8888); break; } case Standalone: { - GenericContainer applicationContainer = - createStandaloneApplicationContainer( - network, dockerImageName, testName); - applicationContainer.start(); - testEnvironment.setApplicationContainer(applicationContainer); + standaloneApplicationContainer = createStandaloneApplicationContainer(); + standaloneExporterContainer = createStandaloneExporterContainer(); - GenericContainer exporterContainer = - createStandaloneExporterContainer(network, dockerImageName, testName); - exporterContainer.start(); - testEnvironment.setExporterContainer(exporterContainer); + standaloneApplicationContainer.start(); + standaloneExporterContainer.start(); - HttpClient httpClient = createHttpClient(exporterContainer, baseUrl); - testEnvironment.setHttpClient(httpClient); + httpClient = createHttpClient(standaloneExporterContainer, baseUrl, 8888); break; } } } - @TestEngine.AfterAll - public final void afterAll() { - testEnvironment.reset(); + /** + * Method to get an HttpClient for the test environment + * + * @return an HttpClient + */ + public HttpClient getHttpClient() { + return httpClient; } - @TestEngine.Conclude - public final void conclude() { - testEnvironment.destroy(); - testEnvironment = null; + /** Method to destroy the test environment */ + public void destroy() { + if (javaAgentApplicationContainer != null) { + javaAgentApplicationContainer.close(); + javaAgentApplicationContainer = null; + } + + if (standaloneExporterContainer != null) { + standaloneExporterContainer.close(); + standaloneExporterContainer = null; + } + + if (standaloneApplicationContainer != null) { + standaloneApplicationContainer.close(); + standaloneApplicationContainer = null; + } } /** * Method to create an application container * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName * @return the return value */ - private static GenericContainer createStandaloneApplicationContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) + private GenericContainer createJavaAgentApplicationContainer() { + return new GenericContainer<>(javaDockerImage) .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( - testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) + testClass.getName().replace(".", "/") + "/JavaAgent", + "/temp", + BindMode.READ_ONLY) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -160,7 +167,7 @@ private static GenericContainer createStandaloneApplicationContainer( new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh application.sh") - .withExposedPorts(9999) + .withExposedPorts(8888) .withLogConsumer( outputFrame -> { String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); @@ -176,20 +183,18 @@ private static GenericContainer createStandaloneApplicationContainer( } /** - * Method to create an exporter container + * Method to create an application container * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName * @return the return value */ - private static GenericContainer createStandaloneExporterContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forListeningPort()) + private GenericContainer createStandaloneApplicationContainer() { + return new GenericContainer<>(javaDockerImage) + .waitingFor(Wait.forLogMessage(".*Running.*", 1)) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( - testName.replace(".", "/") + "/Standalone", "/temp", BindMode.READ_ONLY) + testClass.getName().replace(".", "/") + "/Standalone", + "/temp", + BindMode.READ_ONLY) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -202,8 +207,8 @@ private static GenericContainer createStandaloneExporterContainer( new Ulimit[] { new Ulimit("nofile", 65536L, 65536L) })) - .withCommand("/bin/sh exporter.sh") - .withExposedPorts(8888) + .withCommand("/bin/sh application.sh") + .withExposedPorts(9999) .withLogConsumer( outputFrame -> { String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); @@ -212,27 +217,25 @@ private static GenericContainer createStandaloneExporterContainer( } }) .withNetwork(network) - .withNetworkAliases("exporter") + .withNetworkAliases("application") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) .withWorkingDirectory("/temp"); } /** - * Method to create an application container + * Method to create an exporter container * - * @param network network - * @param dockerImageName dockerImageName - * @param testName testName * @return the return value */ - private static GenericContainer createJavaAgentApplicationContainer( - Network network, String dockerImageName, String testName) { - return new GenericContainer<>(dockerImageName) - .waitingFor(Wait.forLogMessage(".*Running.*", 1)) + private GenericContainer createStandaloneExporterContainer() { + return new GenericContainer<>(javaDockerImage) + .waitingFor(Wait.forListeningPort()) .withClasspathResourceMapping("common", "/temp", BindMode.READ_ONLY) .withClasspathResourceMapping( - testName.replace(".", "/") + "/JavaAgent", "/temp", BindMode.READ_ONLY) + testClass.getName().replace(".", "/") + "/Standalone", + "/temp", + BindMode.READ_ONLY) .withCreateContainerCmdModifier( c -> c.getHostConfig() @@ -245,7 +248,7 @@ private static GenericContainer createJavaAgentApplicationContainer( new Ulimit[] { new Ulimit("nofile", 65536L, 65536L) })) - .withCommand("/bin/sh application.sh") + .withCommand("/bin/sh exporter.sh") .withExposedPorts(8888) .withLogConsumer( outputFrame -> { @@ -255,21 +258,21 @@ private static GenericContainer createJavaAgentApplicationContainer( } }) .withNetwork(network) - .withNetworkAliases("application") + .withNetworkAliases("exporter") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) .withWorkingDirectory("/temp"); } /** - * Method to create an HttpClient + * Method to create a Prometheus HttpClient * * @param genericContainer genericContainer * @param baseUrl baseUrl * @return the return value */ private static HttpClient createHttpClient( - GenericContainer genericContainer, String baseUrl) { - return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(8888)); + GenericContainer genericContainer, String baseUrl, int mappedPort) { + return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PBKDF2WithHmacExporterTestEnvironmentFilter.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PBKDF2WithHmacExporterTestEnvironmentFilter.java new file mode 100644 index 00000000..9d21a172 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PBKDF2WithHmacExporterTestEnvironmentFilter.java @@ -0,0 +1,33 @@ +package io.prometheus.jmx.test.common; + +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + +/** Class to implement PBKDF2WithHmacTestArgumentFilter */ +public class PBKDF2WithHmacExporterTestEnvironmentFilter + implements Predicate { + + private final Set filteredDockerImages; + + /** Constructor */ + public PBKDF2WithHmacExporterTestEnvironmentFilter() { + // Filter out Docker image names that don't support PBKDF2 with HMAC + filteredDockerImages = new HashSet<>(); + filteredDockerImages.add("ibmjava:8"); + filteredDockerImages.add("ibmjava:8-jre"); + filteredDockerImages.add("ibmjava:8-sdk"); + filteredDockerImages.add("ibmjava:8-sfj"); + } + + /** + * Evaluates this predicate on the given argument. + * + * @param ExporterTestEnvironment the input argument + * @return {@code true} if the input argument matches the predicate, otherwise {@code false} + */ + @Override + public boolean test(ExporterTestEnvironment ExporterTestEnvironment) { + return !filteredDockerImages.contains(ExporterTestEnvironment.getJavaDockerImage()); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PKCS12KeyStoreExporterTestEnvironmentFilter.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PKCS12KeyStoreExporterTestEnvironmentFilter.java new file mode 100644 index 00000000..a3d3ec74 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/PKCS12KeyStoreExporterTestEnvironmentFilter.java @@ -0,0 +1,35 @@ +package io.prometheus.jmx.test.common; + +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + +/** Class to implement PKCS12KeyStoreExporterContextFilter */ +public class PKCS12KeyStoreExporterTestEnvironmentFilter + implements Predicate { + + private final Set filteredDockerImages; + + /** Constructor */ + public PKCS12KeyStoreExporterTestEnvironmentFilter() { + filteredDockerImages = new HashSet<>(); + filteredDockerImages.add("eclipse-temurin:8-alpine"); + filteredDockerImages.add("ghcr.io/graalvm/jdk:java8"); + filteredDockerImages.add("ibmjava:8"); + filteredDockerImages.add("ibmjava:8-jre"); + filteredDockerImages.add("ibmjava:8-sdk"); + filteredDockerImages.add("ibmjava:8-sfj"); + filteredDockerImages.add("ibmjava:11"); + } + + /** + * Evaluates this predicate on the given argument. + * + * @param ExporterTestEnvironment the input argument + * @return {@code true} if the input argument matches the predicate, otherwise {@code false} + */ + @Override + public boolean test(ExporterTestEnvironment ExporterTestEnvironment) { + return !filteredDockerImages.contains(ExporterTestEnvironment.getJavaDockerImage()); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index 240d1fdc..d8bf0df7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -20,9 +20,9 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; import io.prometheus.jmx.test.support.http.HttpHealthyRequest; import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; @@ -32,15 +32,17 @@ import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class CompleteHttpServerConfigurationTest extends AbstractTest +public class CompleteHttpServerConfigurationTest extends AbstractExporterTest implements Consumer { - private final String BASE_URL = "https://localhost"; + private static final String BASE_URL = "https://localhost"; private final String VALID_USERNAME = "Prometheus"; @@ -53,26 +55,29 @@ public class CompleteHttpServerConfigurationTest extends AbstractTest new String[] {VALID_PASSWORD, "Secret", "bad", "", null}; /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 // https://bugs.openjdk.org/browse/JDK-8306037 - return AbstractTest.arguments() + return AbstractExporterTest.arguments() .filter( - testArgument -> - !testArgument - .getDockerImageName() - .contains("eclipse-temurin:8-alpine")); - } - - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() + .contains("eclipse-temurin:8-alpine")) + .map( + new Function() { + @Override + public ExporterTestEnvironment apply( + ExporterTestEnvironment ExporterTestEnvironment) { + return ExporterTestEnvironment.setBaseUrl(BASE_URL); + } + }); } @TestEngine.Test @@ -87,7 +92,7 @@ public void testHealthy() { new HttpHealthyRequest() .credentials(new HttpBasicAuthenticationCredentials(username, password)) - .send(testEnvironment.getHttpClient()) + .send(exporterTestEnvironment.getHttpClient()) .accept(response -> assertHttpResponseCode(response, code.get())); } } @@ -105,7 +110,7 @@ public void testMetrics() { new HttpPrometheusMetricsRequest() .credentials(new HttpBasicAuthenticationCredentials(username, password)) - .send(testEnvironment.getHttpClient()) + .send(exporterTestEnvironment.getHttpClient()) .accept( response -> { assertHttpResponseCode(response, code.get()); @@ -129,7 +134,7 @@ public void testMetricsOpenMetricsFormat() { new HttpOpenMetricsRequest() .credentials(new HttpBasicAuthenticationCredentials(username, password)) - .send(testEnvironment.getHttpClient()) + .send(exporterTestEnvironment.getHttpClient()) .accept( response -> { assertHttpResponseCode(response, code.get()); @@ -153,7 +158,7 @@ public void testMetricsPrometheusFormat() { new HttpPrometheusMetricsRequest() .credentials(new HttpBasicAuthenticationCredentials(username, password)) - .send(testEnvironment.getHttpClient()) + .send(exporterTestEnvironment.getHttpClient()) .accept( response -> { assertHttpResponseCode(response, code.get()); @@ -177,7 +182,7 @@ public void testMetricsPrometheusProtobufFormat() { new HttpPrometheusProtobufMetricsRequest() .credentials(new HttpBasicAuthenticationCredentials(username, password)) - .send(testEnvironment.getHttpClient()) + .send(exporterTestEnvironment.getHttpClient()) .accept( response -> { assertHttpResponseCode(response, code.get()); @@ -193,65 +198,68 @@ public void testMetricsPrometheusProtobufFormat() { public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java index cf104916..83b0183e 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java @@ -16,15 +16,23 @@ package io.prometheus.jmx.test.http.authentication; -import io.prometheus.jmx.test.AbstractTest; -import io.prometheus.jmx.test.support.TestArguments; +import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; + +import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.AuthenticationCredentials; +import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; +import io.prometheus.jmx.test.support.http.HttpHealthyRequest; +import io.prometheus.jmx.test.support.http.HttpMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.function.Predicate; +import java.util.concurrent.atomic.AtomicInteger; +import org.antublue.test.engine.api.TestEngine; -public abstract class AbstractBasicAuthenticationTest extends AbstractTest { +public abstract class AbstractBasicAuthenticationTest extends AbstractExporterTest { protected static final String VALID_USERNAME = "Prometheus"; @@ -35,112 +43,147 @@ public abstract class AbstractBasicAuthenticationTest extends AbstractTest { protected static final String[] INVALID_PASSWORDS = new String[] {"Secret", "bad", "", null}; - protected static final PBKDF2WithHmacTestArgumentFilter PBKDF2_WITH_MAC_TEST_ARGUMENT_FILTER = - new PBKDF2WithHmacTestArgumentFilter(); - - /** Class to implement a PBKDF2WithHmacTestArgumentFilter */ - protected static class PBKDF2WithHmacTestArgumentFilter implements Predicate { - - private final Set filteredDockerImages; - - /** Constructor */ - public PBKDF2WithHmacTestArgumentFilter() { - // Filter out Docker image names that don't support PBKDF2 with HMAC - filteredDockerImages = new HashSet<>(); - filteredDockerImages.add("ibmjava:8"); - filteredDockerImages.add("ibmjava:8-jre"); - filteredDockerImages.add("ibmjava:8-sdk"); - filteredDockerImages.add("ibmjava:8-sfj"); - } - - /** - * Evaluates this predicate on the given argument. - * - * @param testArguments the input argument - * @return {@code true} if the input argument matches the predicate, otherwise {@code false} - */ - @Override - public boolean test(TestArguments testArguments) { - return !filteredDockerImages.contains(testArguments.getDockerImageName()); - } - } - /** - * Method to create a Collection of AuthenticationTestCredentials + * Method to create a Collection of AuthenticationCredentials * - * @return a Collection of AuthenticationTestCredentials + * @return a Collection of AuthenticationCredentials */ - public static Collection getAuthenticationTestCredentials() { - Collection collection = new ArrayList<>(); - collection.add(AuthenticationTestCredentials.of(VALID_USERNAME, VALID_PASSWORD, true)); + public static Collection getAuthenticationCredentials() { + Collection collection = new ArrayList<>(); + collection.add(AuthenticationCredentials.of(VALID_USERNAME, VALID_PASSWORD, true)); for (String username : INVALID_USERNAMES) { for (String password : INVALID_PASSWORDS) { - collection.add(AuthenticationTestCredentials.of(username, password, false)); + collection.add(AuthenticationCredentials.of(username, password, false)); } } return collection; } - /** Class to implement AuthenticationTestCredentials */ - public static class AuthenticationTestCredentials { - - private String username; - private String password; - private boolean isValid; - - /** - * Constructor - * - * @param username - * @param password - * @param isValid - */ - private AuthenticationTestCredentials(String username, String password, boolean isValid) { - this.username = username; - this.password = password; - this.isValid = isValid; - } + @TestEngine.Test + public void testHealthy() { + getAuthenticationCredentials() + .forEach( + authenticationTestArguments -> { + final AtomicInteger code = + new AtomicInteger( + authenticationTestArguments.isValid() + ? HttpResponse.OK + : HttpResponse.UNAUTHORIZED); + new HttpHealthyRequest() + .credentials( + new HttpBasicAuthenticationCredentials( + authenticationTestArguments.getUsername(), + authenticationTestArguments.getPassword())) + .send(exporterTestEnvironment.getHttpClient()) + .accept( + response -> + assertHttpResponseCode(response, code.get())); + }); + } - /** - * Method to get the username - * - * @return the username - */ - public String getUsername() { - return username; - } + @TestEngine.Test + public void testMetrics() { + getAuthenticationCredentials() + .forEach( + authenticationCredentials -> { + final AtomicInteger code = + new AtomicInteger( + authenticationCredentials.isValid() + ? HttpResponse.OK + : HttpResponse.UNAUTHORIZED); + new HttpMetricsRequest() + .credentials( + new HttpBasicAuthenticationCredentials( + authenticationCredentials.getUsername(), + authenticationCredentials.getPassword())) + .send(exporterTestEnvironment.getHttpClient()) + .accept( + response -> { + assertHttpResponseCode(response, code.get()); + if (code.get() == HttpResponse.OK) { + accept(response); + } + }); + }); + } - /** - * Method to get the password - * - * @return the password - */ - public String getPassword() { - return password; - } + @TestEngine.Test + public void testMetricsOpenMetricsFormat() { + getAuthenticationCredentials() + .forEach( + authenticationCredentials -> { + final AtomicInteger code = + new AtomicInteger( + authenticationCredentials.isValid() + ? HttpResponse.OK + : HttpResponse.UNAUTHORIZED); + new HttpOpenMetricsRequest() + .credentials( + new HttpBasicAuthenticationCredentials( + authenticationCredentials.getUsername(), + authenticationCredentials.getPassword())) + .send(exporterTestEnvironment.getHttpClient()) + .accept( + response -> { + assertHttpResponseCode(response, code.get()); + if (code.get() == HttpResponse.OK) { + accept(response); + } + }); + }); + } - /** - * Method to return if the credentials are valid - * - * @return true if the credentials are valid, else false - */ - public boolean isValid() { - return isValid; - } + @TestEngine.Test + public void testMetricsPrometheusFormat() { + getAuthenticationCredentials() + .forEach( + authenticationCredentials -> { + final AtomicInteger code = + new AtomicInteger( + authenticationCredentials.isValid() + ? HttpResponse.OK + : HttpResponse.UNAUTHORIZED); + new HttpPrometheusMetricsRequest() + .credentials( + new HttpBasicAuthenticationCredentials( + authenticationCredentials.getUsername(), + authenticationCredentials.getPassword())) + .send(exporterTestEnvironment.getHttpClient()) + .accept( + response -> { + assertHttpResponseCode(response, code.get()); + if (code.get() == HttpResponse.OK) { + accept(response); + } + }); + }); + } - /** - * Method to create an AuthenticationTestCredentials - * - * @param username username - * @param password password - * @param isValid isValid - * @return an AuthenticationTestCredentials - */ - public static AuthenticationTestCredentials of( - String username, String password, boolean isValid) { - return new AuthenticationTestCredentials(username, password, isValid); - } + @TestEngine.Test + public void testMetricsPrometheusProtobufFormat() { + getAuthenticationCredentials() + .forEach( + authenticationCredentials -> { + final AtomicInteger code = + new AtomicInteger( + authenticationCredentials.isValid() + ? HttpResponse.OK + : HttpResponse.UNAUTHORIZED); + new HttpPrometheusProtobufMetricsRequest() + .credentials( + new HttpBasicAuthenticationCredentials( + authenticationCredentials.getUsername(), + authenticationCredentials.getPassword())) + .send(exporterTestEnvironment.getHttpClient()) + .accept( + response -> { + assertHttpResponseCode(response, code.get()); + if (code.get() == HttpResponse.OK) { + accept(response); + } + }); + }); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java index 895b753e..e9541e6a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java @@ -17,22 +17,16 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PBKDF2WithHmacExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -41,205 +35,82 @@ public class BasicAuthenticationPBKDF2WithHmacSHA1Test extends AbstractBasicAuth implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() - .filter(PBKDF2_WITH_MAC_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); + .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java index 251f1cb5..37f1dd8f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java @@ -17,22 +17,16 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PBKDF2WithHmacExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -41,205 +35,82 @@ public class BasicAuthenticationPBKDF2WithHmacSHA256Test extends AbstractBasicAu implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() - .filter(PBKDF2_WITH_MAC_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); + .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java index 6143166d..cb5d794a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -17,22 +17,16 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PBKDF2WithHmacExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -41,205 +35,82 @@ public class BasicAuthenticationPBKDF2WithHmacSHA512Test extends AbstractBasicAu implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() - .filter(PBKDF2_WITH_MAC_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); + .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java index d8c886ac..75c0276b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java @@ -17,216 +17,85 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; public class BasicAuthenticationPlaintextTest extends AbstractBasicAuthenticationTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java index 3bcc5ba9..3a7c9809 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java @@ -17,216 +17,85 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; public class BasicAuthenticationSHA1Test extends AbstractBasicAuthenticationTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java index 965acfbd..4fdc6c79 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java @@ -17,216 +17,85 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; public class BasicAuthenticationSHA256Test extends AbstractBasicAuthenticationTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java index a29561df..861a96ff 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java @@ -17,216 +17,85 @@ package io.prometheus.jmx.test.http.authentication; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; public class BasicAuthenticationSHA512Test extends AbstractBasicAuthenticationTest implements Consumer { - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java new file mode 100644 index 00000000..c8a829f8 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java @@ -0,0 +1,23 @@ +package io.prometheus.jmx.test.http.ssl; + +import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.http.authentication.AbstractBasicAuthenticationTest; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; + +public abstract class AbstractSSLTest extends AbstractExporterTest { + + private static final String BASE_URL = "https://localhost"; + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + return AbstractBasicAuthenticationTest.arguments() + .map(exporterTestEnvironment -> exporterTestEnvironment.setBaseUrl(BASE_URL)); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java index 67f7b83d..c116eb23 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -17,23 +17,16 @@ package io.prometheus.jmx.test.http.ssl; import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; -import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpResponseCode; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.http.authentication.AbstractBasicAuthenticationTest; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; @@ -41,218 +34,90 @@ public class SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test extends AbstractBasicAuthenticationTest implements Consumer { - private static final String BASE_URL = "https://localhost"; - /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { - return AbstractBasicAuthenticationTest.arguments() - .filter(PBKDF2_WITH_MAC_TEST_ARGUMENT_FILTER) + public static Stream arguments() { + // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites + // https://github.com/adoptium/temurin-build/issues/3002 + // https://bugs.openjdk.org/browse/JDK-8306037 + return AbstractSSLTest.arguments() .filter( - testArgument -> - !testArgument - .getDockerImageName() + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() .contains("eclipse-temurin:8-alpine")); } - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpHealthyRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> - assertHttpResponseCode(response, code.get())); - }); - } - - @TestEngine.Test - public void testMetrics() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpOpenMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - getAuthenticationTestCredentials() - .forEach( - authenticationTestArguments -> { - final AtomicInteger code = - new AtomicInteger( - authenticationTestArguments.isValid() - ? HttpResponse.OK - : HttpResponse.UNAUTHORIZED); - new HttpPrometheusProtobufMetricsRequest() - .credentials( - new HttpBasicAuthenticationCredentials( - authenticationTestArguments.getUsername(), - authenticationTestArguments.getPassword())) - .send(testEnvironment.getHttpClient()) - .accept( - response -> { - assertHttpResponseCode(response, code.get()); - if (code.get() == HttpResponse.OK) { - accept(response); - } - }); - }); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java index 2d96fcd6..7c4f2d70 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java @@ -19,142 +19,104 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithJKSKeyStoreMultipleCertificatesTest extends AbstractTest +public class SSLWithJKSKeyStoreMultipleCertificatesTest extends AbstractSSLTest implements Consumer { - private static final String BASE_URL = "https://localhost"; - /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 - return AbstractTest.arguments() + // https://bugs.openjdk.org/browse/JDK-8306037 + return AbstractSSLTest.arguments() .filter( - testArgument -> - !testArgument - .getDockerImageName() + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() .contains("eclipse-temurin:8-alpine")); } - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java index b08a80c3..bc07b468 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java @@ -19,141 +19,103 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithJKSKeyStoreTest extends AbstractTest implements Consumer { - - private static final String BASE_URL = "https://localhost"; +public class SSLWithJKSKeyStoreTest extends AbstractSSLTest implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 - return AbstractTest.arguments() + // https://bugs.openjdk.org/browse/JDK-8306037 + return AbstractSSLTest.arguments() .filter( - testArgument -> - !testArgument - .getDockerImageName() + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() .contains("eclipse-temurin:8-alpine")); } - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java index dbd8c850..4a11e93e 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java @@ -19,141 +19,103 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithJKSKeyStoreTest2 extends AbstractTest implements Consumer { - - private static final String BASE_URL = "https://localhost"; +public class SSLWithJKSKeyStoreTest2 extends AbstractSSLTest implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 - return AbstractTest.arguments() + // https://bugs.openjdk.org/browse/JDK-8306037 + return AbstractSSLTest.arguments() .filter( - testArgument -> - !testArgument - .getDockerImageName() + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() .contains("eclipse-temurin:8-alpine")); } - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } - @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java index 26d7c0a6..7c359532 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java @@ -19,170 +19,100 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PKCS12KeyStoreExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.Map; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithPKCS12KeyStoreMultipleCertificatesTest extends AbstractTest +public class SSLWithPKCS12KeyStoreMultipleCertificatesTest extends AbstractSSLTest implements Consumer { - private static final String BASE_URL = "https://localhost"; - - protected static final Predicate PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER = - new PKCS12KeyStoreTestArgumentFilter(); - - private static class PKCS12KeyStoreTestArgumentFilter implements Predicate { - - private final Set filteredDockerImages; - - public PKCS12KeyStoreTestArgumentFilter() { - filteredDockerImages = new HashSet<>(); - filteredDockerImages.add("eclipse-temurin:8-alpine"); - filteredDockerImages.add("ghcr.io/graalvm/jdk:java8"); - filteredDockerImages.add("ibmjava:8"); - filteredDockerImages.add("ibmjava:8-jre"); - filteredDockerImages.add("ibmjava:8-sdk"); - filteredDockerImages.add("ibmjava:8-sfj"); - filteredDockerImages.add("ibmjava:11"); - } - - /** - * Evaluates this predicate on the given argument. - * - * @param testArguments the input argument - * @return {@code true} if the input argument matches the predicate, otherwise {@code false} - */ - @Override - public boolean test(TestArguments testArguments) { - return !filteredDockerImages.contains(testArguments.getDockerImageName()); - } - } - /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites - return AbstractTest.arguments().filter(PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); + return AbstractSSLTest.arguments() + .filter(new PKCS12KeyStoreExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java index 52ab9c72..7ca0d59a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java @@ -19,169 +19,99 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PKCS12KeyStoreExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.Map; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithPKCS12KeyStoreTest extends AbstractTest implements Consumer { - - private static final String BASE_URL = "https://localhost"; - - protected static final Predicate PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER = - new PKCS12KeyStoreTestArgumentFilter(); - - private static class PKCS12KeyStoreTestArgumentFilter implements Predicate { - - private final Set filteredDockerImages; - - public PKCS12KeyStoreTestArgumentFilter() { - filteredDockerImages = new HashSet<>(); - filteredDockerImages.add("eclipse-temurin:8-alpine"); - filteredDockerImages.add("ghcr.io/graalvm/jdk:java8"); - filteredDockerImages.add("ibmjava:8"); - filteredDockerImages.add("ibmjava:8-jre"); - filteredDockerImages.add("ibmjava:8-sdk"); - filteredDockerImages.add("ibmjava:8-sfj"); - filteredDockerImages.add("ibmjava:11"); - } - - /** - * Evaluates this predicate on the given argument. - * - * @param testArguments the input argument - * @return {@code true} if the input argument matches the predicate, otherwise {@code false} - */ - @Override - public boolean test(TestArguments testArguments) { - return !filteredDockerImages.contains(testArguments.getDockerImageName()); - } - } +public class SSLWithPKCS12KeyStoreTest extends AbstractSSLTest implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites - return AbstractTest.arguments().filter(PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); + return AbstractSSLTest.arguments() + .filter(new PKCS12KeyStoreExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java index 06813989..4b329fec 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java @@ -19,169 +19,99 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.common.PKCS12KeyStoreExporterTestEnvironmentFilter; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.Map; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class SSLWithPKCS12KeyStoreTest2 extends AbstractTest implements Consumer { - - private static final String BASE_URL = "https://localhost"; - - protected static final Predicate PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER = - new PKCS12KeyStoreTestArgumentFilter(); - - private static class PKCS12KeyStoreTestArgumentFilter implements Predicate { - - private final Set filteredDockerImages; - - public PKCS12KeyStoreTestArgumentFilter() { - filteredDockerImages = new HashSet<>(); - filteredDockerImages.add("eclipse-temurin:8-alpine"); - filteredDockerImages.add("ghcr.io/graalvm/jdk:java8"); - filteredDockerImages.add("ibmjava:8"); - filteredDockerImages.add("ibmjava:8-jre"); - filteredDockerImages.add("ibmjava:8-sdk"); - filteredDockerImages.add("ibmjava:8-sfj"); - filteredDockerImages.add("ibmjava:11"); - } - - /** - * Evaluates this predicate on the given argument. - * - * @param testArguments the input argument - * @return {@code true} if the input argument matches the predicate, otherwise {@code false} - */ - @Override - public boolean test(TestArguments testArguments) { - return !filteredDockerImages.contains(testArguments.getDockerImageName()); - } - } +public class SSLWithPKCS12KeyStoreTest2 extends AbstractSSLTest implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites - return AbstractTest.arguments().filter(PKCS12_KEYSTORE_TEST_ARGUMENT_FILTER); - } - - @TestEngine.Prepare - public void setBaseUrl() { - testEnvironment.setBaseUrl(BASE_URL); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); + return AbstractSSLTest.arguments() + .filter(new PKCS12KeyStoreExporterTestEnvironmentFilter()); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java index 55aeb840..97c51ff2 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java @@ -19,115 +19,84 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; -import org.antublue.test.engine.api.TestEngine; -public class ThreadsConfigurationTest extends AbstractTest implements Consumer { - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); - } +public class ThreadsConfigurationTest extends AbstractExporterTest + implements Consumer { @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java index b1d79bba..2b5dbd59 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java @@ -1,18 +1,20 @@ package io.prometheus.jmx.test.opentelemetry; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; +import java.util.Collections; /** Class to implement ExpectedMetricsNames */ public class ExpectedMetricsNames { - private static final List metricNames = new ArrayList<>(); + private static final Collection METRIC_NAMES; static { + Collection metricNames = new ArrayList<>(); + metricNames.add("io_prometheus_jmx_autoIncrementing_Value"); // This metric doesn't exist for Java 11+ - // metricNames.add("io_prometheus_jmx_optionalValue_Value"); metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_avail"); @@ -179,6 +181,8 @@ public class ExpectedMetricsNames { metricNames.add("process_resident_memory_bytes"); metricNames.add("process_start_time_seconds"); metricNames.add("process_virtual_memory_bytes"); + + METRIC_NAMES = Collections.unmodifiableCollection(metricNames); } /** Constructor */ @@ -191,7 +195,7 @@ private ExpectedMetricsNames() { * * @return a List of metrics names */ - public static List getMetricsNames() { - return metricNames; + public static Collection getMetricsNames() { + return METRIC_NAMES; } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 4dba2db5..4a9c129c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -10,7 +10,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -26,19 +25,6 @@ @TestEngine.ParallelArgumentTest public class OpenTelemetryTest { - private static final List PROMETHEUS_DOCKER_IMAGES = new ArrayList<>(); - - // List of Prometheus Docker Images - static { - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.47.2"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.48.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.49.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.50.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.51.2"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.52.0"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.53.0"); - } - private Network network; @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; @@ -52,20 +38,21 @@ public class OpenTelemetryTest { public static Stream arguments() { Collection openTelemetryTestEnvironments = new ArrayList<>(); - PROMETHEUS_DOCKER_IMAGES.forEach( - prometheusDockerImage -> - JavaDockerImages.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + PrometheusDockerImages.names() + .forEach( + prometheusDockerImage -> + JavaDockerImages.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); return openTelemetryTestEnvironments.stream(); } @@ -126,13 +113,15 @@ public void testIsPrometheusUp() { /** Method to test that metrics exist in Prometheus */ @TestEngine.Test public void testPrometheusHasMetrics() { + boolean isJmxExporterModeJavaStandalone = + openTelemetryTestEnvironment.getJmxExporterMode() == JmxExporterMode.Standalone; + ExpectedMetricsNames.getMetricsNames().stream() .filter( metricName -> { - if (openTelemetryTestEnvironment.getJmxExporterMode() - == JmxExporterMode.Standalone - && metricName.startsWith("jvm_") - || metricName.startsWith("process_")) { + if (isJmxExporterModeJavaStandalone + && (metricName.startsWith("jvm_") + || metricName.startsWith("process_"))) { return false; } return true; @@ -154,6 +143,7 @@ public void afterAll() { public void conclude() { if (network != null) { network.close(); + network = null; } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java new file mode 100644 index 00000000..f475efc6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java @@ -0,0 +1,37 @@ +package io.prometheus.jmx.test.opentelemetry; + +import java.util.Collection; +import java.util.List; + +/** Class to implement PrometheusDockerImages */ +public class PrometheusDockerImages { + + private static final Collection PROMETHEUS_DOCKER_IMAGES; + + // Build the immutable list of Docker image names + static { + PROMETHEUS_DOCKER_IMAGES = + List.of( + "prom/prometheus:v2.47.2", + "prom/prometheus:v2.48.1", + "prom/prometheus:v2.49.1", + "prom/prometheus:v2.50.1", + "prom/prometheus:v2.51.2", + "prom/prometheus:v2.52.0", + "prom/prometheus:v2.53.1"); + } + + /** Constructor */ + private PrometheusDockerImages() { + // DO NOTHING + } + + /** + * Method to get List of all Docker image names + * + * @return the List of Docker image names + */ + public static Collection names() { + return PROMETHEUS_DOCKER_IMAGES; + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java index 34643ea9..8a2bfe94 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java @@ -19,138 +19,113 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class MinimalRMISSLTest extends AbstractTest implements Consumer { +public class MinimalRMISSLTest extends AbstractExporterTest implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter the arguments.. // // 1. only run the Standalone exporter // 2. filter out the GraalVM 1.8 JVM - exception is that SunJSSE is not found // 3. filter out all ibmjava* JVMs - exception is that SunJSSE is not found // - return AbstractTest.arguments() - .filter(testArgument -> testArgument.getName().contains("Standalone")) + return AbstractExporterTest.arguments() .filter( - testArgument1 -> - !testArgument1.getDockerImageName().contains("graalvm/jdk:java8")) - .filter(testArgument1 -> !testArgument1.getDockerImageName().contains("ibmjava")); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); + exporterTestEnvironment -> + exporterTestEnvironment.getName().contains("Standalone")) + .filter( + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() + .contains("graalvm/jdk:java8")) + .filter( + exporterTestEnvironment -> + !exporterTestEnvironment.getJavaDockerImage().contains("ibmjava")); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java index fc995b6d..af517fb0 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java @@ -19,138 +19,114 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; -import io.prometheus.jmx.test.AbstractTest; +import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; -import io.prometheus.jmx.test.support.TestArguments; -import io.prometheus.jmx.test.support.http.HttpHealthyRequest; -import io.prometheus.jmx.test.support.http.HttpMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpOpenMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; -import io.prometheus.jmx.test.support.http.HttpPrometheusProtobufMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; -import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; +import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; import org.antublue.test.engine.api.TestEngine; -public class RMIRegistrySSLDisabledTest extends AbstractTest implements Consumer { +public class RMIRegistrySSLDisabledTest extends AbstractExporterTest + implements Consumer { /** - * Method to get the list of TestArguments + * Method to get the Stream of test environments * - * @return the return value + * @return the Stream of test environments */ @TestEngine.ArgumentSupplier - public static Stream arguments() { + public static Stream arguments() { // Filter the arguments.. // // 1. only run the Standalone exporter // 2. filter out the GraalVM 1.8 JVM - exception is that SunJSSE is not found // 3. filter out all ibmjava* JVMs - exception is that SunJSSE is not found // - return AbstractTest.arguments() - .filter(testArgument -> testArgument.getName().contains("Standalone")) + return AbstractExporterTest.arguments() .filter( - testArgument1 -> - !testArgument1.getDockerImageName().contains("graalvm/jdk:java8")) - .filter(testArgument1 -> !testArgument1.getDockerImageName().contains("ibmjava")); - } - - @TestEngine.Test - public void testHealthy() { - new HttpHealthyRequest() - .send(testEnvironment.getHttpClient()) - .accept(HttpResponseAssertions::assertHttpHealthyResponse); - } - - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest().send(testEnvironment.getHttpClient()).accept(this); - } - - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(testEnvironment.getHttpClient()) - .accept(this); + exporterTestEnvironment -> + exporterTestEnvironment.getName().contains("Standalone")) + .filter( + exporterTestEnvironment -> + !exporterTestEnvironment + .getJavaDockerImage() + .contains("graalvm/jdk:java8")) + .filter( + exporterTestEnvironment -> + !exporterTestEnvironment.getJavaDockerImage().contains("ibmjava")); } @Override public void accept(HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); - Collection metrics = MetricsParser.parse(httpResponse); + Map> metrics = MetricsParser.parseMap(httpResponse); + + boolean isJmxExporterModeJavaAgent = + exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent + isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" : "jmx_prometheus_httpserver"; assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_exporter_build_info") .withLabel("name", buildInfoName) .withValue(1d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jmx_scrape_error") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("COUNTER") + .ofType(Metric.Type.COUNTER) .withName("jmx_config_reload_success_total") .withValue(0d) .isPresent(); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isPresent(testArguments.getJmxExporterMode() == JmxExporterMode.JavaAgent); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "nonheap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("GAUGE") + .ofType(Metric.Type.GAUGE) .withName("jvm_memory_used_bytes") .withLabel("area", "heap") - .isNotPresent(testArguments.getJmxExporterMode() == JmxExporterMode.Standalone); + .isPresentWhen(isJmxExporterModeJavaAgent); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_size") .withLabel("source", "/dev/sda1") .withValue(7.516192768E9d) .isPresent(); assertMetric(metrics) - .ofType("UNTYPED") + .ofType(Metric.Type.UNTYPED) .withName("io_prometheus_jmx_tabularData_Server_2_Disk_Usage_Table_pcent") .withLabel("source", "/dev/sda2") .withValue(0.8d) diff --git a/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/MessageDigestAuthenticatorTest.java b/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/MessageDigestAuthenticatorTest.java index 5a835f7f..3ff07413 100644 --- a/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/MessageDigestAuthenticatorTest.java +++ b/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/MessageDigestAuthenticatorTest.java @@ -22,6 +22,7 @@ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Locale; import org.junit.Test; public class MessageDigestAuthenticatorTest extends BaseAuthenticatorTest { @@ -53,7 +54,7 @@ public void test_upperCase() throws Exception { String[] algorithms = new String[] {"SHA-1", "SHA-256", "SHA-512"}; for (String algorithm : algorithms) { - String hash = hash(algorithm, VALID_PASSWORD, SALT).toUpperCase(); + String hash = hash(algorithm, VALID_PASSWORD, SALT).toUpperCase(Locale.ENGLISH); MessageDigestAuthenticator messageDigestAuthenticator = new MessageDigestAuthenticator("/", VALID_USERNAME, hash, algorithm, SALT); diff --git a/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/PBKDF2AuthenticatorTest.java b/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/PBKDF2AuthenticatorTest.java index a6360d1c..85edabfd 100644 --- a/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/PBKDF2AuthenticatorTest.java +++ b/jmx_prometheus_common/src/test/java/io/prometheus/jmx/common/http/authenticator/PBKDF2AuthenticatorTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; +import java.util.Locale; import org.junit.Test; public class PBKDF2AuthenticatorTest extends BaseAuthenticatorTest { @@ -143,7 +144,7 @@ public void testPBKDF2WithHmacSHA1_upperCaseWithoutColon() throws Exception { + ":E0:72:6E:69:7D:EB:83:05:05:E5:D6:F2:19:99:49:3F:89:DA:DE:83:D7:2B:5B:7D:C9:56:B4:F2:F6:A5:61:29" + ":29:ED:DF:4C:4E:8D:EA:DF:47:A2:B0:89:11:86:D4:77:A1:02:E9:0C:26:A4:1E:2A:C1:A8:71:E0:93:8F:A4"; - hash = hash.toUpperCase().replace(":", ""); + hash = hash.toUpperCase(Locale.ENGLISH).replace(":", ""); PBKDF2Authenticator PBKDF2Authenticator = new PBKDF2Authenticator( @@ -281,7 +282,7 @@ public void testPBKDF2WithHmacSHA256_upperCaseWithoutColon() throws Exception { + ":9C:CB:AD:55:25:46:C5:73:09:6C:38:9C:F2:FD:82:7F:90:E5:31:EF:7E:3E:6B:B2:0C:38:77:23:EC:3A:CF:29" + ":F7:E5:4D:4E:CC:35:7A:C2:E5:CB:E3:B3:E5:09:2B:CC:B9:40:26:A4:28:E9:5F:2D:18:B2:14:41:E7:4D:5B"; - hash = hash.toUpperCase().replace(":", ""); + hash = hash.toUpperCase(Locale.ENGLISH).replace(":", ""); PBKDF2Authenticator PBKDF2Authenticator = new PBKDF2Authenticator( @@ -404,7 +405,7 @@ public void testPBKDF2WithHmacSHA512_upperCaseWithoutColon() throws Exception { String hash = "07:6F:E2:27:9B:CA:48:66:9B:13:9E:02:9C:AE:FC:E4:1A:2F:0F:E6:48:A3:FF:8E:D2:30:59:68:12:A6:29:34:FC:99:29:8A:98:65:AE:4B:05:7C:B6:83:A4:83:C0:32:E4:90:61:1D:DD:2E:53:17:01:FF:6A:64:48:B2:AA:22:DE:B3:BC:56:08:C6:66:EC:98:F8:96:8C:1B:DA:B2:F2:2A:6C:22:8E:19:CC:B2:62:55:3E:BE:DC:C7:58:36:9D:92:CF:D7:D2:A1:6D:8F:DC:DE:8E:E9:36:D4:E7:2D:0A:6D:A1:B8:56:0A:53:BB:17:E2:D5:DE:A0:48:51:FC:33"; - hash = hash.toUpperCase().replace(":", ""); + hash = hash.toUpperCase(Locale.ENGLISH).replace(":", ""); PBKDF2Authenticator PBKDF2Authenticator = new PBKDF2Authenticator( diff --git a/pom.xml b/pom.xml index ea7fdd0c..6664e1d5 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ - + From e2d46e177ae39450baa76661870731d78048af82 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 11 Jul 2024 23:11:57 -0400 Subject: [PATCH 51/77] Added support for OpenTelemetry headers Signed-off-by: dhoard --- .../common/configuration/ConvertToMap.java | 41 +++++++++++++++++++ .../OpenTelemetryExporterFactory.java | 36 +++++++++++++--- 2 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java new file mode 100644 index 00000000..913ad1ef --- /dev/null +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java @@ -0,0 +1,41 @@ +package io.prometheus.jmx.common.configuration; + +import io.prometheus.jmx.common.util.Precondition; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * Class to convert an Object to a Map, throwing a RuntimeException from the Supplier if there is a + * ClassCastException + */ +@SuppressWarnings("unchecked") +public class ConvertToMap implements Function> { + + private final Supplier supplier; + + /** + * Constructor + * + * @param supplier supplier + */ + public ConvertToMap(Supplier supplier) { + Precondition.notNull(supplier); + this.supplier = supplier; + } + + @Override + public Map apply(Object o) { + try { + Map result = new LinkedHashMap<>(); + Map map = (Map) o; + + map.forEach((o1, o2) -> result.put(o1.toString(), o2.toString())); + + return result; + } catch (Throwable t) { + throw supplier.get(); + } + } +} diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java index 8e602a3a..57c6f4c1 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java @@ -3,6 +3,7 @@ import static java.lang.String.format; import io.prometheus.jmx.common.configuration.ConvertToInteger; +import io.prometheus.jmx.common.configuration.ConvertToMap; import io.prometheus.jmx.common.configuration.ConvertToMapAccessor; import io.prometheus.jmx.common.configuration.ConvertToString; import io.prometheus.jmx.common.configuration.ValidateIntegerInRange; @@ -117,12 +118,35 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE + " between greater than 0"))) .orElse(60); - openTelemetryExporter = - OpenTelemetryExporter.builder() - .endpoint(endpoint) - .protocol(protocol) - .intervalSeconds(interval) - .buildAndStart(); + Map headers = + openTelemetryYamlMapAccessor + .get("/headers") + .map( + new ConvertToMap( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/headers" + + " must be a map"))) + .orElse(null); + + OpenTelemetryExporter.Builder openTelemetryExporterBuilder = + OpenTelemetryExporter.builder(); + + openTelemetryExporterBuilder + .endpoint(endpoint) + .protocol(protocol) + .intervalSeconds(interval); + + if (headers != null) { + headers.forEach( + (name, value) -> { + if (name != null && !name.trim().isEmpty()) { + openTelemetryExporterBuilder.header(name, value); + } + }); + } + + openTelemetryExporter = openTelemetryExporterBuilder.buildAndStart(); } } } catch (IOException e) { From 4475bb7135aa50ad79ca3bb9b990cde37a0afee1 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 12 Jul 2024 00:44:23 -0400 Subject: [PATCH 52/77] Fixed duplicate plugin definition Signed-off-by: dhoard --- .../integration_tests/pom.xml | 7 ++---- .../{prometheus.yml => prometheus.yaml} | 0 .../{prometheus.yml => prometheus.yaml} | 0 jmx_prometheus_common/pom.xml | 21 ---------------- jmx_prometheus_httpserver/pom.xml | 25 ++----------------- jmx_prometheus_javaagent/pom.xml | 25 ++----------------- 6 files changed, 6 insertions(+), 72 deletions(-) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/{prometheus.yml => prometheus.yaml} (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/{prometheus.yml => prometheus.yaml} (100%) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index f657a5b5..ac6c3272 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -29,10 +29,7 @@ UTF-8 UTF-8 7.1.0-BETA-3 - - - - + @@ -84,7 +81,7 @@ ${antublue.test.engine.version} - ${docker.image.names} + ${java.docker.images} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yaml diff --git a/jmx_prometheus_common/pom.xml b/jmx_prometheus_common/pom.xml index 7f520deb..4c21d977 100644 --- a/jmx_prometheus_common/pom.xml +++ b/jmx_prometheus_common/pom.xml @@ -40,27 +40,6 @@ -Xbootclasspath/a:${env.JAVA_HOME}/lib/ - - com.diffplug.spotless - spotless-maven-plugin - - - - 1.22.0 - - true - - - - - - - check - - compile - - - com.diffplug.spotless spotless-maven-plugin diff --git a/jmx_prometheus_httpserver/pom.xml b/jmx_prometheus_httpserver/pom.xml index d91be272..aee7766f 100644 --- a/jmx_prometheus_httpserver/pom.xml +++ b/jmx_prometheus_httpserver/pom.xml @@ -41,6 +41,7 @@ com.diffplug.spotless spotless-maven-plugin + 2.43.0 @@ -53,7 +54,7 @@ - check + apply compile @@ -273,28 +274,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - diff --git a/jmx_prometheus_javaagent/pom.xml b/jmx_prometheus_javaagent/pom.xml index 34060ebd..cf149237 100644 --- a/jmx_prometheus_javaagent/pom.xml +++ b/jmx_prometheus_javaagent/pom.xml @@ -41,6 +41,7 @@ com.diffplug.spotless spotless-maven-plugin + 2.43.0 @@ -53,7 +54,7 @@ - check + apply compile @@ -239,28 +240,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - From 4cac01945bb777f7f98bdf1d8d7d0713a71c2a4b Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 12 Jul 2024 00:45:50 -0400 Subject: [PATCH 53/77] Refactored test classes to test OpenTelemetryExporter authentication Signed-off-by: dhoard --- .../test/opentelemetry/OpenTelemetryTest.java | 47 ++-- .../OpenTelemetryTestEnvironment.java | 134 ++++++++--- .../opentelemetry/PrometheusDockerImages.java | 37 +++ .../OpenTelemetryBasicAuthenticationTest.java | 226 ++++++++++++++++++ .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 8 + .../JavaAgent/prometheus.yaml | 4 + .../JavaAgent/web.yaml | 2 + .../Standalone/application.sh | 13 + .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 9 + .../Standalone/prometheus.yaml | 4 + .../Standalone/web.yaml | 2 + .../jmx_example_application/pom.xml | 25 +- 14 files changed, 430 insertions(+), 92 deletions(-) create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 4dba2db5..9950a9a8 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -10,7 +10,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -26,19 +25,6 @@ @TestEngine.ParallelArgumentTest public class OpenTelemetryTest { - private static final List PROMETHEUS_DOCKER_IMAGES = new ArrayList<>(); - - // List of Prometheus Docker Images - static { - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.47.2"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.48.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.49.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.50.1"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.51.2"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.52.0"); - PROMETHEUS_DOCKER_IMAGES.add("prom/prometheus:v2.53.0"); - } - private Network network; @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; @@ -52,20 +38,21 @@ public class OpenTelemetryTest { public static Stream arguments() { Collection openTelemetryTestEnvironments = new ArrayList<>(); - PROMETHEUS_DOCKER_IMAGES.forEach( - prometheusDockerImage -> - JavaDockerImages.names() - .forEach( - javaDockerImageName -> { - for (JmxExporterMode jmxExporterMode : - JmxExporterMode.values()) { - openTelemetryTestEnvironments.add( - new OpenTelemetryTestEnvironment( - prometheusDockerImage, - javaDockerImageName, - jmxExporterMode)); - } - })); + PrometheusDockerImages.names() + .forEach( + prometheusDockerImage -> + JavaDockerImages.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); return openTelemetryTestEnvironments.stream(); } @@ -86,7 +73,7 @@ public void beforeAll() { @TestEngine.Test @TestEngine.Order(order = 0) public void testIsPrometheusUp() { - Throttle throttle = new ExponentialBackoffThrottle(100, 5000); + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); AtomicBoolean success = new AtomicBoolean(); for (int i = 0; i < 10; i++) { @@ -175,7 +162,7 @@ protected Double getPrometheusMetric(String metricName) { * @return the metric value, or null if it doesn't exist */ protected Double getPrometheusMetric(String metricName, String[] labels) { - Throttle throttle = new ExponentialBackoffThrottle(100, 6400); + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); AtomicReference value = new AtomicReference<>(); for (int i = 0; i < 10; i++) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 9fc13937..92055fe5 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -3,7 +3,12 @@ import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpClient; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.util.ArrayList; +import java.util.List; import org.antublue.test.engine.api.Argument; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; @@ -156,45 +161,66 @@ public void destroy() { * @return the return value */ private GenericContainer createPrometheusContainer() { - return new GenericContainer<>(prometheusDockerImage) - .withClasspathResourceMapping( - testClass.getName().replace(".", "/") - + "/" - + jmxExporterMode - + "/prometheus.yml", - "/etc/prometheus/prometheus.yml", - BindMode.READ_ONLY) - .withWorkingDirectory("/prometheus") - .withCommand( - "--config.file=/etc/prometheus/prometheus.yml", - "--storage.tsdb.path=/prometheus", - "--web.console.libraries=/usr/share/prometheus/console_libraries", - "--web.console.templates=/usr/share/prometheus/consoles", - "--enable-feature=otlp-write-receiver") - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withExposedPorts(9090) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("prometheus") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)); + List commands = new ArrayList<>(); + + commands.add("--config.file=/etc/prometheus/prometheus.yaml"); + commands.add("--storage.tsdb.path=/prometheus"); + commands.add("--web.console.libraries=/usr/share/prometheus/console_libraries"); + commands.add("--web.console.templates=/usr/share/prometheus/consoles"); + commands.add("--enable-feature=otlp-write-receiver"); + + String webYml = + "/" + testClass.getName().replace(".", "/") + "/" + jmxExporterMode + "/web.yaml"; + + boolean hasWebYml = hasResource(webYml); + + if (hasWebYml) { + commands.add("--web.config.file=/etc/prometheus/web.yaml"); + } + + GenericContainer genericContainer = + new GenericContainer<>(prometheusDockerImage) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + + "/" + + jmxExporterMode + + "/prometheus.yaml", + "/etc/prometheus/prometheus.yaml", + BindMode.READ_ONLY) + .withWorkingDirectory("/prometheus") + .withCommand(commands.toArray(new String[0])) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withExposedPorts(9090) + .withLogConsumer( + outputFrame -> { + String string = + outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("prometheus") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)); + + if (hasWebYml) { + genericContainer.withClasspathResourceMapping( + webYml, "/etc/prometheus/web.yaml", BindMode.READ_ONLY); + } + + return genericContainer; } /** @@ -331,4 +357,34 @@ private static HttpClient createPrometheusHttpClient( GenericContainer genericContainer, String baseUrl, int mappedPort) { return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); } + + /** + * Method to determin if a resource exists + * + * @param resource resource + * @return true if the resource exists, else false + */ + private static boolean hasResource(String resource) { + boolean hasResource = false; + + try (BufferedReader bufferedReader = + new BufferedReader( + new InputStreamReader( + OpenTelemetryTestEnvironment.class.getResourceAsStream(resource), + StandardCharsets.UTF_8))) { + while (true) { + String line = bufferedReader.readLine(); + if (line == null) { + break; + } + hasResource = true; + break; + } + + } catch (Throwable t) { + // DO NOTHING + } + + return hasResource; + } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java new file mode 100644 index 00000000..f475efc6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java @@ -0,0 +1,37 @@ +package io.prometheus.jmx.test.opentelemetry; + +import java.util.Collection; +import java.util.List; + +/** Class to implement PrometheusDockerImages */ +public class PrometheusDockerImages { + + private static final Collection PROMETHEUS_DOCKER_IMAGES; + + // Build the immutable list of Docker image names + static { + PROMETHEUS_DOCKER_IMAGES = + List.of( + "prom/prometheus:v2.47.2", + "prom/prometheus:v2.48.1", + "prom/prometheus:v2.49.1", + "prom/prometheus:v2.50.1", + "prom/prometheus:v2.51.2", + "prom/prometheus:v2.52.0", + "prom/prometheus:v2.53.1"); + } + + /** Constructor */ + private PrometheusDockerImages() { + // DO NOTHING + } + + /** + * Method to get List of all Docker image names + * + * @return the List of Docker image names + */ + public static Collection names() { + return PROMETHEUS_DOCKER_IMAGES; + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java new file mode 100644 index 00000000..9145118c --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java @@ -0,0 +1,226 @@ +package io.prometheus.jmx.test.opentelemetry.authentication; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.prometheus.jmx.test.opentelemetry.ExpectedMetricsNames; +import io.prometheus.jmx.test.opentelemetry.OpenTelemetryTestEnvironment; +import io.prometheus.jmx.test.opentelemetry.PrometheusDockerImages; +import io.prometheus.jmx.test.support.JavaDockerImages; +import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; +import io.prometheus.jmx.test.support.http.HttpRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Stream; +import org.antublue.test.engine.api.TestEngine; +import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; +import org.antublue.test.engine.extras.throttle.Throttle; +import org.junit.jupiter.api.Assertions; +import org.testcontainers.containers.Network; +import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; + +/** Class to implement OpenTelemetryTest */ +@TestEngine.ParallelArgumentTest +public class OpenTelemetryBasicAuthenticationTest { + + private static final String VALID_USER = "Prometheus"; + private static final String VALUE_PASSWORD = "secret"; + + private Network network; + + @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @TestEngine.ArgumentSupplier + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); + + PrometheusDockerImages.names() + .forEach( + prometheusDockerImage -> + JavaDockerImages.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestEnvironments.stream(); + } + + @TestEngine.Prepare + public void prepare() { + // Create a Network and get the id to force the network creation + network = Network.newNetwork(); + network.getId(); + } + + @TestEngine.BeforeAll + public void beforeAll() { + openTelemetryTestEnvironment.initialize(getClass(), network); + } + + /** Method to test that Prometheus is up */ + @TestEngine.Test + @TestEngine.Order(order = 0) + public void testIsPrometheusUp() { + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + AtomicBoolean success = new AtomicBoolean(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery("up") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + + if (httpResponse.statusCode() != 200) { + return; + } + + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + Map map = + new Yaml().load(httpResponse.body().string()); + + String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); + + success.set(true); + }); + + if (success.get()) { + break; + } + + throttle.throttle(); + } + + if (!success.get()) { + Assertions.fail("Prometheus is not up"); + } + } + + /** Method to test that metrics exist in Prometheus */ + @TestEngine.Test + public void testPrometheusHasMetrics() { + ExpectedMetricsNames.getMetricsNames().stream() + .filter( + metricName -> { + if (openTelemetryTestEnvironment.getJmxExporterMode() + == JmxExporterMode.Standalone + && metricName.startsWith("jvm_") + || metricName.startsWith("process_")) { + return false; + } + return true; + }) + .forEach( + metricName -> { + Double value = getPrometheusMetric(metricName); + assertThat(value).as("metricName [%s]", metricName).isNotNull(); + assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); + }); + } + + @TestEngine.AfterAll + public void afterAll() { + openTelemetryTestEnvironment.destroy(); + } + + @TestEngine.Conclude + public void conclude() { + if (network != null) { + network.close(); + } + } + + /** + * Method to get a Prometheus metric + * + * @param metricName metricName + * @return the metric value, or null if it doesn't exist + */ + protected Double getPrometheusMetric(String metricName) { + return getPrometheusMetric(metricName, null); + } + + /** + * Method to get a Prometheus metrics + * + * @param metricName metricName + * @param labels labels + * @return the metric value, or null if it doesn't exist + */ + protected Double getPrometheusMetric(String metricName, String[] labels) { + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + AtomicReference value = new AtomicReference<>(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery(metricName) + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.statusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + // TODO parse response and return value + if (httpResponse.body().string().contains(metricName)) { + value.set(1.0); + } + }); + + if (value.get() != null) { + break; + } + + throttle.throttle(); + } + + return value.get(); + } + + /** + * Method to send a Prometheus query + * + * @param query query + * @return an HttpResponse + */ + protected HttpResponse sendPrometheusQuery(String query) { + return sendRequest( + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); + } + + /** + * Method to send an Http GET request + * + * @param path path + * @return an HttpResponse + */ + protected HttpResponse sendRequest(String path) { + return openTelemetryTestEnvironment + .getPrometheusHttpClient() + .send( + new HttpRequest(path) + .credentials( + new HttpBasicAuthenticationCredentials( + VALID_USER, VALUE_PASSWORD))); + } +} diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml new file mode 100644 index 00000000..dea4916f --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml @@ -0,0 +1,8 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 + headers: + Authorization: "Basic UHJvbWV0aGV1czpzZWNyZXQ=" +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml new file mode 100644 index 00000000..1aecd62a --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml @@ -0,0 +1,2 @@ +basic_auth_users: + Prometheus: $2y$10$ocnnaD337.WxiugU0ho92eBkX4Eq7/ZntVgwhgwlW5m2EvnOC9n62 \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml new file mode 100644 index 00000000..ddc06c96 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml @@ -0,0 +1,9 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 + headers: + Authorization: "Basic UHJvbWV0aGV1czpzZWNyZXQ=" +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml new file mode 100644 index 00000000..1aecd62a --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml @@ -0,0 +1,2 @@ +basic_auth_users: + Prometheus: $2y$10$ocnnaD337.WxiugU0ho92eBkX4Eq7/ZntVgwhgwlW5m2EvnOC9n62 \ No newline at end of file diff --git a/integration_test_suite/jmx_example_application/pom.xml b/integration_test_suite/jmx_example_application/pom.xml index 06ff5ae0..32b1dd47 100644 --- a/integration_test_suite/jmx_example_application/pom.xml +++ b/integration_test_suite/jmx_example_application/pom.xml @@ -50,6 +50,7 @@ com.diffplug.spotless spotless-maven-plugin + 2.43.0 @@ -62,7 +63,7 @@ - check + apply compile @@ -164,28 +165,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - From 616ad22de5b087fc784bf04d30560f2d5339a07f Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 16 Jul 2024 23:28:22 -0400 Subject: [PATCH 54/77] Converted integration tests to use Verifyica Signed-off-by: dhoard --- .gitignore | 1 - docs/README.md | 2 +- .../integration_tests/pom.xml | 25 +- .../jmx/test/support/JavaDockerImages.java | 35 ++- .../throttle/ExponentialBackoffThrottle.java | 53 ++++ .../jmx/test/support/throttle/Throttle.java | 8 + .../jmx/test/AutoIncrementingMBeanTest.java | 20 +- .../jmx/test/BlacklistObjectNamesTest.java | 7 +- .../jmx/test/CompositeKeyDataTest.java | 8 +- ...leAutoExcludeObjectNameAttributesTest.java | 7 +- .../test/ExcludeObjectNameAttributesTest.java | 7 +- .../jmx/test/ExcludeObjectNamesTest.java | 8 +- .../IncludeAndExcludeObjectNamesTest.java | 7 +- .../jmx/test/IncludeObjectNamesTest.java | 8 +- .../LowerCaseOutputAndLabelNamesTest.java | 7 +- .../test/LowerCaseOutputLabelNamesTest.java | 7 +- .../jmx/test/LowerCaseOutputNamesTest.java | 7 +- .../io/prometheus/jmx/test/MinimalTest.java | 8 +- .../jmx/test/OptionalValueMBeanTest.java | 8 +- .../WhitelistAndBlacklistObjectNamesTest.java | 7 +- .../jmx/test/WhitelistObjectNamesTest.java | 7 +- .../jmx/test/common/AbstractExporterTest.java | 99 +++++--- .../test/common/ExporterTestEnvironment.java | 6 +- .../CompleteHttpServerConfigurationTest.java | 49 ++-- .../AbstractBasicAuthenticationTest.java | 42 ++-- ...cAuthenticationPBKDF2WithHmacSHA1Test.java | 10 +- ...uthenticationPBKDF2WithHmacSHA256Test.java | 10 +- ...uthenticationPBKDF2WithHmacSHA512Test.java | 10 +- .../BasicAuthenticationPlaintextTest.java | 7 +- .../BasicAuthenticationSHA1Test.java | 7 +- .../BasicAuthenticationSHA256Test.java | 7 +- .../BasicAuthenticationSHA512Test.java | 7 +- .../jmx/test/http/ssl/AbstractSSLTest.java | 4 +- ...uthenticationPBKDF2WithHmacSHA512Test.java | 11 +- ...thJKSKeyStoreMultipleCertificatesTest.java | 10 +- .../test/http/ssl/SSLWithJKSKeyStoreTest.java | 11 +- .../http/ssl/SSLWithJKSKeyStoreTest2.java | 11 +- ...KCS12KeyStoreMultipleCertificatesTest.java | 10 +- .../http/ssl/SSLWithPKCS12KeyStoreTest.java | 11 +- .../http/ssl/SSLWithPKCS12KeyStoreTest2.java | 11 +- .../threads/ThreadsConfigurationTest.java | 7 +- .../test/opentelemetry/OpenTelemetryTest.java | 101 ++++---- .../OpenTelemetryTestEnvironment.java | 132 +++++++--- .../opentelemetry/PrometheusDockerImages.java | 156 ++++++++++-- .../OpenTelemetryBasicAuthenticationTest.java | 229 ++++++++++++++++++ .../jmx/test/rmi/ssl/MinimalRMISSLTest.java | 11 +- .../rmi/ssl/RMIRegistrySSLDisabledTest.java | 10 +- .../{prometheus.yml => prometheus.yaml} | 0 .../{prometheus.yml => prometheus.yaml} | 0 .../JavaAgent/application.sh | 6 + .../JavaAgent/exporter.yaml | 8 + .../JavaAgent/prometheus.yaml | 4 + .../JavaAgent/web.yaml | 2 + .../Standalone/application.sh | 13 + .../Standalone/exporter.sh | 5 + .../Standalone/exporter.yaml | 9 + .../Standalone/prometheus.yaml | 4 + .../Standalone/web.yaml | 2 + .../resources/prometheus-docker-images.txt | 7 + .../smoke-test-prometheus-docker-images.txt | 1 + .../jmx_example_application/pom.xml | 24 +- jmx_prometheus_common/pom.xml | 22 -- .../common/configuration/ConvertToMap.java | 41 ++++ .../OpenTelemetryExporterFactory.java | 36 ++- jmx_prometheus_httpserver/pom.xml | 24 +- jmx_prometheus_javaagent/pom.xml | 24 +- verifyica.properties | 23 ++ 67 files changed, 1033 insertions(+), 448 deletions(-) create mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/ExponentialBackoffThrottle.java create mode 100644 integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/Throttle.java create mode 100644 integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/{prometheus.yml => prometheus.yaml} (100%) rename integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/{prometheus.yml => prometheus.yaml} (100%) create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml create mode 100644 integration_test_suite/integration_tests/src/test/resources/prometheus-docker-images.txt create mode 100644 integration_test_suite/integration_tests/src/test/resources/smoke-test-prometheus-docker-images.txt create mode 100644 jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java create mode 100644 verifyica.properties diff --git a/.gitignore b/.gitignore index 80177aa4..fbdd40b0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ output.log stress-test.log test.sh test.log -.antublue-test-engine.properties diff --git a/docs/README.md b/docs/README.md index 464553fa..38c124c6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -332,7 +332,7 @@ httpServer: ## Integration Test Suite -The JMX exporter uses the [AntuBLUE Test Engine](https://github.com/antublue/test-engine) and [Testcontainers](https://www.testcontainers.org/) to run integration tests with different Java versions. +The JMX exporter uses the [Braxco](https://github.com/antublue/braxco) and [Testcontainers](https://www.testcontainers.org/) to run integration tests with different Java versions. You need to have Docker installed to run the integration test suite. diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 38d301b5..3fa91ffe 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 7.1.0-BETA-4 + 0.0.1 @@ -79,9 +79,9 @@ - org.antublue - test-engine-maven-plugin - ${antublue.test.engine.version} + org.antublue.verifyica + maven-plugin + ${verifyica.version} ${docker.image.names} @@ -123,19 +123,14 @@ - org.antublue - test-engine-api - ${antublue.test.engine.version} + org.antublue.verifyica + api + ${verifyica.version} - org.antublue - test-engine-extras - ${antublue.test.engine.version} - - - org.antublue - test-engine - ${antublue.test.engine.version} + org.antublue.verifyica + engine + ${verifyica.version} io.prometheus.jmx diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java index e0e110f3..4ba3e71b 100644 --- a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/JavaDockerImages.java @@ -30,19 +30,19 @@ /** Class to implement JavaDockerImages */ public final class JavaDockerImages { - private static final String JAVA_DOCKER_IMAGES_CONFIGURATION = "java.docker.images"; + private static final String DOCKER_IMAGES_CONFIGURATION = "java.docker.images"; - private static final String JAVA_DOCKER_IMAGES_RESOURCE = "/java-docker-images.txt"; + private static final String DOCKER_IMAGES_RESOURCE = "/java-docker-images.txt"; - private static final String SMOKE_TEST_JAVA_DOCKER_IMAGES_RESOURCE = + private static final String SMOKE_TEST_DOCKER_IMAGES_RESOURCE = "/smoke-test-java-docker-images.txt"; - private static String[] ALL_JAVA_DOCKER_IMAGE_NAMES; + private static String[] ALL_DOCKER_IMAGE_NAMES; - private static String[] SMOKE_TEST_JAVA_DOCKER_IMAGES; + private static String[] SMOKE_TEST_DOCKER_IMAGES; /** Predicate to accept all Docker image names */ - public static final Predicate ALL_JAVA_VERSIONS = name -> true; + public static final Predicate ACCEPT_ALL = name -> true; /** Constructor */ private JavaDockerImages() { @@ -55,7 +55,7 @@ private JavaDockerImages() { * @return the Collection of Docker image names */ public static Collection names() { - return names(ALL_JAVA_VERSIONS); + return names(ACCEPT_ALL); } /** @@ -68,11 +68,11 @@ public static Collection names(Predicate predicate) { Objects.requireNonNull(predicate); synchronized (JavaDockerImages.class) { - if (ALL_JAVA_DOCKER_IMAGE_NAMES == null) { - ALL_JAVA_DOCKER_IMAGE_NAMES = load(JAVA_DOCKER_IMAGES_RESOURCE); + if (ALL_DOCKER_IMAGE_NAMES == null) { + ALL_DOCKER_IMAGE_NAMES = load(DOCKER_IMAGES_RESOURCE); } - if (SMOKE_TEST_JAVA_DOCKER_IMAGES == null) { - SMOKE_TEST_JAVA_DOCKER_IMAGES = load(SMOKE_TEST_JAVA_DOCKER_IMAGES_RESOURCE); + if (SMOKE_TEST_DOCKER_IMAGES == null) { + SMOKE_TEST_DOCKER_IMAGES = load(SMOKE_TEST_DOCKER_IMAGES_RESOURCE); } } @@ -80,9 +80,7 @@ public static Collection names(Predicate predicate) { String dockerImageNameValue = System.getenv( - JAVA_DOCKER_IMAGES_CONFIGURATION - .toUpperCase(Locale.ENGLISH) - .replace('.', '_')); + DOCKER_IMAGES_CONFIGURATION.toUpperCase(Locale.ENGLISH).replace('.', '_')); if (dockerImageNameValue != null) { dockerImageNameValue = dockerImageNameValue.trim(); @@ -92,7 +90,7 @@ public static Collection names(Predicate predicate) { } if (dockerImageNameValue == null) { - dockerImageNameValue = System.getProperty(JAVA_DOCKER_IMAGES_CONFIGURATION); + dockerImageNameValue = System.getProperty(DOCKER_IMAGES_CONFIGURATION); if (dockerImageNameValue != null) { if (dockerImageNameValue.isBlank()) { dockerImageNameValue = null; @@ -101,9 +99,9 @@ public static Collection names(Predicate predicate) { } if (dockerImageNameValue == null) { - dockerImageNames = SMOKE_TEST_JAVA_DOCKER_IMAGES; + dockerImageNames = SMOKE_TEST_DOCKER_IMAGES; } else if (dockerImageNameValue.equalsIgnoreCase("ALL")) { - dockerImageNames = ALL_JAVA_DOCKER_IMAGE_NAMES; + dockerImageNames = ALL_DOCKER_IMAGE_NAMES; } else { dockerImageNames = dockerImageNameValue.split("\\s+"); } @@ -149,8 +147,7 @@ private static String[] load(String resource) { return dockerImageNames.toArray(new String[0]); } catch (IOException e) { - throw new RuntimeException( - "Exception reading resource " + JAVA_DOCKER_IMAGES_RESOURCE, e); + throw new RuntimeException("Exception reading resource " + DOCKER_IMAGES_RESOURCE, e); } } } diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/ExponentialBackoffThrottle.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/ExponentialBackoffThrottle.java new file mode 100644 index 00000000..152e8d70 --- /dev/null +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/ExponentialBackoffThrottle.java @@ -0,0 +1,53 @@ +package io.prometheus.jmx.test.support.throttle; + +/** Class to implement ExponentialBackupThrottle */ +@SuppressWarnings("PMD.EmptyCatchBlock") +public class ExponentialBackoffThrottle implements Throttle { + + private final long maximumMilliseconds; + private long throttleMilliseconds; + + /** + * Constructor + * + * @param minimumMilliseconds minimumMilliseconds + * @param maximumMilliseconds maximumMilliseconds + */ + public ExponentialBackoffThrottle(long minimumMilliseconds, long maximumMilliseconds) { + if (minimumMilliseconds < 1) { + throw new IllegalArgumentException( + "minimumMilliseconds [" + minimumMilliseconds + "] is less than 1"); + } + + if (maximumMilliseconds < 1) { + throw new IllegalArgumentException( + "maximumMilliseconds [" + maximumMilliseconds + "] is less than 1"); + } + + if (minimumMilliseconds > maximumMilliseconds) { + throw new IllegalArgumentException( + "minimumMilliseconds [" + + minimumMilliseconds + + "] is greater than maximumMilliseconds [" + + maximumMilliseconds + + "]"); + } + + this.throttleMilliseconds = minimumMilliseconds; + this.maximumMilliseconds = maximumMilliseconds; + } + + @Override + public void throttle() { + try { + Thread.sleep(throttleMilliseconds); + } catch (InterruptedException e) { + // DO NOTHING + } + + throttleMilliseconds = throttleMilliseconds * 2; + if (throttleMilliseconds > maximumMilliseconds) { + throttleMilliseconds = maximumMilliseconds; + } + } +} diff --git a/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/Throttle.java b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/Throttle.java new file mode 100644 index 00000000..a0fce163 --- /dev/null +++ b/integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/throttle/Throttle.java @@ -0,0 +1,8 @@ +package io.prometheus.jmx.test.support.throttle; + +/** Interface to implement Throttle */ +public interface Throttle { + + /** Method to throttle the current thread */ + void throttle(); +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java index 099540f7..e4d4059c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java @@ -19,23 +19,27 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static org.assertj.core.api.Assertions.assertThat; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.Verifyica; import org.testcontainers.shaded.com.google.common.util.concurrent.AtomicDouble; public class AutoIncrementingMBeanTest extends MinimalTest { - @TestEngine.Test - @TestEngine.Order(order = Integer.MAX_VALUE) - public void testAutoIncrementingMBean() { + @Verifyica.Test + @Verifyica.Order(order = Integer.MAX_VALUE) + public void testAutoIncrementingMBean(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + // Collect the auto incrementing MBean values - double value1 = collect(); - double value2 = collect(); - double value3 = collect(); + double value1 = collect(exporterTestEnvironment); + double value2 = collect(exporterTestEnvironment); + double value3 = collect(exporterTestEnvironment); // Assert that each collection is the previous value + 1 assertThat(value2).isGreaterThan(value1); @@ -49,7 +53,7 @@ public void testAutoIncrementingMBean() { * * @return the auto incrementing MBean value */ - private double collect() { + private double collect(ExporterTestEnvironment exporterTestEnvironment) { final AtomicDouble value = new AtomicDouble(); HttpResponse httpResponse = diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java index 3bf42943..e19e161c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/BlacklistObjectNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class BlacklistObjectNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java index f715caad..72488ee1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/CompositeKeyDataTest.java @@ -20,16 +20,18 @@ import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; -import java.util.function.Consumer; +import java.util.function.BiConsumer; -public class CompositeKeyDataTest extends AbstractExporterTest implements Consumer { +public class CompositeKeyDataTest extends AbstractExporterTest + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java index 9118cda9..83c98bd2 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest.java @@ -20,19 +20,20 @@ import static org.assertj.core.api.Assertions.fail; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class DisableAutoExcludeObjectNameAttributesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java index 0f44f0eb..a546339d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest.java @@ -20,19 +20,20 @@ import static org.assertj.core.api.Assertions.fail; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class ExcludeObjectNameAttributesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java index f59c6192..4c190bee 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/ExcludeObjectNamesTest.java @@ -20,17 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; -public class ExcludeObjectNamesTest extends AbstractExporterTest implements Consumer { +public class ExcludeObjectNamesTest extends AbstractExporterTest + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java index aa1268b3..4e7853cf 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class IncludeAndExcludeObjectNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java index eb3442ea..31bdd0f8 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/IncludeObjectNamesTest.java @@ -20,17 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; -public class IncludeObjectNamesTest extends AbstractExporterTest implements Consumer { +public class IncludeObjectNamesTest extends AbstractExporterTest + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java index d0e01030..71f9b4ad 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class LowerCaseOutputAndLabelNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java index e42d5d5a..b638239f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class LowerCaseOutputLabelNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java index a0c4e5fb..d91a025b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/LowerCaseOutputNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class LowerCaseOutputNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java index 6abdb65b..72a19fe1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java @@ -20,18 +20,20 @@ import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; -public class MinimalTest extends AbstractExporterTest implements Consumer { +public class MinimalTest extends AbstractExporterTest + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java index 8284d54c..8dab053e 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java @@ -20,18 +20,20 @@ import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; -public class OptionalValueMBeanTest extends AbstractExporterTest implements Consumer { +public class OptionalValueMBeanTest extends AbstractExporterTest + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java index e55970ae..f969ae45 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class WhitelistAndBlacklistObjectNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java index 9334c608..261851c0 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/WhitelistObjectNamesTest.java @@ -20,18 +20,19 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Locale; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class WhitelistObjectNamesTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Collection metrics = MetricsParser.parseCollection(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java index 05ee76f1..b60e92ad 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java @@ -27,23 +27,24 @@ import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import java.util.ArrayList; import java.util.Collection; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.ClassContext; +import org.antublue.verifyica.api.Verifyica; import org.testcontainers.containers.Network; -public abstract class AbstractExporterTest implements Consumer { +public abstract class AbstractExporterTest + implements BiConsumer { - protected Network network; - - @TestEngine.Argument public ExporterTestEnvironment exporterTestEnvironment; + public static final String NETWORK = "network"; /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { Collection collection = new ArrayList<>(); @@ -60,65 +61,87 @@ public static Stream arguments() { return collection.stream(); } - @TestEngine.Prepare - public final void prepare() { + @Verifyica.Prepare + public static void prepare(ClassContext classContext) { // Create a Network and get the id to force the network creation - network = Network.newNetwork(); + Network network = Network.newNetwork(); network.getId(); + + classContext.getStore().put(NETWORK, network); } - @TestEngine.BeforeAll - public void beforeAll() { - exporterTestEnvironment.initialize(getClass(), network); + @Verifyica.BeforeAll + public void beforeAll(ArgumentContext argumentContext) { + Network network = argumentContext.getClassContext().getStore().get(NETWORK); + + argumentContext + .getArgumentPayload(ExporterTestEnvironment.class) + .initialize(getClass(), network); } - @TestEngine.Test - public void testHealthy() { + @Verifyica.Test + public void testHealthy(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + new HttpHealthyRequest() .send(exporterTestEnvironment.getHttpClient()) .accept(HttpResponseAssertions::assertHttpHealthyResponse); } - @TestEngine.Test - public void testMetrics() { - new HttpMetricsRequest().send(exporterTestEnvironment.getHttpClient()).accept(this); + @Verifyica.Test + public void testMetrics(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + + accept( + exporterTestEnvironment, + new HttpMetricsRequest().send(exporterTestEnvironment.getHttpClient())); } - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { - new HttpOpenMetricsRequest().send(exporterTestEnvironment.getHttpClient()).accept(this); + @Verifyica.Test + public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + + accept( + exporterTestEnvironment, + new HttpOpenMetricsRequest().send(exporterTestEnvironment.getHttpClient())); } - @TestEngine.Test - public void testMetricsPrometheusFormat() { - new HttpPrometheusMetricsRequest() - .send(exporterTestEnvironment.getHttpClient()) - .accept(this); + @Verifyica.Test + public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + + accept( + exporterTestEnvironment, + new HttpPrometheusMetricsRequest().send(exporterTestEnvironment.getHttpClient())); } - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { - new HttpPrometheusProtobufMetricsRequest() - .send(exporterTestEnvironment.getHttpClient()) - .accept(this); + @Verifyica.Test + public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + + accept( + exporterTestEnvironment, + new HttpPrometheusProtobufMetricsRequest() + .send(exporterTestEnvironment.getHttpClient())); } - @TestEngine.AfterAll - public void afterAll() { + @Verifyica.AfterAll + public void afterAll(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); if (exporterTestEnvironment != null) { exporterTestEnvironment.destroy(); - exporterTestEnvironment = null; } } - @TestEngine.Conclude - public final void conclude() { + @Verifyica.Conclude + public static void conclude(ClassContext classContext) { + Network network = classContext.getStore().remove(NETWORK); if (network != null) { network.close(); - network = null; } } @Override - public abstract void accept(HttpResponse httpResponse); + public abstract void accept( + ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java index f747a907..ba0f45ce 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java @@ -4,7 +4,7 @@ import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpClient; import java.time.Duration; -import org.antublue.test.engine.api.Argument; +import org.antublue.verifyica.api.Argument; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; @@ -102,9 +102,9 @@ public void initialize(Class testClass, Network network) { case Standalone: { standaloneApplicationContainer = createStandaloneApplicationContainer(); - standaloneExporterContainer = createStandaloneExporterContainer(); - standaloneApplicationContainer.start(); + + standaloneExporterContainer = createStandaloneExporterContainer(); standaloneExporterContainer.start(); httpClient = createHttpClient(standaloneExporterContainer, baseUrl, 8888); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index d8bf0df7..7035dbe7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -34,13 +34,14 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.function.Function; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.Verifyica; public class CompleteHttpServerConfigurationTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { private static final String BASE_URL = "https://localhost"; @@ -59,7 +60,7 @@ public class CompleteHttpServerConfigurationTest extends AbstractExporterTest * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 @@ -80,8 +81,10 @@ public ExporterTestEnvironment apply( }); } - @TestEngine.Test - public void testHealthy() { + @Verifyica.Test + public void testHealthy(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { final AtomicInteger code = new AtomicInteger(HttpResponse.UNAUTHORIZED); @@ -98,8 +101,10 @@ public void testHealthy() { } } - @TestEngine.Test - public void testMetrics() { + @Verifyica.Test + public void testMetrics(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { final AtomicInteger code = new AtomicInteger(HttpResponse.UNAUTHORIZED); @@ -115,15 +120,17 @@ public void testMetrics() { response -> { assertHttpResponseCode(response, code.get()); if (response.statusCode() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); } } } - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { + @Verifyica.Test + public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { final AtomicInteger code = new AtomicInteger(HttpResponse.UNAUTHORIZED); @@ -139,15 +146,17 @@ public void testMetricsOpenMetricsFormat() { response -> { assertHttpResponseCode(response, code.get()); if (response.statusCode() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); } } } - @TestEngine.Test - public void testMetricsPrometheusFormat() { + @Verifyica.Test + public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { final AtomicInteger code = new AtomicInteger(HttpResponse.UNAUTHORIZED); @@ -163,15 +172,17 @@ public void testMetricsPrometheusFormat() { response -> { assertHttpResponseCode(response, code.get()); if (response.statusCode() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); } } } - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { + @Verifyica.Test + public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { final AtomicInteger code = new AtomicInteger(HttpResponse.UNAUTHORIZED); @@ -187,7 +198,7 @@ public void testMetricsPrometheusProtobufFormat() { response -> { assertHttpResponseCode(response, code.get()); if (response.statusCode() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); } @@ -195,7 +206,7 @@ public void testMetricsPrometheusProtobufFormat() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java index 83b0183e..ab1fbaaf 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java @@ -20,6 +20,7 @@ import io.prometheus.jmx.test.common.AbstractExporterTest; import io.prometheus.jmx.test.common.AuthenticationCredentials; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; import io.prometheus.jmx.test.support.http.HttpHealthyRequest; import io.prometheus.jmx.test.support.http.HttpMetricsRequest; @@ -30,7 +31,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.atomic.AtomicInteger; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.Verifyica; public abstract class AbstractBasicAuthenticationTest extends AbstractExporterTest { @@ -61,8 +63,10 @@ public static Collection getAuthenticationCredentials return collection; } - @TestEngine.Test - public void testHealthy() { + @Verifyica.Test + public void testHealthy(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + getAuthenticationCredentials() .forEach( authenticationTestArguments -> { @@ -83,8 +87,10 @@ public void testHealthy() { }); } - @TestEngine.Test - public void testMetrics() { + @Verifyica.Test + public void testMetrics(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + getAuthenticationCredentials() .forEach( authenticationCredentials -> { @@ -103,14 +109,16 @@ public void testMetrics() { response -> { assertHttpResponseCode(response, code.get()); if (code.get() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); }); } - @TestEngine.Test - public void testMetricsOpenMetricsFormat() { + @Verifyica.Test + public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + getAuthenticationCredentials() .forEach( authenticationCredentials -> { @@ -129,14 +137,16 @@ public void testMetricsOpenMetricsFormat() { response -> { assertHttpResponseCode(response, code.get()); if (code.get() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); }); } - @TestEngine.Test - public void testMetricsPrometheusFormat() { + @Verifyica.Test + public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + getAuthenticationCredentials() .forEach( authenticationCredentials -> { @@ -155,14 +165,16 @@ public void testMetricsPrometheusFormat() { response -> { assertHttpResponseCode(response, code.get()); if (code.get() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); }); } - @TestEngine.Test - public void testMetricsPrometheusProtobufFormat() { + @Verifyica.Test + public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { + ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + getAuthenticationCredentials() .forEach( authenticationCredentials -> { @@ -181,7 +193,7 @@ public void testMetricsPrometheusProtobufFormat() { response -> { assertHttpResponseCode(response, code.get()); if (code.get() == HttpResponse.OK) { - accept(response); + accept(exporterTestEnvironment, response); } }); }); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java index e9541e6a..1f07efbd 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java @@ -27,26 +27,26 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class BasicAuthenticationPBKDF2WithHmacSHA1Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java index 37f1dd8f..b4294556 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java @@ -27,26 +27,26 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class BasicAuthenticationPBKDF2WithHmacSHA256Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java index cb5d794a..ed18ea75 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -27,26 +27,26 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class BasicAuthenticationPBKDF2WithHmacSHA512Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() .filter(new PBKDF2WithHmacExporterTestEnvironmentFilter()); } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java index 75c0276b..1c9aa23b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java @@ -19,19 +19,20 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class BasicAuthenticationPlaintextTest extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java index 3a7c9809..e8828269 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java @@ -19,19 +19,20 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class BasicAuthenticationSHA1Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java index 4fdc6c79..24173526 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java @@ -19,19 +19,20 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class BasicAuthenticationSHA256Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java index 861a96ff..e609cdc4 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java @@ -19,19 +19,20 @@ import static io.prometheus.jmx.test.support.http.HttpResponseAssertions.assertHttpMetricsResponse; import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class BasicAuthenticationSHA512Test extends AbstractBasicAuthenticationTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java index c8a829f8..15b4ca13 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/AbstractSSLTest.java @@ -4,7 +4,7 @@ import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.http.authentication.AbstractBasicAuthenticationTest; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public abstract class AbstractSSLTest extends AbstractExporterTest { @@ -15,7 +15,7 @@ public abstract class AbstractSSLTest extends AbstractExporterTest { * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { return AbstractBasicAuthenticationTest.arguments() .map(exporterTestEnvironment -> exporterTestEnvironment.setBaseUrl(BASE_URL)); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java index c116eb23..1d456bc5 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -27,19 +27,20 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test - extends AbstractBasicAuthenticationTest implements Consumer { + extends AbstractBasicAuthenticationTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 @@ -53,7 +54,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java index 7c4f2d70..5165bb01 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java @@ -26,19 +26,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class SSLWithJKSKeyStoreMultipleCertificatesTest extends AbstractSSLTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 @@ -52,7 +52,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java index bc07b468..50c1cdd3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java @@ -26,18 +26,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; -public class SSLWithJKSKeyStoreTest extends AbstractSSLTest implements Consumer { +public class SSLWithJKSKeyStoreTest extends AbstractSSLTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 @@ -51,7 +52,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java index 4a11e93e..de020732 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java @@ -26,18 +26,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; -public class SSLWithJKSKeyStoreTest2 extends AbstractSSLTest implements Consumer { +public class SSLWithJKSKeyStoreTest2 extends AbstractSSLTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter eclipse-temurin:8 based Alpine images due to missing TLS cipher suites // https://github.com/adoptium/temurin-build/issues/3002 @@ -51,7 +52,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java index 7c359532..7c052ae8 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java @@ -27,19 +27,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class SSLWithPKCS12KeyStoreMultipleCertificatesTest extends AbstractSSLTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites @@ -48,7 +48,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java index 7ca0d59a..b553bfaa 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java @@ -27,18 +27,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; -public class SSLWithPKCS12KeyStoreTest extends AbstractSSLTest implements Consumer { +public class SSLWithPKCS12KeyStoreTest extends AbstractSSLTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites @@ -47,7 +48,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java index 4b329fec..84d09a7a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java @@ -27,18 +27,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; -public class SSLWithPKCS12KeyStoreTest2 extends AbstractSSLTest implements Consumer { +public class SSLWithPKCS12KeyStoreTest2 extends AbstractSSLTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter Java versions that don't support the PKCS12 keystore // format or don't support the required TLS cipher suites @@ -47,7 +48,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java index 97c51ff2..5b20ee6b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java @@ -20,19 +20,20 @@ import static io.prometheus.jmx.test.support.metrics.MetricAssertion.assertMetric; import io.prometheus.jmx.test.common.AbstractExporterTest; +import io.prometheus.jmx.test.common.ExporterTestEnvironment; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; public class ThreadsConfigurationTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 4a9c129c..369ba55f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -6,6 +6,8 @@ import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpRequest; import io.prometheus.jmx.test.support.http.HttpResponse; +import io.prometheus.jmx.test.support.throttle.ExponentialBackoffThrottle; +import io.prometheus.jmx.test.support.throttle.Throttle; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -14,27 +16,23 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; -import org.antublue.test.engine.extras.throttle.ExponentialBackoffThrottle; -import org.antublue.test.engine.extras.throttle.Throttle; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.Verifyica; import org.junit.jupiter.api.Assertions; import org.testcontainers.containers.Network; import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; /** Class to implement OpenTelemetryTest */ -@TestEngine.ParallelArgumentTest public class OpenTelemetryTest { - private Network network; - - @TestEngine.Argument public OpenTelemetryTestEnvironment openTelemetryTestEnvironment; + public static final String NETWORK = "network"; /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier(parallelism = 10) public static Stream arguments() { Collection openTelemetryTestEnvironments = new ArrayList<>(); @@ -57,27 +55,31 @@ public static Stream arguments() { return openTelemetryTestEnvironments.stream(); } - @TestEngine.Prepare - public void prepare() { + @Verifyica.BeforeAll + public void beforeAll(ArgumentContext argumentContext) { // Create a Network and get the id to force the network creation - network = Network.newNetwork(); + Network network = Network.newNetwork(); network.getId(); - } - @TestEngine.BeforeAll - public void beforeAll() { - openTelemetryTestEnvironment.initialize(getClass(), network); + argumentContext.getStore().put(NETWORK, network); + + argumentContext + .getArgumentPayload(OpenTelemetryTestEnvironment.class) + .initialize(getClass(), network); } /** Method to test that Prometheus is up */ - @TestEngine.Test - @TestEngine.Order(order = 0) - public void testIsPrometheusUp() { + @Verifyica.Test + @Verifyica.Order(order = 0) + public void testIsPrometheusUp(ArgumentContext argumentContext) { + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getArgumentPayload(); + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicBoolean success = new AtomicBoolean(); for (int i = 0; i < 10; i++) { - sendPrometheusQuery("up") + sendPrometheusQuery(openTelemetryTestEnvironment, "up") .accept( httpResponse -> { assertThat(httpResponse).isNotNull(); @@ -111,65 +113,53 @@ public void testIsPrometheusUp() { } /** Method to test that metrics exist in Prometheus */ - @TestEngine.Test - public void testPrometheusHasMetrics() { + @Verifyica.Test + public void testPrometheusHasMetrics(ArgumentContext argumentContext) { + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getArgumentPayload(); + boolean isJmxExporterModeJavaStandalone = openTelemetryTestEnvironment.getJmxExporterMode() == JmxExporterMode.Standalone; ExpectedMetricsNames.getMetricsNames().stream() .filter( - metricName -> { - if (isJmxExporterModeJavaStandalone - && (metricName.startsWith("jvm_") - || metricName.startsWith("process_"))) { - return false; - } - return true; - }) + metricName -> + !isJmxExporterModeJavaStandalone + || (!metricName.startsWith("jvm_") + && !metricName.startsWith("process_"))) .forEach( metricName -> { - Double value = getPrometheusMetric(metricName); + Double value = + getPrometheusMetric(openTelemetryTestEnvironment, metricName); assertThat(value).as("metricName [%s]", metricName).isNotNull(); assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); }); } - @TestEngine.AfterAll - public void afterAll() { - openTelemetryTestEnvironment.destroy(); - } + @Verifyica.AfterAll + public void afterAll(ArgumentContext argumentContext) { + argumentContext.getArgumentPayload(OpenTelemetryTestEnvironment.class).destroy(); - @TestEngine.Conclude - public void conclude() { + Network network = argumentContext.getStore().remove(NETWORK); if (network != null) { network.close(); - network = null; } } /** * Method to get a Prometheus metric * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment * @param metricName metricName * @return the metric value, or null if it doesn't exist */ - protected Double getPrometheusMetric(String metricName) { - return getPrometheusMetric(metricName, null); - } - - /** - * Method to get a Prometheus metrics - * - * @param metricName metricName - * @param labels labels - * @return the metric value, or null if it doesn't exist - */ - protected Double getPrometheusMetric(String metricName, String[] labels) { + protected Double getPrometheusMetric( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String metricName) { Throttle throttle = new ExponentialBackoffThrottle(100, 6400); AtomicReference value = new AtomicReference<>(); for (int i = 0; i < 10; i++) { - sendPrometheusQuery(metricName) + sendPrometheusQuery(openTelemetryTestEnvironment, metricName) .accept( httpResponse -> { assertThat(httpResponse).isNotNull(); @@ -196,21 +186,26 @@ protected Double getPrometheusMetric(String metricName, String[] labels) { /** * Method to send a Prometheus query * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment * @param query query * @return an HttpResponse */ - protected HttpResponse sendPrometheusQuery(String query) { + protected HttpResponse sendPrometheusQuery( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String query) { return sendRequest( + openTelemetryTestEnvironment, "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); } /** - * Method to send an Http GET request + * Method to send a Http GET request * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment * @param path path * @return an HttpResponse */ - protected HttpResponse sendRequest(String path) { + protected HttpResponse sendRequest( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String path) { return openTelemetryTestEnvironment.getPrometheusHttpClient().send(new HttpRequest(path)); } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 9fc13937..4788192a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -3,8 +3,13 @@ import com.github.dockerjava.api.model.Ulimit; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpClient; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.time.Duration; -import org.antublue.test.engine.api.Argument; +import java.util.ArrayList; +import java.util.List; +import org.antublue.verifyica.api.Argument; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; @@ -156,45 +161,66 @@ public void destroy() { * @return the return value */ private GenericContainer createPrometheusContainer() { - return new GenericContainer<>(prometheusDockerImage) - .withClasspathResourceMapping( - testClass.getName().replace(".", "/") - + "/" - + jmxExporterMode - + "/prometheus.yml", - "/etc/prometheus/prometheus.yml", - BindMode.READ_ONLY) - .withWorkingDirectory("/prometheus") - .withCommand( - "--config.file=/etc/prometheus/prometheus.yml", - "--storage.tsdb.path=/prometheus", - "--web.console.libraries=/usr/share/prometheus/console_libraries", - "--web.console.templates=/usr/share/prometheus/consoles", - "--enable-feature=otlp-write-receiver") - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withMemory(MEMORY_BYTES) - .withMemorySwap(MEMORY_SWAP_BYTES)) - .withCreateContainerCmdModifier( - c -> - c.getHostConfig() - .withUlimits( - new Ulimit[] { - new Ulimit("nofile", 65536L, 65536L) - })) - .withExposedPorts(9090) - .withLogConsumer( - outputFrame -> { - String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); - if (!string.isBlank()) { - System.out.println(string); - } - }) - .withNetwork(network) - .withNetworkAliases("prometheus") - .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)); + List commands = new ArrayList<>(); + + commands.add("--config.file=/etc/prometheus/prometheus.yaml"); + commands.add("--storage.tsdb.path=/prometheus"); + commands.add("--web.console.libraries=/usr/share/prometheus/console_libraries"); + commands.add("--web.console.templates=/usr/share/prometheus/consoles"); + commands.add("--enable-feature=otlp-write-receiver"); + + String webYml = + "/" + testClass.getName().replace(".", "/") + "/" + jmxExporterMode + "/web.yaml"; + + boolean hasWebYaml = hasResource(webYml); + + if (hasWebYaml) { + commands.add("--web.config.file=/etc/prometheus/web.yaml"); + } + + GenericContainer genericContainer = + new GenericContainer<>(prometheusDockerImage) + .withClasspathResourceMapping( + testClass.getName().replace(".", "/") + + "/" + + jmxExporterMode + + "/prometheus.yaml", + "/etc/prometheus/prometheus.yaml", + BindMode.READ_ONLY) + .withWorkingDirectory("/prometheus") + .withCommand(commands.toArray(new String[0])) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withMemory(MEMORY_BYTES) + .withMemorySwap(MEMORY_SWAP_BYTES)) + .withCreateContainerCmdModifier( + c -> + c.getHostConfig() + .withUlimits( + new Ulimit[] { + new Ulimit("nofile", 65536L, 65536L) + })) + .withExposedPorts(9090) + .withLogConsumer( + outputFrame -> { + String string = + outputFrame.getUtf8StringWithoutLineEnding().trim(); + if (!string.isBlank()) { + System.out.println(string); + } + }) + .withNetwork(network) + .withNetworkAliases("prometheus") + .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) + .withStartupTimeout(Duration.ofMillis(30000)); + + if (hasWebYaml) { + genericContainer.withClasspathResourceMapping( + webYml, "/etc/prometheus/web.yaml", BindMode.READ_ONLY); + } + + return genericContainer; } /** @@ -331,4 +357,30 @@ private static HttpClient createPrometheusHttpClient( GenericContainer genericContainer, String baseUrl, int mappedPort) { return new HttpClient(baseUrl + ":" + genericContainer.getMappedPort(mappedPort)); } + + /** + * Method to determine if a resource exists + * + * @param resource resource + * @return true if the resource exists, else false + */ + private static boolean hasResource(String resource) { + boolean hasResource = false; + + try (BufferedReader bufferedReader = + new BufferedReader( + new InputStreamReader( + OpenTelemetryTestEnvironment.class.getResourceAsStream(resource), + StandardCharsets.UTF_8))) { + String line = bufferedReader.readLine(); + if (line != null) { + hasResource = true; + } + + } catch (Throwable t) { + // DO NOTHING + } + + return hasResource; + } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java index f475efc6..fa43020f 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/PrometheusDockerImages.java @@ -1,25 +1,48 @@ +/* + * Copyright (C) 2023 The Prometheus jmx_exporter Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.prometheus.jmx.test.opentelemetry; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.Collections; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Predicate; /** Class to implement PrometheusDockerImages */ -public class PrometheusDockerImages { - - private static final Collection PROMETHEUS_DOCKER_IMAGES; - - // Build the immutable list of Docker image names - static { - PROMETHEUS_DOCKER_IMAGES = - List.of( - "prom/prometheus:v2.47.2", - "prom/prometheus:v2.48.1", - "prom/prometheus:v2.49.1", - "prom/prometheus:v2.50.1", - "prom/prometheus:v2.51.2", - "prom/prometheus:v2.52.0", - "prom/prometheus:v2.53.1"); - } +public final class PrometheusDockerImages { + + private static final String DOCKER_IMAGES_CONFIGURATION = "prometheus.docker.images"; + + private static final String DOCKER_IMAGES_RESOURCE = "/prometheus-docker-images.txt"; + + private static final String SMOKE_TEST_DOCKER_IMAGES_RESOURCE = + "/smoke-test-prometheus-docker-images.txt"; + + private static String[] ALL_DOCKER_IMAGE_NAMES; + + private static String[] SMOKE_TEST_DOCKER_IMAGES; + + /** Predicate to accept all Docker image names */ + public static final Predicate ACCEPT_ALL = name -> true; /** Constructor */ private PrometheusDockerImages() { @@ -27,11 +50,104 @@ private PrometheusDockerImages() { } /** - * Method to get List of all Docker image names + * Method to get Collection of all Docker image names * - * @return the List of Docker image names + * @return the Collection of Docker image names */ public static Collection names() { - return PROMETHEUS_DOCKER_IMAGES; + return names(ACCEPT_ALL); + } + + /** + * Method to get List of Docker image names filtered by a Predicate + * + * @param predicate predicate + * @return the List of Docker image names + */ + public static Collection names(Predicate predicate) { + Objects.requireNonNull(predicate); + + synchronized (PrometheusDockerImages.class) { + if (ALL_DOCKER_IMAGE_NAMES == null) { + ALL_DOCKER_IMAGE_NAMES = load(DOCKER_IMAGES_RESOURCE); + } + if (SMOKE_TEST_DOCKER_IMAGES == null) { + SMOKE_TEST_DOCKER_IMAGES = load(SMOKE_TEST_DOCKER_IMAGES_RESOURCE); + } + } + + String[] dockerImageNames; + + String dockerImageNameValue = + System.getenv( + DOCKER_IMAGES_CONFIGURATION.toUpperCase(Locale.ENGLISH).replace('.', '_')); + + if (dockerImageNameValue != null) { + dockerImageNameValue = dockerImageNameValue.trim(); + if (dockerImageNameValue.isBlank()) { + dockerImageNameValue = null; + } + } + + if (dockerImageNameValue == null) { + dockerImageNameValue = System.getProperty(DOCKER_IMAGES_CONFIGURATION); + if (dockerImageNameValue != null) { + if (dockerImageNameValue.isBlank()) { + dockerImageNameValue = null; + } + } + } + + if (dockerImageNameValue == null) { + dockerImageNames = SMOKE_TEST_DOCKER_IMAGES; + } else if (dockerImageNameValue.equalsIgnoreCase("ALL")) { + dockerImageNames = ALL_DOCKER_IMAGE_NAMES; + } else { + dockerImageNames = dockerImageNameValue.split("\\s+"); + } + + Collection dockerImageNamesCollection = new ArrayList<>(); + for (String dockerImageName : dockerImageNames) { + if (predicate.test(dockerImageName)) { + dockerImageNamesCollection.add(dockerImageName); + } + } + + return Collections.unmodifiableCollection(dockerImageNamesCollection); + } + + /** + * Method to load the list of Docker image names from a resource + * + * @param resource resource + * @return the String array of lines + */ + private static String[] load(String resource) { + Collection dockerImageNames = new ArrayList<>(); + BufferedReader bufferedReader; + + try { + bufferedReader = + new BufferedReader( + new InputStreamReader( + PrometheusDockerImages.class.getResourceAsStream(resource), + StandardCharsets.UTF_8)); + + while (true) { + String line = bufferedReader.readLine(); + + if (line == null) { + break; + } + + if (!line.trim().isEmpty() && !line.trim().startsWith("#")) { + dockerImageNames.add(line.trim()); + } + } + + return dockerImageNames.toArray(new String[0]); + } catch (IOException e) { + throw new RuntimeException("Exception reading resource " + DOCKER_IMAGES_RESOURCE, e); + } } } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java new file mode 100644 index 00000000..daf7fb38 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java @@ -0,0 +1,229 @@ +package io.prometheus.jmx.test.opentelemetry.authentication; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.prometheus.jmx.test.opentelemetry.ExpectedMetricsNames; +import io.prometheus.jmx.test.opentelemetry.OpenTelemetryTestEnvironment; +import io.prometheus.jmx.test.opentelemetry.PrometheusDockerImages; +import io.prometheus.jmx.test.support.JavaDockerImages; +import io.prometheus.jmx.test.support.JmxExporterMode; +import io.prometheus.jmx.test.support.http.HttpBasicAuthenticationCredentials; +import io.prometheus.jmx.test.support.http.HttpRequest; +import io.prometheus.jmx.test.support.http.HttpResponse; +import io.prometheus.jmx.test.support.throttle.ExponentialBackoffThrottle; +import io.prometheus.jmx.test.support.throttle.Throttle; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Stream; +import org.antublue.verifyica.api.ArgumentContext; +import org.antublue.verifyica.api.Verifyica; +import org.junit.jupiter.api.Assertions; +import org.testcontainers.containers.Network; +import org.testcontainers.shaded.org.yaml.snakeyaml.Yaml; + +/** Class to implement OpenTelemetryBasicAuthenticationTest */ +public class OpenTelemetryBasicAuthenticationTest { + + private static final String NETWORK = "network"; + private static final String VALID_USER = "Prometheus"; + private static final String VALUE_PASSWORD = "secret"; + + /** + * Method to get the Stream of test environments + * + * @return the Stream of test environments + */ + @Verifyica.ArgumentSupplier(parallelism = 10) + public static Stream arguments() { + Collection openTelemetryTestEnvironments = new ArrayList<>(); + + PrometheusDockerImages.names() + .forEach( + prometheusDockerImage -> + JavaDockerImages.names() + .forEach( + javaDockerImageName -> { + for (JmxExporterMode jmxExporterMode : + JmxExporterMode.values()) { + openTelemetryTestEnvironments.add( + new OpenTelemetryTestEnvironment( + prometheusDockerImage, + javaDockerImageName, + jmxExporterMode)); + } + })); + + return openTelemetryTestEnvironments.stream(); + } + + @Verifyica.BeforeAll + public void beforeAll(ArgumentContext argumentContext) { + // Create a Network and get the id to force the network creation + Network network = Network.newNetwork(); + network.getId(); + + argumentContext.getStore().put(NETWORK, network); + + argumentContext + .getArgumentPayload(OpenTelemetryTestEnvironment.class) + .initialize(getClass(), network); + } + + /** + * Method to test that Prometheus is up + * + * @param argumentContext argumentContext + */ + @Verifyica.Test + @Verifyica.Order(order = 0) + public void testIsPrometheusUp(ArgumentContext argumentContext) { + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getArgumentPayload(); + + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + AtomicBoolean success = new AtomicBoolean(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery(openTelemetryTestEnvironment, "up") + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + + if (httpResponse.statusCode() != 200) { + return; + } + + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + Map map = + new Yaml().load(httpResponse.body().string()); + + String status = (String) map.get("status"); + assertThat(status).isEqualTo("success"); + + success.set(true); + }); + + if (success.get()) { + break; + } + + throttle.throttle(); + } + + if (!success.get()) { + Assertions.fail("Prometheus is not up"); + } + } + + /** + * Method to test that metrics exist in Prometheus + * + * @param argumentContext argumentContext + */ + @Verifyica.Test + public void testPrometheusHasMetrics(ArgumentContext argumentContext) { + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getArgumentPayload(); + + ExpectedMetricsNames.getMetricsNames().stream() + .filter( + metricName -> + (openTelemetryTestEnvironment.getJmxExporterMode() + != JmxExporterMode.Standalone + || !metricName.startsWith("jvm_")) + && !metricName.startsWith("process_")) + .forEach( + metricName -> { + Double value = + getPrometheusMetric(openTelemetryTestEnvironment, metricName); + assertThat(value).as("metricName [%s]", metricName).isNotNull(); + assertThat(value).as("metricName [%s]", metricName).isEqualTo(1); + }); + } + + @Verifyica.AfterAll + public void afterAll(ArgumentContext argumentContext) { + argumentContext.getArgumentPayload(OpenTelemetryTestEnvironment.class).destroy(); + + Network network = argumentContext.getStore().remove(NETWORK); + if (network != null) { + network.close(); + } + } + + /** + * Method to get a Prometheus metric + * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment + * @param metricName metricName + * @return the metric value, or null if it doesn't exist + */ + protected Double getPrometheusMetric( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String metricName) { + Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + AtomicReference value = new AtomicReference<>(); + + for (int i = 0; i < 10; i++) { + sendPrometheusQuery(openTelemetryTestEnvironment, metricName) + .accept( + httpResponse -> { + assertThat(httpResponse).isNotNull(); + assertThat(httpResponse.statusCode()).isEqualTo(200); + assertThat(httpResponse.body()).isNotNull(); + assertThat(httpResponse.body().string()).isNotNull(); + + // TODO parse response and return value + if (httpResponse.body().string().contains(metricName)) { + value.set(1.0); + } + }); + + if (value.get() != null) { + break; + } + + throttle.throttle(); + } + + return value.get(); + } + + /** + * Method to send a Prometheus query + * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment + * @param query query + * @return an HttpResponse + */ + protected HttpResponse sendPrometheusQuery( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String query) { + return sendRequest( + openTelemetryTestEnvironment, + "/api/v1/query?query=" + URLEncoder.encode(query, StandardCharsets.UTF_8)); + } + + /** + * Method to send a Http GET request + * + * @param openTelemetryTestEnvironment openTelemetryTestEnvironment + * @param path path + * @return an HttpResponse + */ + protected HttpResponse sendRequest( + OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String path) { + return openTelemetryTestEnvironment + .getPrometheusHttpClient() + .send( + new HttpRequest(path) + .credentials( + new HttpBasicAuthenticationCredentials( + VALID_USER, VALUE_PASSWORD))); + } +} diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java index 8a2bfe94..d6cc408d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java @@ -27,18 +27,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; -public class MinimalRMISSLTest extends AbstractExporterTest implements Consumer { +public class MinimalRMISSLTest extends AbstractExporterTest + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter the arguments.. // @@ -61,7 +62,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java index af517fb0..47847a56 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java @@ -27,19 +27,19 @@ import io.prometheus.jmx.test.support.metrics.MetricsParser; import java.util.Collection; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.antublue.test.engine.api.TestEngine; +import org.antublue.verifyica.api.Verifyica; public class RMIRegistrySSLDisabledTest extends AbstractExporterTest - implements Consumer { + implements BiConsumer { /** * Method to get the Stream of test environments * * @return the Stream of test environments */ - @TestEngine.ArgumentSupplier + @Verifyica.ArgumentSupplier public static Stream arguments() { // Filter the arguments.. // @@ -62,7 +62,7 @@ public static Stream arguments() { } @Override - public void accept(HttpResponse httpResponse) { + public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse httpResponse) { assertHttpMetricsResponse(httpResponse); Map> metrics = MetricsParser.parseMap(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/prometheus.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yaml similarity index 100% rename from integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yml rename to integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/prometheus.yaml diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh new file mode 100644 index 00000000..9e5717d6 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml new file mode 100644 index 00000000..dea4916f --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/exporter.yaml @@ -0,0 +1,8 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 + headers: + Authorization: "Basic UHJvbWV0aGV1czpzZWNyZXQ=" +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/prometheus.yaml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml new file mode 100644 index 00000000..1aecd62a --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/web.yaml @@ -0,0 +1,2 @@ +basic_auth_users: + Prometheus: $2y$10$ocnnaD337.WxiugU0ho92eBkX4Eq7/ZntVgwhgwlW5m2EvnOC9n62 \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh new file mode 100644 index 00000000..80c2b344 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/application.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -Dcom.sun.management.jmxremote=true \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=9999 \ + -Dcom.sun.management.jmxremote.registry.ssl=false \ + -Dcom.sun.management.jmxremote.rmi.port=9999 \ + -Dcom.sun.management.jmxremote.ssl.need.client.auth=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh new file mode 100644 index 00000000..a04f3b63 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +java \ + -Xmx512M \ + -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml new file mode 100644 index 00000000..ddc06c96 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.yaml @@ -0,0 +1,9 @@ +openTelemetry: + endpoint: http://prometheus:9090/api/v1/otlp + protocol: http/protobuf + interval: 1 + headers: + Authorization: "Basic UHJvbWV0aGV1czpzZWNyZXQ=" +hostPort: application:9999 +rules: + - pattern: ".*" \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml new file mode 100644 index 00000000..5b174f8e --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/prometheus.yaml @@ -0,0 +1,4 @@ +global: + scrape_interval: 15s # Default scrape interval, not used since there are no scrape targets + +scrape_configs: [] # Empty scrape_configs means no targets to scrape \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml new file mode 100644 index 00000000..1aecd62a --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/web.yaml @@ -0,0 +1,2 @@ +basic_auth_users: + Prometheus: $2y$10$ocnnaD337.WxiugU0ho92eBkX4Eq7/ZntVgwhgwlW5m2EvnOC9n62 \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/prometheus-docker-images.txt b/integration_test_suite/integration_tests/src/test/resources/prometheus-docker-images.txt new file mode 100644 index 00000000..4f0b28b8 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/prometheus-docker-images.txt @@ -0,0 +1,7 @@ +prom/prometheus:v2.47.2 +prom/prometheus:v2.48.1 +prom/prometheus:v2.49.1 +prom/prometheus:v2.50.1 +prom/prometheus:v2.51.2 +prom/prometheus:v2.52.0 +prom/prometheus:v2.53.1 \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/smoke-test-prometheus-docker-images.txt b/integration_test_suite/integration_tests/src/test/resources/smoke-test-prometheus-docker-images.txt new file mode 100644 index 00000000..6cfaa5a0 --- /dev/null +++ b/integration_test_suite/integration_tests/src/test/resources/smoke-test-prometheus-docker-images.txt @@ -0,0 +1 @@ +prom/prometheus:v2.53.1 \ No newline at end of file diff --git a/integration_test_suite/jmx_example_application/pom.xml b/integration_test_suite/jmx_example_application/pom.xml index 06ff5ae0..3b4f1bf1 100644 --- a/integration_test_suite/jmx_example_application/pom.xml +++ b/integration_test_suite/jmx_example_application/pom.xml @@ -62,7 +62,7 @@ - check + apply compile @@ -164,28 +164,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - diff --git a/jmx_prometheus_common/pom.xml b/jmx_prometheus_common/pom.xml index 7f520deb..57ef7903 100644 --- a/jmx_prometheus_common/pom.xml +++ b/jmx_prometheus_common/pom.xml @@ -52,28 +52,6 @@ - - - - check - - compile - - - - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java new file mode 100644 index 00000000..913ad1ef --- /dev/null +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/configuration/ConvertToMap.java @@ -0,0 +1,41 @@ +package io.prometheus.jmx.common.configuration; + +import io.prometheus.jmx.common.util.Precondition; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +/** + * Class to convert an Object to a Map, throwing a RuntimeException from the Supplier if there is a + * ClassCastException + */ +@SuppressWarnings("unchecked") +public class ConvertToMap implements Function> { + + private final Supplier supplier; + + /** + * Constructor + * + * @param supplier supplier + */ + public ConvertToMap(Supplier supplier) { + Precondition.notNull(supplier); + this.supplier = supplier; + } + + @Override + public Map apply(Object o) { + try { + Map result = new LinkedHashMap<>(); + Map map = (Map) o; + + map.forEach((o1, o2) -> result.put(o1.toString(), o2.toString())); + + return result; + } catch (Throwable t) { + throw supplier.get(); + } + } +} diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java index 8e602a3a..57c6f4c1 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java @@ -3,6 +3,7 @@ import static java.lang.String.format; import io.prometheus.jmx.common.configuration.ConvertToInteger; +import io.prometheus.jmx.common.configuration.ConvertToMap; import io.prometheus.jmx.common.configuration.ConvertToMapAccessor; import io.prometheus.jmx.common.configuration.ConvertToString; import io.prometheus.jmx.common.configuration.ValidateIntegerInRange; @@ -117,12 +118,35 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE + " between greater than 0"))) .orElse(60); - openTelemetryExporter = - OpenTelemetryExporter.builder() - .endpoint(endpoint) - .protocol(protocol) - .intervalSeconds(interval) - .buildAndStart(); + Map headers = + openTelemetryYamlMapAccessor + .get("/headers") + .map( + new ConvertToMap( + ConfigurationException.supplier( + "Invalid configuration for" + + " /openTelemetry/headers" + + " must be a map"))) + .orElse(null); + + OpenTelemetryExporter.Builder openTelemetryExporterBuilder = + OpenTelemetryExporter.builder(); + + openTelemetryExporterBuilder + .endpoint(endpoint) + .protocol(protocol) + .intervalSeconds(interval); + + if (headers != null) { + headers.forEach( + (name, value) -> { + if (name != null && !name.trim().isEmpty()) { + openTelemetryExporterBuilder.header(name, value); + } + }); + } + + openTelemetryExporter = openTelemetryExporterBuilder.buildAndStart(); } } } catch (IOException e) { diff --git a/jmx_prometheus_httpserver/pom.xml b/jmx_prometheus_httpserver/pom.xml index d91be272..e37b51a1 100644 --- a/jmx_prometheus_httpserver/pom.xml +++ b/jmx_prometheus_httpserver/pom.xml @@ -53,7 +53,7 @@ - check + apply compile @@ -273,28 +273,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - diff --git a/jmx_prometheus_javaagent/pom.xml b/jmx_prometheus_javaagent/pom.xml index 34060ebd..df5995ab 100644 --- a/jmx_prometheus_javaagent/pom.xml +++ b/jmx_prometheus_javaagent/pom.xml @@ -53,7 +53,7 @@ - check + apply compile @@ -239,28 +239,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - 1.22.0 - - true - - - - - - - apply - - compile - - - diff --git a/verifyica.properties b/verifyica.properties new file mode 100644 index 00000000..8c0f28ad --- /dev/null +++ b/verifyica.properties @@ -0,0 +1,23 @@ +verifyica.parallelism=100 +#verifyica.thread.type=virtual +#verifyica.thread.type=platform +#verifyica.test.class.shuffle=true +#verifyica.test.class.include.regex= +#verifyica.test.class.exclude.regex= +#verifyica.test.class.tag.include.regex= +#verifyica.test.class.tag.exclude.regex= +#verifyica.test.method.include.regex= +#verifyica.test.method.exclude.regex= +#verifyica.test.method.tag.include.regex= +#verifyica.test.method.tag.exclude.regex= +#verifyica.logger.level=ALL +#verifyica.logger.regex= +#verifyica.console.log.timing=false +#verifyica.console.log.timing.units=seconds +#verifyica.console.log.test.messages=false +#verifyica.console.log.test.message=T +#verifyica.console.log.pass.messages=false +#verifyica.console.log.pass.message=P +#verifyica.console.log.skip.messages=false +#verifyica.console.log.skip.message=S +#verifyica.console.log.fail.message=F From fa64310536eb21e48b9152721255fe257f469b17 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 19 Jul 2024 23:14:41 -0400 Subject: [PATCH 55/77] Added shell scripts Signed-off-by: dhoard --- integration_test_suite/pull-docker-images.sh | 21 ++++++++++++++++ .../pull-prometheus-docker-images.sh | 24 +++++++++++++++++++ .../pull-smoke-test-docker-images.sh | 21 ++++++++++++++++ ...ull-smoke-test-prometheus-docker-images.sh | 24 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100755 integration_test_suite/pull-docker-images.sh create mode 100755 integration_test_suite/pull-prometheus-docker-images.sh create mode 100755 integration_test_suite/pull-smoke-test-docker-images.sh create mode 100755 integration_test_suite/pull-smoke-test-prometheus-docker-images.sh diff --git a/integration_test_suite/pull-docker-images.sh b/integration_test_suite/pull-docker-images.sh new file mode 100755 index 00000000..49bcce7f --- /dev/null +++ b/integration_test_suite/pull-docker-images.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PWD="$PWD" +function exit_trap() { + cd "${PWD}" + echo $? +} +trap exit_trap EXIT +SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd "${SCRIPT_DIRECTORY}" + +function check_exit_code() { + if [ "$?" != "0" ]; + then + echo "Failed to pull Docker image ${1}"; + exit $? + fi +} + +./pull-java-docker-images.sh +./pull-prometheus-docker-images.sh \ No newline at end of file diff --git a/integration_test_suite/pull-prometheus-docker-images.sh b/integration_test_suite/pull-prometheus-docker-images.sh new file mode 100755 index 00000000..586363ce --- /dev/null +++ b/integration_test_suite/pull-prometheus-docker-images.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PWD="$PWD" +function exit_trap() { + cd "${PWD}" + echo $? +} +trap exit_trap EXIT +SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd "${SCRIPT_DIRECTORY}" + +function check_exit_code() { + if [ "$?" != "0" ]; + then + echo "Failed to pull Docker image ${1}"; + exit $? + fi +} + +grep -v '^#' integration_tests/src/test/resources/prometheus-docker-images.txt | while read -r LINE; +do + docker pull "${LINE}" + check_exit_code "${LINE}" +done diff --git a/integration_test_suite/pull-smoke-test-docker-images.sh b/integration_test_suite/pull-smoke-test-docker-images.sh new file mode 100755 index 00000000..a6b0f105 --- /dev/null +++ b/integration_test_suite/pull-smoke-test-docker-images.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PWD="$PWD" +function exit_trap() { + cd "${PWD}" + echo $? +} +trap exit_trap EXIT +SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd "${SCRIPT_DIRECTORY}" + +function check_exit_code() { + if [ "$?" != "0" ]; + then + echo "Failed to pull Docker image ${1}"; + exit $? + fi +} + +./pull-smoke-test-java-docker-images.sh +./pull-smoke-test-prometheus-docker-images.sh \ No newline at end of file diff --git a/integration_test_suite/pull-smoke-test-prometheus-docker-images.sh b/integration_test_suite/pull-smoke-test-prometheus-docker-images.sh new file mode 100755 index 00000000..fec23a4f --- /dev/null +++ b/integration_test_suite/pull-smoke-test-prometheus-docker-images.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PWD="$PWD" +function exit_trap() { + cd "${PWD}" + echo $? +} +trap exit_trap EXIT +SCRIPT_DIRECTORY=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd "${SCRIPT_DIRECTORY}" + +function check_exit_code() { + if [ "$?" != "0" ]; + then + echo "Failed to pull Docker image ${1}"; + exit $? + fi +} + +grep -v '^#' integration_tests/src/test/resources/smoke-test-prometheus-docker-images.txt | while read -r LINE; +do + docker pull "${LINE}" + check_exit_code "${LINE}" +done From e24afac305efc1c6f5d5ac075777af4e75684571 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 19 Jul 2024 23:15:10 -0400 Subject: [PATCH 56/77] Changed to use Verifyica test engine Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 3fa91ffe..745ab5ed 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.1 + 0.0.2 From 4409507ad94705d881fe3e6dac34e7bcbc503f2e Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 19 Jul 2024 23:15:34 -0400 Subject: [PATCH 57/77] Added Verifyica configuration properties Signed-off-by: dhoard --- verifyica.properties | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/verifyica.properties b/verifyica.properties index 8c0f28ad..661a374a 100644 --- a/verifyica.properties +++ b/verifyica.properties @@ -1,6 +1,19 @@ -verifyica.parallelism=100 -#verifyica.thread.type=virtual -#verifyica.thread.type=platform +#verifyica.engine.parallelism=48 +#verifyica.engine.executor=virtual +#verifyica.engine.logger.level=ALL +#verifyica.engine.logger.regex= +#verifyica.engine.thread.type=platform +#verifyica.engine.interceptors.include.regex= +#verifyica.engine.interceptors.exclude.regex= +#verifyica.maven.plugin.log.timing=false +#verifyica.maven.plugin.log.timing.units=seconds +#verifyica.maven.plugin.log.test.messages=false +#verifyica.maven.plugin.log.test.message=T +#verifyica.maven.plugin.log.pass.messages=false +#verifyica.maven.plugin.log.pass.message=P +#verifyica.maven.plugin.log.skip.messages=false +#verifyica.maven.plugin.log.skip.message=S +#verifyica.maven.plugin.log.fail.message=F #verifyica.test.class.shuffle=true #verifyica.test.class.include.regex= #verifyica.test.class.exclude.regex= @@ -10,14 +23,3 @@ verifyica.parallelism=100 #verifyica.test.method.exclude.regex= #verifyica.test.method.tag.include.regex= #verifyica.test.method.tag.exclude.regex= -#verifyica.logger.level=ALL -#verifyica.logger.regex= -#verifyica.console.log.timing=false -#verifyica.console.log.timing.units=seconds -#verifyica.console.log.test.messages=false -#verifyica.console.log.test.message=T -#verifyica.console.log.pass.messages=false -#verifyica.console.log.pass.message=P -#verifyica.console.log.skip.messages=false -#verifyica.console.log.skip.message=S -#verifyica.console.log.fail.message=F From d64323ac641541cac2607b1a12bd52dab20f9598 Mon Sep 17 00:00:00 2001 From: dhoard Date: Mon, 22 Jul 2024 12:46:32 -0400 Subject: [PATCH 58/77] Updated Verifyica test engine version Signed-off-by: dhoard --- .../integration_tests/pom.xml | 11 +----- .../jmx/test/AutoIncrementingMBeanTest.java | 18 ++++++---- .../jmx/test/common/AbstractExporterTest.java | 36 +++++++++++-------- .../CompleteHttpServerConfigurationTest.java | 15 +++++--- .../AbstractBasicAuthenticationTest.java | 15 +++++--- .../test/opentelemetry/OpenTelemetryTest.java | 27 ++++++++------ .../OpenTelemetryBasicAuthenticationTest.java | 27 ++++++++------ 7 files changed, 85 insertions(+), 64 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 1e5ceec6..2e7c8986 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,11 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.2 - - - - + 0.0.3 @@ -82,11 +78,6 @@ org.antublue.verifyica maven-plugin ${verifyica.version} - - - ${java.docker.images} - - verify diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java index e4d4059c..ca6cd794 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/AutoIncrementingMBeanTest.java @@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; import io.prometheus.jmx.test.common.ExporterTestEnvironment; +import io.prometheus.jmx.test.support.http.HttpClient; import io.prometheus.jmx.test.support.http.HttpPrometheusMetricsRequest; import io.prometheus.jmx.test.support.http.HttpResponse; import io.prometheus.jmx.test.support.metrics.Metric; @@ -34,12 +35,16 @@ public class AutoIncrementingMBeanTest extends MinimalTest { @Verifyica.Test @Verifyica.Order(order = Integer.MAX_VALUE) public void testAutoIncrementingMBean(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + HttpClient httpClient = + argumentContext + .getTestArgument(ExporterTestEnvironment.class) + .getPayload() + .getHttpClient(); // Collect the auto incrementing MBean values - double value1 = collect(exporterTestEnvironment); - double value2 = collect(exporterTestEnvironment); - double value3 = collect(exporterTestEnvironment); + double value1 = collect(httpClient); + double value2 = collect(httpClient); + double value3 = collect(httpClient); // Assert that each collection is the previous value + 1 assertThat(value2).isGreaterThan(value1); @@ -53,11 +58,10 @@ public void testAutoIncrementingMBean(ArgumentContext argumentContext) { * * @return the auto incrementing MBean value */ - private double collect(ExporterTestEnvironment exporterTestEnvironment) { + private double collect(HttpClient httpClient) { final AtomicDouble value = new AtomicDouble(); - HttpResponse httpResponse = - new HttpPrometheusMetricsRequest().send(exporterTestEnvironment.getHttpClient()); + HttpResponse httpResponse = new HttpPrometheusMetricsRequest().send(httpClient); assertHttpMetricsResponse(httpResponse); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java index b60e92ad..7c420f0d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java @@ -27,6 +27,7 @@ import io.prometheus.jmx.test.support.http.HttpResponseAssertions; import java.util.ArrayList; import java.util.Collection; +import java.util.Optional; import java.util.function.BiConsumer; import java.util.stream.Stream; import org.antublue.verifyica.api.ArgumentContext; @@ -73,15 +74,18 @@ public static void prepare(ClassContext classContext) { @Verifyica.BeforeAll public void beforeAll(ArgumentContext argumentContext) { Network network = argumentContext.getClassContext().getStore().get(NETWORK); + Class testClass = argumentContext.getClassContext().getTestClass(); argumentContext - .getArgumentPayload(ExporterTestEnvironment.class) - .initialize(getClass(), network); + .getTestArgument(ExporterTestEnvironment.class) + .getPayload() + .initialize(testClass, network); } @Verifyica.Test public void testHealthy(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); new HttpHealthyRequest() .send(exporterTestEnvironment.getHttpClient()) @@ -90,7 +94,8 @@ public void testHealthy(ArgumentContext argumentContext) { @Verifyica.Test public void testMetrics(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); accept( exporterTestEnvironment, @@ -99,7 +104,8 @@ public void testMetrics(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); accept( exporterTestEnvironment, @@ -108,7 +114,8 @@ public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); accept( exporterTestEnvironment, @@ -117,7 +124,8 @@ public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); accept( exporterTestEnvironment, @@ -127,18 +135,16 @@ public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) @Verifyica.AfterAll public void afterAll(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); - if (exporterTestEnvironment != null) { - exporterTestEnvironment.destroy(); - } + Optional.ofNullable(argumentContext.getTestArgument(ExporterTestEnvironment.class)) + .ifPresent( + exporterTestEnvironmentArgument -> + exporterTestEnvironmentArgument.getPayload().destroy()); } @Verifyica.Conclude public static void conclude(ClassContext classContext) { - Network network = classContext.getStore().remove(NETWORK); - if (network != null) { - network.close(); - } + Optional.ofNullable(classContext.getStore().remove(NETWORK, Network.class)) + .ifPresent(Network::close); } @Override diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index 7035dbe7..637a310d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -83,7 +83,8 @@ public ExporterTestEnvironment apply( @Verifyica.Test public void testHealthy(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { @@ -103,7 +104,8 @@ public void testHealthy(ArgumentContext argumentContext) { @Verifyica.Test public void testMetrics(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { @@ -129,7 +131,8 @@ public void testMetrics(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { @@ -155,7 +158,8 @@ public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { @@ -181,7 +185,8 @@ public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); for (String username : TEST_USERNAMES) { for (String password : TEST_PASSWORDS) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java index ab1fbaaf..8b6dd2d0 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AbstractBasicAuthenticationTest.java @@ -65,7 +65,8 @@ public static Collection getAuthenticationCredentials @Verifyica.Test public void testHealthy(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); getAuthenticationCredentials() .forEach( @@ -89,7 +90,8 @@ public void testHealthy(ArgumentContext argumentContext) { @Verifyica.Test public void testMetrics(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); getAuthenticationCredentials() .forEach( @@ -117,7 +119,8 @@ public void testMetrics(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); getAuthenticationCredentials() .forEach( @@ -145,7 +148,8 @@ public void testMetricsOpenMetricsFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); getAuthenticationCredentials() .forEach( @@ -173,7 +177,8 @@ public void testMetricsPrometheusFormat(ArgumentContext argumentContext) { @Verifyica.Test public void testMetricsPrometheusProtobufFormat(ArgumentContext argumentContext) { - ExporterTestEnvironment exporterTestEnvironment = argumentContext.getArgumentPayload(); + ExporterTestEnvironment exporterTestEnvironment = + argumentContext.getTestArgument(ExporterTestEnvironment.class).getPayload(); getAuthenticationCredentials() .forEach( diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 369ba55f..48b8cf11 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; @@ -32,7 +33,7 @@ public class OpenTelemetryTest { * * @return the Stream of test environments */ - @Verifyica.ArgumentSupplier(parallelism = 10) + @Verifyica.ArgumentSupplier(parallelism = 2) public static Stream arguments() { Collection openTelemetryTestEnvironments = new ArrayList<>(); @@ -63,9 +64,12 @@ public void beforeAll(ArgumentContext argumentContext) { argumentContext.getStore().put(NETWORK, network); - argumentContext - .getArgumentPayload(OpenTelemetryTestEnvironment.class) - .initialize(getClass(), network); + Class testClass = argumentContext.getClassContext().getTestClass(); + + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); + + openTelemetryTestEnvironment.initialize(testClass, network); } /** Method to test that Prometheus is up */ @@ -73,7 +77,7 @@ public void beforeAll(ArgumentContext argumentContext) { @Verifyica.Order(order = 0) public void testIsPrometheusUp(ArgumentContext argumentContext) { OpenTelemetryTestEnvironment openTelemetryTestEnvironment = - argumentContext.getArgumentPayload(); + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicBoolean success = new AtomicBoolean(); @@ -116,7 +120,7 @@ public void testIsPrometheusUp(ArgumentContext argumentContext) { @Verifyica.Test public void testPrometheusHasMetrics(ArgumentContext argumentContext) { OpenTelemetryTestEnvironment openTelemetryTestEnvironment = - argumentContext.getArgumentPayload(); + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); boolean isJmxExporterModeJavaStandalone = openTelemetryTestEnvironment.getJmxExporterMode() == JmxExporterMode.Standalone; @@ -138,12 +142,13 @@ public void testPrometheusHasMetrics(ArgumentContext argumentContext) { @Verifyica.AfterAll public void afterAll(ArgumentContext argumentContext) { - argumentContext.getArgumentPayload(OpenTelemetryTestEnvironment.class).destroy(); + Optional.ofNullable(argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class)) + .ifPresent( + openTelemetryTestEnvironmentArgument -> + openTelemetryTestEnvironmentArgument.getPayload().destroy()); - Network network = argumentContext.getStore().remove(NETWORK); - if (network != null) { - network.close(); - } + Optional.ofNullable(argumentContext.getStore().remove(NETWORK, Network.class)) + .ifPresent(Network::close); } /** diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java index daf7fb38..dfb58157 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; @@ -38,7 +39,7 @@ public class OpenTelemetryBasicAuthenticationTest { * * @return the Stream of test environments */ - @Verifyica.ArgumentSupplier(parallelism = 10) + @Verifyica.ArgumentSupplier(parallelism = 2) public static Stream arguments() { Collection openTelemetryTestEnvironments = new ArrayList<>(); @@ -69,9 +70,12 @@ public void beforeAll(ArgumentContext argumentContext) { argumentContext.getStore().put(NETWORK, network); - argumentContext - .getArgumentPayload(OpenTelemetryTestEnvironment.class) - .initialize(getClass(), network); + Class testClass = argumentContext.getClassContext().getTestClass(); + + OpenTelemetryTestEnvironment openTelemetryTestEnvironment = + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); + + openTelemetryTestEnvironment.initialize(testClass, network); } /** @@ -83,7 +87,7 @@ public void beforeAll(ArgumentContext argumentContext) { @Verifyica.Order(order = 0) public void testIsPrometheusUp(ArgumentContext argumentContext) { OpenTelemetryTestEnvironment openTelemetryTestEnvironment = - argumentContext.getArgumentPayload(); + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); Throttle throttle = new ExponentialBackoffThrottle(100, 2000); AtomicBoolean success = new AtomicBoolean(); @@ -130,7 +134,7 @@ public void testIsPrometheusUp(ArgumentContext argumentContext) { @Verifyica.Test public void testPrometheusHasMetrics(ArgumentContext argumentContext) { OpenTelemetryTestEnvironment openTelemetryTestEnvironment = - argumentContext.getArgumentPayload(); + argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); ExpectedMetricsNames.getMetricsNames().stream() .filter( @@ -150,12 +154,13 @@ public void testPrometheusHasMetrics(ArgumentContext argumentContext) { @Verifyica.AfterAll public void afterAll(ArgumentContext argumentContext) { - argumentContext.getArgumentPayload(OpenTelemetryTestEnvironment.class).destroy(); + Optional.ofNullable(argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class)) + .ifPresent( + openTelemetryTestEnvironmentArgument -> + openTelemetryTestEnvironmentArgument.getPayload().destroy()); - Network network = argumentContext.getStore().remove(NETWORK); - if (network != null) { - network.close(); - } + Optional.ofNullable(argumentContext.getStore().remove(NETWORK, Network.class)) + .ifPresent(Network::close); } /** From 734d51ad58d6dabb3e9cf09968f2fddb6121383a Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 23 Jul 2024 23:37:58 -0400 Subject: [PATCH 59/77] Changed code to use OpenTelemetry default is configuration is not specified Signed-off-by: dhoard --- .../OpenTelemetryExporterFactory.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java index 57c6f4c1..3efbc5f7 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java @@ -22,6 +22,8 @@ /** Class to implement OpenTelemetryExporterFactory */ public class OpenTelemetryExporterFactory { + private static final int NO_INTERVAL = -1; + /** Constructor */ private OpenTelemetryExporterFactory() { // DO NOTHING @@ -55,9 +57,7 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE ConfigurationException.supplier( "Invalid configuration for" + " /openTelemetry"))) - .orElseThrow( - ConfigurationException.supplier( - "Invalid configuration for /openTelemetry")); + .orElse(new YamlMapAccessor()); String endpoint = openTelemetryYamlMapAccessor @@ -80,7 +80,7 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE "Invalid configuration for" + " /openTelemetry/endpoint" + " must be a URL"))) - .orElse("http://localhost:4317"); + .orElse(null); String protocol = openTelemetryYamlMapAccessor @@ -97,7 +97,7 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE "Invalid configuration for" + " /openTelemetry/protocol" + " must not be blank"))) - .orElse("grpc"); + .orElse(null); int interval = openTelemetryYamlMapAccessor @@ -115,8 +115,8 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE ConfigurationException.supplier( "Invalid configuration for" + " /openTelemetry/interval must be" - + " between greater than 0"))) - .orElse(60); + + " an integer greater than 0"))) + .orElse(NO_INTERVAL); Map headers = openTelemetryYamlMapAccessor @@ -132,16 +132,27 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE OpenTelemetryExporter.Builder openTelemetryExporterBuilder = OpenTelemetryExporter.builder(); - openTelemetryExporterBuilder - .endpoint(endpoint) - .protocol(protocol) - .intervalSeconds(interval); + if (endpoint != null) { + openTelemetryExporterBuilder.endpoint(endpoint); + } + + if (protocol != null) { + openTelemetryExporterBuilder.protocol(protocol); + } + + if (interval != NO_INTERVAL) { + openTelemetryExporterBuilder.intervalSeconds(interval); + } if (headers != null) { headers.forEach( (name, value) -> { - if (name != null && !name.trim().isEmpty()) { - openTelemetryExporterBuilder.header(name, value); + if (name != null + && !name.trim().isEmpty() + && value != null + && !value.trim().isEmpty()) { + openTelemetryExporterBuilder.header( + name.trim(), value.trim()); } }); } From f86cf361f04ed89eca97545698b25df7ebe8348f Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 23 Jul 2024 23:38:21 -0400 Subject: [PATCH 60/77] Removed unused static references Signed-off-by: dhoard --- .../java/io/prometheus/jmx/JavaAgent.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index 71b53fc8..36b74ef6 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -19,8 +19,6 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; -import io.prometheus.metrics.exporter.httpserver.HTTPServer; -import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; import io.prometheus.metrics.instrumentation.jvm.JvmMetrics; import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; @@ -40,9 +38,6 @@ public class JavaAgent { private static final String DEFAULT_HOST = "0.0.0.0"; - private static HTTPServer httpServer; - private static OpenTelemetryExporter openTelemetryExporter; - public static void agentmain(String agentArgument, Instrumentation instrumentation) throws Exception { premain(agentArgument, instrumentation); @@ -60,16 +55,14 @@ public static void premain(String agentArgument, Instrumentation instrumentation String host = config.host != null ? config.host : DEFAULT_HOST; - httpServer = - HTTPServerFactory.getInstance() - .createHTTPServer( - InetAddress.getByName(host), - config.port, - PrometheusRegistry.defaultRegistry, - new File(config.file)); + HTTPServerFactory.getInstance() + .createHTTPServer( + InetAddress.getByName(host), + config.port, + PrometheusRegistry.defaultRegistry, + new File(config.file)); - openTelemetryExporter = - OpenTelemetryExporterFactory.getInstance().create(new File(config.file)); + OpenTelemetryExporterFactory.getInstance().create(new File(config.file)); } catch (Throwable t) { synchronized (System.err) { System.err.println("Failed to start Prometheus JMX Exporter"); From 4c2e541a954b3cc4b1a12a57a8e8f4d6b79e2b18 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 12:47:49 -0400 Subject: [PATCH 61/77] Changed code so that HTTP / OpenTelemetry modes are exclusive Signed-off-by: dhoard --- .../OpenTelemetryTestEnvironment.java | 1 - .../OpenTelemetryTest/Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../java/io/prometheus/jmx/WebServer.java | 85 +++++++++++++------ 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 4788192a..66350117 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -331,7 +331,6 @@ private GenericContainer createStandaloneExporterContainer() { new Ulimit("nofile", 65536L, 65536L) })) .withCommand("/bin/sh exporter.sh") - .withExposedPorts(8888) .withLogConsumer( outputFrame -> { String string = outputFrame.getUtf8StringWithoutLineEnding().trim(); diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh index a04f3b63..2f818857 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_httpserver.jar exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh index a04f3b63..2f818857 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_httpserver.jar exporter.yaml \ No newline at end of file diff --git a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java index 161253d9..8428a112 100644 --- a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java +++ b/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java @@ -19,6 +19,7 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; +import io.prometheus.jmx.common.util.ResourceSupport; import io.prometheus.metrics.exporter.httpserver.HTTPServer; import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; import io.prometheus.metrics.model.registry.PrometheusRegistry; @@ -30,60 +31,92 @@ public class WebServer { + private static final String DEFAULT_HOST = "0.0.0.0"; + private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd | HH:mm:ss.SSS", Locale.getDefault()); + private enum Mode { + HTTP, + OPEN_TELEMETRY + } + public static void main(String[] args) throws Exception { HTTPServer httpServer = null; OpenTelemetryExporter openTelemetryExporter = null; + String usage = ResourceSupport.load("/usage.txt"); - if (args.length < 2) { - System.err.println("Usage: WebServer <[hostname:]port> "); + if (args == null || args.length < 1 || args.length > 2) { + System.err.println(usage); + System.err.println(); System.exit(1); } - String host = "0.0.0.0"; - int port; - int colonIndex = args[0].lastIndexOf(':'); - - if (colonIndex < 0) { - port = Integer.parseInt(args[0]); + Mode mode; + if (args.length == 2) { + mode = Mode.HTTP; } else { - port = Integer.parseInt(args[0].substring(colonIndex + 1)); - host = args[0].substring(0, colonIndex); + mode = Mode.OPEN_TELEMETRY; } - new BuildInfoMetrics().register(PrometheusRegistry.defaultRegistry); - new JmxCollector(new File(args[1]), JmxCollector.Mode.STANDALONE) - .register(PrometheusRegistry.defaultRegistry); - try { - httpServer = - HTTPServerFactory.getInstance() - .createHTTPServer( - InetAddress.getByName(host), - port, - PrometheusRegistry.defaultRegistry, - new File(args[1])); + new BuildInfoMetrics().register(PrometheusRegistry.defaultRegistry); + + switch (mode) { + case HTTP: + { + String host = DEFAULT_HOST; + int port; + int colonIndex = args[0].lastIndexOf(':'); - openTelemetryExporter = - OpenTelemetryExporterFactory.getInstance().create(new File(args[1])); + if (colonIndex < 0) { + port = Integer.parseInt(args[0]); + } else { + port = Integer.parseInt(args[0].substring(colonIndex + 1)); + host = args[0].substring(0, colonIndex); + } + + new JmxCollector(new File(args[1]), JmxCollector.Mode.STANDALONE) + .register(PrometheusRegistry.defaultRegistry); + + httpServer = + HTTPServerFactory.getInstance() + .createHTTPServer( + InetAddress.getByName(host), + port, + PrometheusRegistry.defaultRegistry, + new File(args[1])); + break; + } + case OPEN_TELEMETRY: + { + new JmxCollector(new File(args[0]), JmxCollector.Mode.STANDALONE) + .register(PrometheusRegistry.defaultRegistry); + + openTelemetryExporter = + OpenTelemetryExporterFactory.getInstance() + .create(new File(args[0])); + } + } System.out.println( String.format( - "%s | %s | INFO | %s | %s", + "%s | %s | INFO | %s | %s (%s)", SIMPLE_DATE_FORMAT.format(new Date()), Thread.currentThread().getName(), WebServer.class.getName(), - "Running")); + "Running", + mode == Mode.HTTP ? "HTTP" : "OpenTelemetry")); Thread.currentThread().join(); } catch (ConfigurationException e) { System.err.println("Configuration Exception : " + e.getMessage()); + e.printStackTrace(System.err); System.exit(1); } catch (Throwable t) { System.err.println("Exception starting"); - t.printStackTrace(); + t.printStackTrace(System.err); + System.exit(1); } finally { if (openTelemetryExporter != null) { openTelemetryExporter.close(); From 6ef71f637038d263a80c891861a42b62165c7ee4 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 12:58:38 -0400 Subject: [PATCH 62/77] Added missing class Signed-off-by: dhoard --- .../jmx/common/util/ResourceSupport.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/util/ResourceSupport.java diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/util/ResourceSupport.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/util/ResourceSupport.java new file mode 100644 index 00000000..b0dc44df --- /dev/null +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/util/ResourceSupport.java @@ -0,0 +1,49 @@ +package io.prometheus.jmx.common.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +/** Class to implement ResourceSupport */ +public class ResourceSupport { + + /** Constructor */ + private ResourceSupport() { + // DO NOTHING + } + + public static String load(String resource) throws IOException { + Precondition.notNull(resource, "resource is null"); + + if (!resource.startsWith("/")) { + resource = "/" + resource; + } + + StringBuilder stringBuilder = new StringBuilder(); + + InputStream inputStream = ResourceSupport.class.getResourceAsStream(resource); + if (inputStream == null) { + throw new IOException("Resource [" + resource + "] not found"); + } + + try (BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + while (true) { + String line = bufferedReader.readLine(); + if (line == null) { + break; + } + + if (stringBuilder.length() > 0) { + stringBuilder.append(System.lineSeparator()); + } + + stringBuilder.append(line); + } + } + + return stringBuilder.toString(); + } +} From 4888cf43bd994d988743245410a29fc416931d4a Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 12:59:00 -0400 Subject: [PATCH 63/77] Added new Java test containers Signed-off-by: dhoard --- .../integration_tests/src/test/resources/java-docker-images.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt b/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt index fc84e183..f446e289 100644 --- a/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt +++ b/integration_test_suite/integration_tests/src/test/resources/java-docker-images.txt @@ -70,6 +70,8 @@ openjdk:11 openjdk:17 openjdk:21 openjdk:22 +openjdk:23 +openjdk:24 registry.access.redhat.com/ubi8/openjdk-8-runtime:latest registry.access.redhat.com/ubi8/openjdk-11-runtime:latest registry.access.redhat.com/ubi8/openjdk-17-runtime:latest From ab053612f66d1c487d7955870ed710a30482f631 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 12:59:33 -0400 Subject: [PATCH 64/77] Added missing resource Signed-off-by: dhoard --- .../src/main/resources/usage.txt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 jmx_prometheus_httpserver/src/main/resources/usage.txt diff --git a/jmx_prometheus_httpserver/src/main/resources/usage.txt b/jmx_prometheus_httpserver/src/main/resources/usage.txt new file mode 100644 index 00000000..5aab67ad --- /dev/null +++ b/jmx_prometheus_httpserver/src/main/resources/usage.txt @@ -0,0 +1,39 @@ +------------------------------------- +JMX Exporter HTTP Server (standalone) +------------------------------------- + +The JMX Exporter HTTP server has two exclusive modes: + +Prometheus (HTTP) mode +---------------------- + +- Exposes a "/metrics" endpoint to allow metrics collection via Prometheus (HTTP) +- OpenTelemetry configuration is ignored + +Usage: + + java -jar jmx_prometheus_httpserver-.jar [HOSTNAME:] + +Example: + + java -jar jmx_prometheus_httpserver-1.0.1.jar 12345 config.yaml + +OpenTelemetry mode +------------------ + +- Pushes metrics to an OpenTelemetry endpoint +- Requires OpenTelemetry to be configured in the YAML configuration file +- HTTP configuration is ignored + +Usage: + + java -jar jmx_prometheus_httpserver-.jar + +Example: + + java -jar jmx_prometheus_httpserver-1.0.1.jar config.yaml + +Documentation +------------- + +https://github.com/prometheus/jmx_exporter \ No newline at end of file From 7ea84cce28114e43e0f094a2ff30547df7a4f856 Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 22:35:02 -0400 Subject: [PATCH 65/77] Changed jmx_prometheus_httpserver module to jmx_prometheus_standalone Signed-off-by: dhoard --- MAINTAINER_NOTES.md | 6 +-- README.md | 18 ++++++--- .../io/prometheus/jmx/BuildInfoMetrics.java | 2 +- .../java/io/prometheus/jmx/JmxCollector.java | 2 +- docs/README.md | 39 +++++++++++-------- .../io/prometheus/jmx/test/MinimalTest.java | 2 +- .../jmx/test/OptionalValueMBeanTest.java | 2 +- .../CompleteHttpServerConfigurationTest.java | 2 +- ...cAuthenticationPBKDF2WithHmacSHA1Test.java | 2 +- ...uthenticationPBKDF2WithHmacSHA256Test.java | 2 +- ...uthenticationPBKDF2WithHmacSHA512Test.java | 2 +- .../BasicAuthenticationPlaintextTest.java | 2 +- .../BasicAuthenticationSHA1Test.java | 2 +- .../BasicAuthenticationSHA256Test.java | 2 +- .../BasicAuthenticationSHA512Test.java | 2 +- ...uthenticationPBKDF2WithHmacSHA512Test.java | 2 +- ...thJKSKeyStoreMultipleCertificatesTest.java | 2 +- .../test/http/ssl/SSLWithJKSKeyStoreTest.java | 2 +- .../http/ssl/SSLWithJKSKeyStoreTest2.java | 2 +- ...KCS12KeyStoreMultipleCertificatesTest.java | 2 +- .../http/ssl/SSLWithPKCS12KeyStoreTest.java | 2 +- .../http/ssl/SSLWithPKCS12KeyStoreTest2.java | 2 +- .../threads/ThreadsConfigurationTest.java | 2 +- .../jmx/test/rmi/ssl/MinimalRMISSLTest.java | 2 +- .../rmi/ssl/RMIRegistrySSLDisabledTest.java | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../test/MinimalTest/Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../OpenTelemetryTest/Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../MinimalRMISSLTest/Standalone/exporter.sh | 2 +- .../Standalone/exporter.sh | 2 +- .../src/deb/bin/jmx_exporter | 3 -- .../pom.xml | 10 ++--- .../src/deb/bin/jmx_exporter | 3 ++ .../src/deb/config/jmx_exporter.yaml | 0 .../src/deb/control/control | 0 .../java/io/prometheus/jmx/Standalone.java | 4 +- .../src/main/resources/usage.txt | 18 ++++----- .../version-rules.xml | 0 pom.xml | 2 +- run_sample_httpserver.sh | 4 +- tools/build-and-copy.sh | 2 +- tools/patch-and-run-integration-test-suite.sh | 16 ++++---- 72 files changed, 125 insertions(+), 114 deletions(-) delete mode 100755 jmx_prometheus_httpserver/src/deb/bin/jmx_exporter rename {jmx_prometheus_httpserver => jmx_prometheus_standalone}/pom.xml (98%) create mode 100755 jmx_prometheus_standalone/src/deb/bin/jmx_exporter rename {jmx_prometheus_httpserver => jmx_prometheus_standalone}/src/deb/config/jmx_exporter.yaml (100%) rename {jmx_prometheus_httpserver => jmx_prometheus_standalone}/src/deb/control/control (100%) rename jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java => jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java (98%) rename {jmx_prometheus_httpserver => jmx_prometheus_standalone}/src/main/resources/usage.txt (51%) rename {jmx_prometheus_httpserver => jmx_prometheus_standalone}/version-rules.xml (100%) diff --git a/MAINTAINER_NOTES.md b/MAINTAINER_NOTES.md index 72d9c850..2447b50f 100644 --- a/MAINTAINER_NOTES.md +++ b/MAINTAINER_NOTES.md @@ -57,19 +57,19 @@ Example ```shell /home/dhoard/Downloads/jmx_prometheus_javaagent-0.20.0.jar -/home/dhoard/Downloads/jmx_prometheus_httpserver-0.20.0.jar +/home/dhoard/Downloads/jmx_prometheus_standalone-0.20.0.jar ``` Command ```shell -./tools/patch-and-run-integration-test-suite.sh +./tools/patch-and-run-integration-test-suite.sh ``` Example ```shell -./tools/patch-and-run-integration-test-suite.sh /home/dhoard/Downloads/jmx_prometheus_javaagent-0.20.0.jar /home/dhoard/Downloads/jmx_prometheus_httpserver-0.20.0.jar +./tools/patch-and-run-integration-test-suite.sh /home/dhoard/Downloads/jmx_prometheus_javaagent-0.20.0.jar /home/dhoard/Downloads/jmx_prometheus_standalone-0.20.0.jar ``` ### Step 3 diff --git a/README.md b/README.md index 3da02dd8..346ef323 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ +[![Build Status](https://circleci.com/gh/prometheus/jmx_exporter.svg?style=svg)](https://circleci.com/gh/prometheus/jmx_exporter) + # JMX Exporter -[![Build Status](https://circleci.com/gh/prometheus/jmx_exporter.svg?style=svg)](https://circleci.com/gh/prometheus/jmx_exporter) +JMX to Prometheus exporter: -JMX to Prometheus exporter: a collector that can configurable scrape and -expose MBeans of a JMX target. +A collector that can configurable scrape and expose MBeans of a JMX target. -This exporter is intended to be run as a Java Agent, exposing a HTTP server -and serving metrics of the local JVM. It can be also run as a standalone -HTTP server and scrape remote JMX targets, but this has various +This exporter is intended to be run as a Java Agent, exposing either +an HTTP endpoint or pushing Open Telemetry metrics of the local JVM. + +It can be also run as a standalone server and scrape remote JMX targets, but this has various disadvantages, such as being harder to configure and being unable to expose process metrics (e.g., memory and CPU usage). +In particular all the `jvm_*` metrics like `jvm_classes_loaded_total`, `jvm_threads_current`, +`jvm_threads_daemon` and `jvm_memory_bytes_used` won't be available when +using the standalone server. + **Running the exporter as a Java agent is strongly encouraged.** # Documentation diff --git a/collector/src/main/java/io/prometheus/jmx/BuildInfoMetrics.java b/collector/src/main/java/io/prometheus/jmx/BuildInfoMetrics.java index a771202f..bd1716a3 100755 --- a/collector/src/main/java/io/prometheus/jmx/BuildInfoMetrics.java +++ b/collector/src/main/java/io/prometheus/jmx/BuildInfoMetrics.java @@ -31,7 +31,7 @@ * Metrics being exported: * *
- *   jmx_exporter_build_info{version="3.2.0",name="jmx_prometheus_httpserver",} 1.0
+ *   jmx_exporter_build_info{version="3.2.0",name="jmx_prometheus_standalone",} 1.0
  * 
*/ public class BuildInfoMetrics { diff --git a/collector/src/main/java/io/prometheus/jmx/JmxCollector.java b/collector/src/main/java/io/prometheus/jmx/JmxCollector.java index 450083da..ca0f03f4 100644 --- a/collector/src/main/java/io/prometheus/jmx/JmxCollector.java +++ b/collector/src/main/java/io/prometheus/jmx/JmxCollector.java @@ -181,7 +181,7 @@ private void exitOnConfigError() { LOGGER.log( SEVERE, "Configuration error: When running jmx_exporter in standalone mode (using" - + " jmx_prometheus_httpserver-*.jar) you must configure 'jmxUrl' or" + + " jmx_prometheus_standalone-*.jar) you must configure 'jmxUrl' or" + " 'hostPort'."); System.exit(-1); } diff --git a/docs/README.md b/docs/README.md index 38c124c6..926a3219 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,17 +5,22 @@ JMX Exporter ===== -JMX to Prometheus exporter: a collector that can configurable scrape and -expose mBeans of a JMX target. +JMX to Prometheus exporter: -This exporter is intended to be run as a Java Agent, exposing a HTTP server -and serving metrics of the local JVM. It can be also run as a standalone -HTTP server and scrape remote JMX targets, but this has various +A collector that can configurable scrape and expose MBeans of a JMX target. + +This exporter is intended to be run as a Java Agent, exposing either +an HTTP endpoint or pushing Open Telemetry metrics of the local JVM. + +It can be also run as a standalone server and scrape remote JMX targets, but this has various disadvantages, such as being harder to configure and being unable to expose -process metrics (e.g., memory and CPU usage). In particular all the -`jvm_*` metrics like `jvm_classes_loaded_total`, `jvm_threads_current`, -`jvm_threads_daemon` and `jvm_memory_bytes_used` won't be availabe if -using the standalone http server. +process metrics (e.g., memory and CPU usage). + +In particular all the `jvm_*` metrics like `jvm_classes_loaded_total`, `jvm_threads_current`, +`jvm_threads_daemon` and `jvm_memory_bytes_used` won't be available when +using the standalone server. + +**Running the exporter as a Java agent is strongly encouraged.** ### **NOTES** @@ -52,21 +57,21 @@ rules: Example configurations can be found in the `example_configs/` directory. -## Running the Standalone HTTP Server +## Running the Standalone Server -- [jmx_prometheus_httpserver-1.0.1.jar](https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/1.0.1/jmx_prometheus_httpserver-1.0.1.jar) +- [jmx_prometheus_standalone-1.0.1.jar](https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_standalone/1.0.1/jmx_prometheus_standalone-1.0.1.jar) -To run the standalone HTTP server, download one of the JARs and run: +To run the standalone server, download one of the JARs and run: ``` -java -jar jmx_prometheus_httpserver-1.0.1.jar 12345 config.yaml +java -jar jmx_prometheus_standalone-1.0.1.jar 12345 config.yaml ``` Metrics will now be accessible at [http://localhost:12345/metrics](http://localhost:12345/metrics). To bind the java agent to a specific IP change the port number to `host:port`. -The standalone HTTP server will read JMX remotely over the network. Therefore, you need to specify -either `hostPort` or `jmxUrl` in `config.yaml` to tell the HTTP server where the JMX beans can be accessed. +The standalone server will read JMX remotely over the network. Therefore, you need to specify +either `hostPort` or `jmxUrl` in `config.yaml` to tell the server where the JMX beans can be accessed. A minimal `config.yaml` looks like this: @@ -76,7 +81,7 @@ rules: - pattern: ".*" ``` -As stated above, it is recommended to run JMX exporter as a Java agent and not as a standalone HTTP server. +As stated above, it is recommended to run JMX exporter as a Java agent and not as a standalone server. **NOTES** @@ -332,7 +337,7 @@ httpServer: ## Integration Test Suite -The JMX exporter uses the [Braxco](https://github.com/antublue/braxco) and [Testcontainers](https://www.testcontainers.org/) to run integration tests with different Java versions. +The JMX exporter project uses [Verifyica](https://github.com/antublue/verifyica) and [Testcontainers](https://www.testcontainers.org/) to run integration tests with different Java versions. You need to have Docker installed to run the integration test suite. diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java index 72a19fe1..2ca89243 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/MinimalTest.java @@ -44,7 +44,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java index 8dab053e..8e75f5ae 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/OptionalValueMBeanTest.java @@ -44,7 +44,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java index 637a310d..9df845f6 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest.java @@ -222,7 +222,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java index 1f07efbd..d842918b 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test.java @@ -57,7 +57,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java index b4294556..bfc9c0b7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test.java @@ -57,7 +57,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java index ed18ea75..d834d3a3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -57,7 +57,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java index 1c9aa23b..5994de39 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest.java @@ -43,7 +43,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java index e8828269..e5c7605e 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test.java @@ -43,7 +43,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java index 24173526..5223e3b9 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test.java @@ -43,7 +43,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java index e609cdc4..918b634a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test.java @@ -43,7 +43,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java index 1d456bc5..4cefa77c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test.java @@ -65,7 +65,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java index 5165bb01..6de304e3 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest.java @@ -63,7 +63,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java index 50c1cdd3..c9d3c6a7 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest.java @@ -63,7 +63,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java index de020732..bd341438 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2.java @@ -63,7 +63,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java index 7c052ae8..c8fbe606 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest.java @@ -59,7 +59,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java index b553bfaa..e05c64af 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest.java @@ -59,7 +59,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java index 84d09a7a..2ba94715 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2.java @@ -59,7 +59,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java index 5b20ee6b..786c45cd 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest.java @@ -44,7 +44,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java index d6cc408d..0a9043f5 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest.java @@ -73,7 +73,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java index 47847a56..9e9b8397 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest.java @@ -73,7 +73,7 @@ public void accept(ExporterTestEnvironment exporterTestEnvironment, HttpResponse String buildInfoName = isJmxExporterModeJavaAgent ? "jmx_prometheus_javaagent" - : "jmx_prometheus_httpserver"; + : "jmx_prometheus_standalone"; assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/AutoIncrementingMBeanTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/AutoIncrementingMBeanTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/AutoIncrementingMBeanTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/AutoIncrementingMBeanTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/BlacklistObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/BlacklistObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/BlacklistObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/BlacklistObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/CompositeKeyDataTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/CompositeKeyDataTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/CompositeKeyDataTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/CompositeKeyDataTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/DisableAutoExcludeObjectNameAttributesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNameAttributesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/ExcludeObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeAndExcludeObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/IncludeObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputAndLabelNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputLabelNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/LowerCaseOutputNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/MinimalTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/MinimalTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/MinimalTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/MinimalTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/OptionalValueMBeanTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/OptionalValueMBeanTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/OptionalValueMBeanTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/OptionalValueMBeanTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistAndBlacklistObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistObjectNamesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistObjectNamesTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistObjectNamesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/WhitelistObjectNamesTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/CompleteHttpServerConfigurationTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA1Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA256Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationPlaintextTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA1Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA256Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/authentication/BasicAuthenticationSHA512Test/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh index 30d75027..1a8f7542 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLAndBasicAuthenticationPBKDF2WithHmacSHA512Test/Standalone/exporter.sh @@ -4,4 +4,4 @@ java \ -Xmx512M \ -Djavax.net.ssl.keyStore=localhost.jks \ -Djavax.net.ssl.keyStorePassword=changeit \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest/Standalone/exporter.sh index 30d75027..1a8f7542 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreMultipleCertificatesTest/Standalone/exporter.sh @@ -4,4 +4,4 @@ java \ -Xmx512M \ -Djavax.net.ssl.keyStore=localhost.jks \ -Djavax.net.ssl.keyStorePassword=changeit \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest/Standalone/exporter.sh index 30d75027..1a8f7542 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest/Standalone/exporter.sh @@ -4,4 +4,4 @@ java \ -Xmx512M \ -Djavax.net.ssl.keyStore=localhost.jks \ -Djavax.net.ssl.keyStorePassword=changeit \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithJKSKeyStoreTest2/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest/Standalone/exporter.sh index 678c7c2f..b89329fc 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreMultipleCertificatesTest/Standalone/exporter.sh @@ -4,4 +4,4 @@ java \ -Xmx512M \ -Djavax.net.ssl.keyStore=localhost.pkcs12 \ -Djavax.net.ssl.keyStorePassword=changeit \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest/Standalone/exporter.sh index 678c7c2f..b89329fc 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest/Standalone/exporter.sh @@ -4,4 +4,4 @@ java \ -Xmx512M \ -Djavax.net.ssl.keyStore=localhost.pkcs12 \ -Djavax.net.ssl.keyStorePassword=changeit \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/ssl/SSLWithPKCS12KeyStoreTest2/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest/Standalone/exporter.sh index a04f3b63..e05198da 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/http/threads/ThreadsConfigurationTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh index 2f818857..919076de 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh index 2f818857..919076de 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/Standalone/exporter.sh @@ -2,4 +2,4 @@ java \ -Xmx512M \ - -jar jmx_prometheus_httpserver.jar exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest/Standalone/exporter.sh index c931894d..b7a975fa 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/MinimalRMISSLTest/Standalone/exporter.sh @@ -8,4 +8,4 @@ java \ -Djavax.net.ssl.trustStore=localhost.pkcs12 \ -Djavax.net.ssl.trustStorePassword=changeit \ -Djavax.net.ssl.trustStoreType=pkcs12 \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest/Standalone/exporter.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest/Standalone/exporter.sh index 55e42317..0828cecd 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest/Standalone/exporter.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/rmi/ssl/RMIRegistrySSLDisabledTest/Standalone/exporter.sh @@ -10,4 +10,4 @@ java \ -Djavax.net.ssl.trustStore=localhost.pkcs12 \ -Djavax.net.ssl.trustStorePassword=changeit \ -Djavax.net.ssl.trustStoreType=pkcs12 \ - -jar jmx_prometheus_httpserver.jar 8888 exporter.yaml \ No newline at end of file + -jar jmx_prometheus_standalone.jar 8888 exporter.yaml \ No newline at end of file diff --git a/jmx_prometheus_httpserver/src/deb/bin/jmx_exporter b/jmx_prometheus_httpserver/src/deb/bin/jmx_exporter deleted file mode 100755 index d2e79cf3..00000000 --- a/jmx_prometheus_httpserver/src/deb/bin/jmx_exporter +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec java -jar /usr/share/jmx_exporter/jmx_prometheus_httpserver-*.jar $@ diff --git a/jmx_prometheus_httpserver/pom.xml b/jmx_prometheus_standalone/pom.xml similarity index 98% rename from jmx_prometheus_httpserver/pom.xml rename to jmx_prometheus_standalone/pom.xml index aee7766f..a3f9172d 100644 --- a/jmx_prometheus_httpserver/pom.xml +++ b/jmx_prometheus_standalone/pom.xml @@ -8,8 +8,8 @@ 1.x.x - jmx_prometheus_httpserver - Prometheus JMX Exporter - Http Server + jmx_prometheus_standalone + Prometheus JMX Exporter - Standalone Server See https://github.com/prometheus/jmx_exporter/blob/master/README.md @@ -177,7 +177,7 @@ - io.prometheus.jmx.WebServer + io.prometheus.jmx.Standalone ${project.version} ${project.artifactId} @@ -209,7 +209,7 @@
- + jdeb org.vafer @@ -267,7 +267,7 @@ ${project.build.directory}/${project.build.finalName}.jar - ../integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_httpserver.jar + ../integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_standalone.jar diff --git a/jmx_prometheus_standalone/src/deb/bin/jmx_exporter b/jmx_prometheus_standalone/src/deb/bin/jmx_exporter new file mode 100755 index 00000000..906808e2 --- /dev/null +++ b/jmx_prometheus_standalone/src/deb/bin/jmx_exporter @@ -0,0 +1,3 @@ +#!/bin/sh + +exec java -jar /usr/share/jmx_exporter/jmx_prometheus_standalone-*.jar $@ diff --git a/jmx_prometheus_httpserver/src/deb/config/jmx_exporter.yaml b/jmx_prometheus_standalone/src/deb/config/jmx_exporter.yaml similarity index 100% rename from jmx_prometheus_httpserver/src/deb/config/jmx_exporter.yaml rename to jmx_prometheus_standalone/src/deb/config/jmx_exporter.yaml diff --git a/jmx_prometheus_httpserver/src/deb/control/control b/jmx_prometheus_standalone/src/deb/control/control similarity index 100% rename from jmx_prometheus_httpserver/src/deb/control/control rename to jmx_prometheus_standalone/src/deb/control/control diff --git a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java similarity index 98% rename from jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java rename to jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java index 8428a112..db8218ec 100644 --- a/jmx_prometheus_httpserver/src/main/java/io/prometheus/jmx/WebServer.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java @@ -29,7 +29,7 @@ import java.util.Date; import java.util.Locale; -public class WebServer { +public class Standalone { private static final String DEFAULT_HOST = "0.0.0.0"; @@ -104,7 +104,7 @@ public static void main(String[] args) throws Exception { "%s | %s | INFO | %s | %s (%s)", SIMPLE_DATE_FORMAT.format(new Date()), Thread.currentThread().getName(), - WebServer.class.getName(), + Standalone.class.getName(), "Running", mode == Mode.HTTP ? "HTTP" : "OpenTelemetry")); diff --git a/jmx_prometheus_httpserver/src/main/resources/usage.txt b/jmx_prometheus_standalone/src/main/resources/usage.txt similarity index 51% rename from jmx_prometheus_httpserver/src/main/resources/usage.txt rename to jmx_prometheus_standalone/src/main/resources/usage.txt index 5aab67ad..90141e45 100644 --- a/jmx_prometheus_httpserver/src/main/resources/usage.txt +++ b/jmx_prometheus_standalone/src/main/resources/usage.txt @@ -1,8 +1,8 @@ -------------------------------------- -JMX Exporter HTTP Server (standalone) -------------------------------------- +------------------------------ +JMX Exporter Standalone Server +------------------------------ -The JMX Exporter HTTP server has two exclusive modes: +The JMX Exporter Standalone server has two exclusive modes: Prometheus (HTTP) mode ---------------------- @@ -12,11 +12,11 @@ Prometheus (HTTP) mode Usage: - java -jar jmx_prometheus_httpserver-.jar [HOSTNAME:] + java -jar jmx_prometheus_standalone-.jar [HOSTNAME:] Example: - java -jar jmx_prometheus_httpserver-1.0.1.jar 12345 config.yaml + java -jar jmx_prometheus_standalone-1.0.1.jar 12345 config.yaml OpenTelemetry mode ------------------ @@ -27,13 +27,13 @@ OpenTelemetry mode Usage: - java -jar jmx_prometheus_httpserver-.jar + java -jar jmx_prometheus_standalone-.jar Example: - java -jar jmx_prometheus_httpserver-1.0.1.jar config.yaml + java -jar jmx_prometheus_standalone-1.0.1.jar config.yaml Documentation ------------- -https://github.com/prometheus/jmx_exporter \ No newline at end of file +https://github.com/prometheus/jmx_exporter diff --git a/jmx_prometheus_httpserver/version-rules.xml b/jmx_prometheus_standalone/version-rules.xml similarity index 100% rename from jmx_prometheus_httpserver/version-rules.xml rename to jmx_prometheus_standalone/version-rules.xml diff --git a/pom.xml b/pom.xml index 6664e1d5..5b03d76e 100644 --- a/pom.xml +++ b/pom.xml @@ -48,8 +48,8 @@ collector jmx_prometheus_common - jmx_prometheus_httpserver jmx_prometheus_javaagent + jmx_prometheus_standalone integration_test_suite diff --git a/run_sample_httpserver.sh b/run_sample_httpserver.sh index be49ba1f..53fd32f4 100755 --- a/run_sample_httpserver.sh +++ b/run_sample_httpserver.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Script to run a java application for testing jmx4prometheus. +# Script to run a java application for testing the Prometheus JMX Standalone exporter. VERSION=$(sed -n -e 's#.*\(.*-SNAPSHOT\)#\1#p' pom.xml) @@ -10,5 +10,5 @@ java \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.port=5555 \ - -jar jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-"${VERSION}".jar 5556 \ + -jar jmx_prometheus_standalone/target/jmx_prometheus_standalone-"${VERSION}".jar 5556 \ example_configs/httpserver_sample_config.yml diff --git a/tools/build-and-copy.sh b/tools/build-and-copy.sh index f39483e3..91bcce4a 100755 --- a/tools/build-and-copy.sh +++ b/tools/build-and-copy.sh @@ -49,7 +49,7 @@ BUILD_EXIT_CODE="$?" if [ "${BUILD_EXIT_CODE}" == "0" ]; then cp "jmx_prometheus_javaagent/target/jmx_prometheus_javaagent-${BUILD_VERSION}.jar" "${DESTINATION_DIRECTORY}" - cp "jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-${BUILD_VERSION}.jar" "${DESTINATION_DIRECTORY}" + cp "jmx_prometheus_standalone/target/jmx_prometheus_standalone-${BUILD_VERSION}.jar" "${DESTINATION_DIRECTORY}" fi # Revert the versions diff --git a/tools/patch-and-run-integration-test-suite.sh b/tools/patch-and-run-integration-test-suite.sh index 4aa8fc50..880baa12 100755 --- a/tools/patch-and-run-integration-test-suite.sh +++ b/tools/patch-and-run-integration-test-suite.sh @@ -16,7 +16,7 @@ function emit_error () { } JAVA_AGENT_JAR="${1}" -HTTPSERVER_JAR="${2}" +STANDALONE_JAR="${2}" PROJECT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel) if [ "$#" -ne 2 ]; @@ -36,9 +36,9 @@ rm -Rf ./integration_test_suite/integration_tests/src/test/resources/common/* > cp "${JAVA_AGENT_JAR}" ./integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_javaagent.jar check_exit_code "Failed to patch the integration test suite [${JAVA_AGENT_JAR}]" -# Copy the Java HTTP server exporter jar into the integration test suite -cp "${HTTPSERVER_JAR}" ./integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_httpserver.jar -check_exit_code "Failed to patch the integration test suite [${HTTPSERVER_JAR}]" +# Copy the Java standalone server exporter jar into the integration test suite +cp "${STANDALONE_JAR}" ./integration_test_suite/integration_tests/src/test/resources/common/jmx_prometheus_standalone.jar +check_exit_code "Failed to patch the integration test suite [${STANDALONE_JAR}]" # Pull smoke test Docker images ./integration_test_suite/docker-pull-images.smoke-test.sh @@ -61,12 +61,12 @@ then fi # Validate the java httpserver jar version -DOWNLOAD_HTTPSERVER_JAR_SHA256=$(sha256sum "${HTTPSERVER_JAR}") -INTEGRATION_HTTPSERVER_JAR_SHA256=$(sha256sum ./integration_tests/src/test/resources/common/jmx_prometheus_httpserver.jar) +DOWNLOAD_STANDALONE_JAR_SHA256=$(sha256sum "${STANDALONE_JAR}") +INTEGRATION_STANDALONE_JAR_SHA256=$(sha256sum ./integration_tests/src/test/resources/common/jmx_prometheus_standalone.jar) -if [ "${DOWNLOAD_HTTPSERVER_JAR_SHA256}" != "${DOWNLOAD_HTTPSERVER_JAR_SHA256}" ]; +if [ "${DOWNLOAD_STANDALONE_JAR_SHA256}" != "${DOWNLOAD_STANDALONE_JAR_SHA256}" ]; then - emit_error "Java HTTP server jar mismatch" + emit_error "Java standalone server jar mismatch" fi # Change to the project root directory From 566478b0f33e1394ece475e3f256a04b466ef95d Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 24 Jul 2024 22:41:14 -0400 Subject: [PATCH 66/77] Changed methods for consistency Signed-off-by: dhoard --- .../opentelemetry/OpenTelemetryExporterFactory.java | 8 +++++++- .../src/main/java/io/prometheus/jmx/JavaAgent.java | 4 +++- .../src/main/java/io/prometheus/jmx/Standalone.java | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java index 3efbc5f7..838c9142 100644 --- a/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java +++ b/jmx_prometheus_common/src/main/java/io/prometheus/jmx/common/opentelemetry/OpenTelemetryExporterFactory.java @@ -12,6 +12,7 @@ import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.yaml.YamlMapAccessor; import io.prometheus.metrics.exporter.opentelemetry.OpenTelemetryExporter; +import io.prometheus.metrics.model.registry.PrometheusRegistry; import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -32,11 +33,14 @@ private OpenTelemetryExporterFactory() { /** * Method to create an OpenTelemetryExporter using the supplied arguments * + * @param prometheusRegistry prometheusRegistry * @param exporterYamlFile exporterYamlFile * @return OpenTelemetryExporter OpenTelemetryExporter * @throws ConfigurationException ConfigurationException */ - public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationException { + public OpenTelemetryExporter createOpenTelemetryExporter( + PrometheusRegistry prometheusRegistry, File exporterYamlFile) + throws ConfigurationException { if (exporterYamlFile == null) { throw new IllegalArgumentException("exporterYamlFile is null"); } @@ -132,6 +136,8 @@ public OpenTelemetryExporter create(File exporterYamlFile) throws ConfigurationE OpenTelemetryExporter.Builder openTelemetryExporterBuilder = OpenTelemetryExporter.builder(); + openTelemetryExporterBuilder.registry(prometheusRegistry); + if (endpoint != null) { openTelemetryExporterBuilder.endpoint(endpoint); } diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index 36b74ef6..f1328827 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -62,7 +62,9 @@ public static void premain(String agentArgument, Instrumentation instrumentation PrometheusRegistry.defaultRegistry, new File(config.file)); - OpenTelemetryExporterFactory.getInstance().create(new File(config.file)); + OpenTelemetryExporterFactory.getInstance() + .createOpenTelemetryExporter( + PrometheusRegistry.defaultRegistry, new File(config.file)); } catch (Throwable t) { synchronized (System.err) { System.err.println("Failed to start Prometheus JMX Exporter"); diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java index db8218ec..deb8c355 100644 --- a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java @@ -95,7 +95,9 @@ public static void main(String[] args) throws Exception { openTelemetryExporter = OpenTelemetryExporterFactory.getInstance() - .create(new File(args[0])); + .createOpenTelemetryExporter( + PrometheusRegistry.defaultRegistry, + new File(args[0])); } } From 9c61465b1f6a38775392a1ad335baf530f9df711 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 26 Jul 2024 01:14:53 -0400 Subject: [PATCH 67/77] Code cleanup Signed-off-by: dhoard --- .../OpenTelemetryTestEnvironment.java | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 66350117..446de79c 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -1,9 +1,11 @@ package io.prometheus.jmx.test.opentelemetry; import com.github.dockerjava.api.model.Ulimit; +import io.prometheus.jmx.common.util.ResourceSupport; import io.prometheus.jmx.test.support.JmxExporterMode; import io.prometheus.jmx.test.support.http.HttpClient; import java.io.BufferedReader; +import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.time.Duration; @@ -302,7 +304,8 @@ private GenericContainer createStandaloneApplicationContainer() { .withNetworkAliases("application") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); + .withWorkingDirectory("/temp") + .waitingFor(Wait.forLogMessage(".*Running.*", 1)); } /** @@ -342,7 +345,8 @@ private GenericContainer createStandaloneExporterContainer() { .withNetworkAliases("exporter") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); + .withWorkingDirectory("/temp") + .waitingFor(Wait.forLogMessage(".*Running.*", 1)); } /** @@ -366,18 +370,27 @@ private static HttpClient createPrometheusHttpClient( private static boolean hasResource(String resource) { boolean hasResource = false; - try (BufferedReader bufferedReader = - new BufferedReader( - new InputStreamReader( - OpenTelemetryTestEnvironment.class.getResourceAsStream(resource), - StandardCharsets.UTF_8))) { - String line = bufferedReader.readLine(); - if (line != null) { - hasResource = true; - } + if (!resource.startsWith("/")) { + resource = "/" + resource; + } - } catch (Throwable t) { - // DO NOTHING + InputStream inputStream = ResourceSupport.class.getResourceAsStream(resource); + if (inputStream != null) { + try (BufferedReader bufferedReader = + new BufferedReader( + new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + while (true) { + String line = bufferedReader.readLine(); + if (line == null) { + break; + } + + hasResource = true; + break; + } + } catch (Throwable t) { + // DO NOTHING + } } return hasResource; From 50dce7dc76adfd4675baf5fcdb3f595aa43bb2fd Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 26 Jul 2024 01:15:19 -0400 Subject: [PATCH 68/77] Increase max throttle time Signed-off-by: dhoard --- .../authentication/OpenTelemetryBasicAuthenticationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java index dfb58157..9ad0b648 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java @@ -89,7 +89,7 @@ public void testIsPrometheusUp(ArgumentContext argumentContext) { OpenTelemetryTestEnvironment openTelemetryTestEnvironment = argumentContext.getTestArgument(OpenTelemetryTestEnvironment.class).getPayload(); - Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicBoolean success = new AtomicBoolean(); for (int i = 0; i < 10; i++) { From add92564afe157e539cf97f3713c818fedfc79ea Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 26 Jul 2024 09:32:10 -0400 Subject: [PATCH 69/77] Updated Verifyica test engine version Signed-off-by: dhoard --- .../integration_tests/pom.xml | 4 +-- verifyica.properties | 25 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 verifyica.properties diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 2e7c8986..f05ceee4 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.3 + 0.0.4 @@ -151,7 +151,7 @@ org.testcontainers testcontainers - 1.19.8 + 1.20.0 com.squareup.okhttp3 diff --git a/verifyica.properties b/verifyica.properties deleted file mode 100644 index 661a374a..00000000 --- a/verifyica.properties +++ /dev/null @@ -1,25 +0,0 @@ -#verifyica.engine.parallelism=48 -#verifyica.engine.executor=virtual -#verifyica.engine.logger.level=ALL -#verifyica.engine.logger.regex= -#verifyica.engine.thread.type=platform -#verifyica.engine.interceptors.include.regex= -#verifyica.engine.interceptors.exclude.regex= -#verifyica.maven.plugin.log.timing=false -#verifyica.maven.plugin.log.timing.units=seconds -#verifyica.maven.plugin.log.test.messages=false -#verifyica.maven.plugin.log.test.message=T -#verifyica.maven.plugin.log.pass.messages=false -#verifyica.maven.plugin.log.pass.message=P -#verifyica.maven.plugin.log.skip.messages=false -#verifyica.maven.plugin.log.skip.message=S -#verifyica.maven.plugin.log.fail.message=F -#verifyica.test.class.shuffle=true -#verifyica.test.class.include.regex= -#verifyica.test.class.exclude.regex= -#verifyica.test.class.tag.include.regex= -#verifyica.test.class.tag.exclude.regex= -#verifyica.test.method.include.regex= -#verifyica.test.method.exclude.regex= -#verifyica.test.method.tag.include.regex= -#verifyica.test.method.tag.exclude.regex= From 6f8a3341219e5e99984335c95d96a2162b6a2d49 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 26 Jul 2024 22:39:43 -0400 Subject: [PATCH 70/77] Cleaned up argument parsing. Updated tests Signed-off-by: dhoard --- .../opentelemetry/ExpectedMetricsNames.java | 2 +- .../test/opentelemetry/OpenTelemetryTest.java | 2 +- .../OpenTelemetryTestEnvironment.java | 28 +- .../OpenTelemetryBasicAuthenticationTest.java | 2 +- .../JavaAgent/application.sh | 2 +- .../JavaAgent/application.sh | 2 +- .../java/io/prometheus/jmx/Arguments.java | 147 ++++++++ .../java/io/prometheus/jmx/JavaAgent.java | 116 +++--- .../java/io/prometheus/jmx/ArgumentsTest.java | 333 ++++++++++++++++++ .../jmx/JavaAgentConfigurationRegexTest.java | 66 ---- .../java/io/prometheus/jmx/Arguments.java | 156 ++++++++ .../java/io/prometheus/jmx/Standalone.java | 98 +++--- stress-test.sh | 3 + 13 files changed, 757 insertions(+), 200 deletions(-) create mode 100644 jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java create mode 100644 jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/ArgumentsTest.java delete mode 100644 jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/JavaAgentConfigurationRegexTest.java create mode 100644 jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java index 2b5dbd59..b8e63f5a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/ExpectedMetricsNames.java @@ -14,7 +14,7 @@ public class ExpectedMetricsNames { metricNames.add("io_prometheus_jmx_autoIncrementing_Value"); - // This metric doesn't exist for Java 11+ + // These metric doesn't exist for Java 11+ // metricNames.add("io_prometheus_jmx_optionalValue_Value"); metricNames.add("io_prometheus_jmx_tabularData_Server_1_Disk_Usage_Table_avail"); diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java index 48b8cf11..b8466941 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest.java @@ -160,7 +160,7 @@ public void afterAll(ArgumentContext argumentContext) { */ protected Double getPrometheusMetric( OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String metricName) { - Throttle throttle = new ExponentialBackoffThrottle(100, 6400); + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicReference value = new AtomicReference<>(); for (int i = 0; i < 10; i++) { diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java index 446de79c..ee542fd1 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTestEnvironment.java @@ -101,9 +101,9 @@ public void initialize(Class testClass, Network network) { case JavaAgent: { prometheusContainer = createPrometheusContainer(); - javaAgentApplicationContainer = createJavaAgentApplicationContainer(); - prometheusContainer.start(); + + javaAgentApplicationContainer = createJavaAgentApplicationContainer(); javaAgentApplicationContainer.start(); break; @@ -111,17 +111,30 @@ public void initialize(Class testClass, Network network) { case Standalone: { prometheusContainer = createPrometheusContainer(); - standaloneApplicationContainer = createStandaloneApplicationContainer(); - standaloneExporterContainer = createStandaloneExporterContainer(); - prometheusContainer.start(); + + standaloneApplicationContainer = createStandaloneApplicationContainer(); standaloneApplicationContainer.start(); + + standaloneExporterContainer = createStandaloneExporterContainer(); standaloneExporterContainer.start(); break; } } + if (standaloneApplicationContainer != null && !standaloneApplicationContainer.isRunning()) { + throw new IllegalStateException("standalone exporter container is not running"); + } + + if (standaloneApplicationContainer != null && !standaloneApplicationContainer.isRunning()) { + throw new IllegalStateException("standalone exporter container is not running"); + } + + if (prometheusContainer != null && !prometheusContainer.isRunning()) { + throw new IllegalStateException("standalone exporter container is not running"); + } + httpClient = createPrometheusHttpClient(prometheusContainer, BASE_URL, 9090); } @@ -215,7 +228,10 @@ private GenericContainer createPrometheusContainer() { .withNetwork(network) .withNetworkAliases("prometheus") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) - .withStartupTimeout(Duration.ofMillis(30000)); + .withStartupTimeout(Duration.ofMillis(30000)) + .waitingFor( + Wait.forLogMessage( + ".*Server is ready to receive web requests.*", 1)); if (hasWebYaml) { genericContainer.withClasspathResourceMapping( diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java index 9ad0b648..8b55da0d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest.java @@ -172,7 +172,7 @@ public void afterAll(ArgumentContext argumentContext) { */ protected Double getPrometheusMetric( OpenTelemetryTestEnvironment openTelemetryTestEnvironment, String metricName) { - Throttle throttle = new ExponentialBackoffThrottle(100, 2000); + Throttle throttle = new ExponentialBackoffThrottle(100, 5000); AtomicReference value = new AtomicReference<>(); for (int i = 0; i < 10; i++) { diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh index 9e5717d6..da8a6a08 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/OpenTelemetryTest/JavaAgent/application.sh @@ -2,5 +2,5 @@ java \ -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -javaagent:jmx_prometheus_javaagent.jar=exporter.yaml \ -jar jmx_example_application.jar \ No newline at end of file diff --git a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh index 9e5717d6..da8a6a08 100644 --- a/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh +++ b/integration_test_suite/integration_tests/src/test/resources/io/prometheus/jmx/test/opentelemetry/authentication/OpenTelemetryBasicAuthenticationTest/JavaAgent/application.sh @@ -2,5 +2,5 @@ java \ -Xmx512M \ - -javaagent:jmx_prometheus_javaagent.jar=8888:exporter.yaml \ + -javaagent:jmx_prometheus_javaagent.jar=exporter.yaml \ -jar jmx_example_application.jar \ No newline at end of file diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java new file mode 100644 index 00000000..7a0bc4e4 --- /dev/null +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java @@ -0,0 +1,147 @@ +package io.prometheus.jmx; + +import static java.lang.String.format; + +import io.prometheus.jmx.common.http.ConfigurationException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** Class to implement Arguments */ +public class Arguments { + + private static final String DEFAULT_HOST = "0.0.0.0"; + + public enum Mode { + HTTP, + OPEN_TELEMETRY + } + + private static final String CONFIGURATION_REGEX = + "^(?:((?:[\\w.-]+)|(?:\\[.+])):)?" + + // host name, or ipv4, or ipv6 address in brackets + "(?:(\\d{1,5}):)" + // port + + "(.+)"; // config file + + private final Mode mode; + private final String host; + private final Integer port; + private final String filename; + + /** + * Constructor + * + * @param mode mode + * @param host host + * @param port port + * @param filename filename + */ + private Arguments(Mode mode, String host, Integer port, String filename) { + this.mode = mode; + this.host = host; + this.port = port; + this.filename = filename; + } + + /** + * Method to get the mode inferred by the Java agent arguments + * + * @return the mode + */ + public Mode getMode() { + return mode; + } + + /** + * Method to get the host + * + * @return the host if it exists, else null + */ + public String getHost() { + return host; + } + + /** + * Method to get the port + * + * @return the port if it exists, else null + */ + public Integer getPort() { + return port; + } + + /** + * Method to get the filename + * + * @return the filename + */ + public String getFilename() { + return filename; + } + + /** + * Method to parse the Java Agent configuration arguments + * + * @param agentArgument the Java agent argument + * @return Arguments + */ + public static Arguments parse(String agentArgument) { + if (agentArgument == null || agentArgument.trim().isEmpty()) { + throw new ConfigurationException(format("Malformed arguments [%s]", agentArgument)); + } + + Pattern pattern = Pattern.compile(CONFIGURATION_REGEX); + Matcher matcher = pattern.matcher(agentArgument); + + Mode mode; + String host = null; + Integer port = null; + String filename; + + if (matcher.matches()) { + switch (matcher.groupCount()) { + case 2: + { + mode = Mode.HTTP; + host = DEFAULT_HOST; + + try { + port = Integer.parseInt(matcher.group(1)); + } catch (NumberFormatException e) { + throw new ConfigurationException( + format("Malformed arguments [%s]", agentArgument)); + } + filename = matcher.group(2); + break; + } + case 3: + { + mode = Mode.HTTP; + host = matcher.group(1) != null ? matcher.group(1) : DEFAULT_HOST; + + if (host.startsWith("[") && host.endsWith("]") && host.length() > 3) { + host = host.substring(1, host.length() - 1); + } + + port = Integer.parseInt(matcher.group(2)); + filename = matcher.group(3); + break; + } + default: + { + throw new ConfigurationException( + format("Malformed arguments [%s]", agentArgument)); + } + } + + if (host.trim().isEmpty()) { + throw new ConfigurationException(format("Malformed arguments [%s]", agentArgument)); + } + } else { + mode = Mode.OPEN_TELEMETRY; + filename = agentArgument; + } + + return new Arguments(mode, host, port, filename); + } +} diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index f1328827..f6e52a61 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -16,7 +16,6 @@ package io.prometheus.jmx; -import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; import io.prometheus.metrics.instrumentation.jvm.JvmMetrics; @@ -24,98 +23,71 @@ import java.io.File; import java.lang.instrument.Instrumentation; import java.net.InetAddress; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class JavaAgent { - public static final String CONFIGURATION_REGEX = - "^(?:((?:[\\w.-]+)|(?:\\[.+])):)?" - + // host name, or ipv4, or ipv6 address in brackets - "(\\d{1,5}):" - + // port - "(.+)"; // config file - - private static final String DEFAULT_HOST = "0.0.0.0"; - - public static void agentmain(String agentArgument, Instrumentation instrumentation) - throws Exception { + /** + * Java agent main + * + * @param agentArgument agentArgument + * @param instrumentation instrumentation + */ + public static void agentmain(String agentArgument, Instrumentation instrumentation) { premain(agentArgument, instrumentation); } - public static void premain(String agentArgument, Instrumentation instrumentation) - throws Exception { + /** + * Java agent premain + * + * @param agentArgument agentArgument + * @param instrumentation instrumentation + */ + public static void premain(String agentArgument, Instrumentation instrumentation) { try { - Config config = parseConfig(agentArgument); + Arguments arguments = Arguments.parse(agentArgument); + File file = new File(arguments.getFilename()); new BuildInfoMetrics().register(PrometheusRegistry.defaultRegistry); JvmMetrics.builder().register(PrometheusRegistry.defaultRegistry); - new JmxCollector(new File(config.file), JmxCollector.Mode.AGENT) + new JmxCollector(new File(arguments.getFilename()), JmxCollector.Mode.AGENT) .register(PrometheusRegistry.defaultRegistry); - String host = config.host != null ? config.host : DEFAULT_HOST; - - HTTPServerFactory.getInstance() - .createHTTPServer( - InetAddress.getByName(host), - config.port, - PrometheusRegistry.defaultRegistry, - new File(config.file)); - - OpenTelemetryExporterFactory.getInstance() - .createOpenTelemetryExporter( - PrometheusRegistry.defaultRegistry, new File(config.file)); + switch (arguments.getMode()) { + case HTTP: + { + HTTPServerFactory.getInstance() + .createHTTPServer( + InetAddress.getByName(arguments.getHost()), + arguments.getPort(), + PrometheusRegistry.defaultRegistry, + file); + + break; + } + case OPEN_TELEMETRY: + { + OpenTelemetryExporterFactory.getInstance() + .createOpenTelemetryExporter( + PrometheusRegistry.defaultRegistry, file); + + break; + } + default: + { + throw new RuntimeException("Undefined mode"); + } + } } catch (Throwable t) { synchronized (System.err) { System.err.println("Failed to start Prometheus JMX Exporter"); System.err.println(); - t.printStackTrace(); + t.printStackTrace(System.err); System.err.println(); System.err.println("Prometheus JMX Exporter exiting"); System.err.flush(); } - System.exit(1); - } - } - /** - * Parse the Java Agent configuration. The arguments are typically specified to the JVM as a - * javaagent as {@code -javaagent:/path/to/agent.jar=}. This method parses the {@code - * } portion. - * - * @param args provided agent args - * @return configuration to use for our application - */ - private static Config parseConfig(String args) { - Pattern pattern = Pattern.compile(CONFIGURATION_REGEX); - - Matcher matcher = pattern.matcher(args); - if (!matcher.matches()) { - System.err.println( - "Usage: -javaagent:/path/to/JavaAgent.jar=[host:]: "); - throw new ConfigurationException("Malformed arguments - " + args); - } - - String givenHost = matcher.group(1); - String givenPort = matcher.group(2); - String givenConfigFile = matcher.group(3); - - int port = Integer.parseInt(givenPort); - - return new Config(givenHost, port, givenConfigFile); - } - - private static class Config { - - String host; - int port; - String file; - - Config(String host, int port, String file) { - this.host = host; - this.port = port; - this.file = file; + System.exit(1); } } } diff --git a/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/ArgumentsTest.java b/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/ArgumentsTest.java new file mode 100644 index 00000000..799496d8 --- /dev/null +++ b/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/ArgumentsTest.java @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2023 The Prometheus jmx_exporter Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.prometheus.jmx; + +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +import io.prometheus.jmx.common.http.ConfigurationException; +import org.junit.jupiter.api.Test; + +public class ArgumentsTest { + + private static final boolean VALID_CONFIGURATION = true; + private static final boolean INVALID_CONFIGURATION = false; + + private static final ArgumentsTestDefinition[] ARGUMENTS_TEST_DEFINITIONS = { + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "0.0.0.0", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "0.0.0.0", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "0.0.0.0", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "0.0.0.0", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "0.0.0.0", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhost.domain.com:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "myhost.domain.com", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhost.domain.com:12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "myhost.domain.com", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhost.domain.com:12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "myhost.domain.com", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhost.domain.com:12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "myhost.domain.com", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhost.domain.com:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "myhost.domain.com", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "myhostname.sub-domain.prometheus.org", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub-domain.prometheus.org", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub-domain.prometheus.org", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub-domain.prometheus.org", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "myhostname.sub_domain.prometheus.org", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub_domain.prometheus.org", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub_domain.prometheus.org", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub_domain.prometheus.org", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "myhostname.sub_domain.prometheus.org", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "192.168.1.1:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "192.168.1.1", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[::/0]:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "::/0", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/config_file.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/config_file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/config-file.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/jmx-exporter/config-file.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/jmx-exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "[001:0db8:0a0b:12f0:0000:0000:0000:0001]:12345:/opt/prometheus/jmx_exporter/config-file.yaml", + Arguments.Mode.HTTP, + "001:0db8:0a0b:12f0:0000:0000:0000:0001", + 12345, + "/opt/prometheus/jmx_exporter/config-file.yaml"), + new ArgumentsTestDefinition( + VALID_CONFIGURATION, + "/opt/prometheus/config.yaml", + Arguments.Mode.OPEN_TELEMETRY, + null, + null, + "/opt/prometheus/config.yaml"), + /* + new ArgumentsTestDefinition( + INVALID_CONFIGURATION, + "::/opt/prometheus/config.yaml", + Arguments.Mode.HTTP, + null, + null, + "/opt/prometheus/config.yaml"), + new ArgumentsTestDefinition( + INVALID_CONFIGURATION, + "::/opt/prometheus/config.yaml", + Arguments.Mode.OPEN_TELEMETRY, + null, + null, + "/opt/prometheus/config.yaml")*/ + }; + + @Test + public void testsArguments() { + for (int i = 0; i < ARGUMENTS_TEST_DEFINITIONS.length; i++) { + ArgumentsTestDefinition argumentsTestDefinition = ARGUMENTS_TEST_DEFINITIONS[i]; + System.out.println( + format( + "testing Java agent argument [%d] [%s]", + i, argumentsTestDefinition.getArgument())); + ARGUMENTS_TEST_DEFINITIONS[i].assertValid(); + } + } + + public static class ArgumentsTestDefinition { + + private final String argument; + private final boolean validConfiguration; + private final Arguments.Mode mode; + private final String host; + private final Integer port; + private final String filename; + + public ArgumentsTestDefinition( + boolean validConfiguration, + String argument, + Arguments.Mode mode, + String host, + Integer port, + String filename) { + this.argument = argument; + this.validConfiguration = validConfiguration; + this.mode = mode; + this.host = host; + this.port = port; + this.filename = filename; + } + + public String getArgument() { + return argument; + } + + public void assertValid() { + if (validConfiguration) { + Arguments arguments = Arguments.parse(argument); + assertThat(arguments.getMode()).isEqualTo(mode); + assertThat(arguments.getHost()).isEqualTo(host); + assertThat(arguments.getPort()).isEqualTo(port); + assertThat(arguments.getFilename()).isEqualTo(filename); + } else { + assertThatExceptionOfType(ConfigurationException.class) + .isThrownBy(() -> Arguments.parse(argument)); + } + } + } +} diff --git a/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/JavaAgentConfigurationRegexTest.java b/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/JavaAgentConfigurationRegexTest.java deleted file mode 100644 index 0c1b07dd..00000000 --- a/jmx_prometheus_javaagent/src/test/java/io/prometheus/jmx/JavaAgentConfigurationRegexTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2023 The Prometheus jmx_exporter Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.prometheus.jmx; - -import static org.assertj.core.api.Assertions.fail; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.junit.jupiter.api.Test; - -public class JavaAgentConfigurationRegexTest { - - private static final String[] ARGUMENTS = { - "12345:/opt/prometheus/config.yaml", - "12345:/opt/prometheus/config_file.yaml", - "12345:/opt/prometheus/config-file.yaml", - "12345:/opt/prometheus/jmx-exporter/config-file.yaml", - "12345:/opt/prometheus/jmx_exporter/config-file.yaml", - "myhost.domain.com:12345:/opt/prometheus/config.yaml", - "myhost.domain.com:12345:/opt/prometheus/config_file.yaml", - "myhost.domain.com:12345:/opt/prometheus/config-file.yaml", - "myhost.domain.com:12345:/opt/prometheus/jmx-exporter/config-file.yaml", - "myhost.domain.com:12345:/opt/prometheus/jmx_exporter/config-file.yaml", - "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config.yaml", - "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config_file.yaml", - "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/config-file.yaml", - "myhostname.sub-domain.prometheus.org:12345:/opt/prometheus/jmx-exporter/config-file.yaml", - "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config.yaml", - "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config_file.yaml", - "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/config-file.yaml", - "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/jmx-exporter/config-file.yaml", - "myhostname.sub_domain.prometheus.org:12345:/opt/prometheus/jmx_exporter/config-file.yaml", - "192.168.1.1:12345:/opt/prometheus/config.yaml", - "192.168.1.1:12345:/opt/prometheus/config_file.yaml", - "192.168.1.1:12345:/opt/prometheus/config-file.yaml", - "192.168.1.1:12345:/opt/prometheus/jmx-exporter/config-file.yaml", - "192.168.1.1:12345:/opt/prometheus/jmx_exporter/config-file.yaml" - }; - - @Test - public void testConfigurationRegex() { - Pattern pattern = Pattern.compile(JavaAgent.CONFIGURATION_REGEX); - Matcher matcher = pattern.matcher(""); - - for (String argument : ARGUMENTS) { - matcher.reset(argument); - if (!matcher.matches()) { - fail(String.format("Expected a match for [%s]", argument)); - } - } - } -} diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java new file mode 100644 index 00000000..f8a0feed --- /dev/null +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java @@ -0,0 +1,156 @@ +package io.prometheus.jmx; + +import static java.lang.String.format; + +import io.prometheus.jmx.common.http.ConfigurationException; + +/** Class to implement Arguments */ +public class Arguments { + + private static final String DEFAULT_HOST = "0.0.0.0"; + + public enum Mode { + HTTP, + OPEN_TELEMETRY + } + + private final Mode mode; + private final String host; + private final Integer port; + private final String filename; + + /** + * Constructor + * + * @param mode mode + * @param host host + * @param port port + * @param filename filename + */ + private Arguments(Mode mode, String host, Integer port, String filename) { + this.mode = mode; + this.host = host; + this.port = port; + this.filename = filename; + } + + /** + * Method to get the mode inferred by the Java agent arguments + * + * @return + */ + public Mode getMode() { + return mode; + } + + /** + * Method to get the host + * + * @return the host if it exists, else null + */ + public String getHost() { + return host; + } + + /** + * Method to get the port + * + * @return the port if it exists, else null + */ + public Integer getPort() { + return port; + } + + /** + * Method to get the filename + * + * @return the filename + */ + public String getFilename() { + return filename; + } + + /** + * Method to parse the Java Standalone configuration arguments + * + * @param arguments the Java arguments + * @return Arguments + */ + public static Arguments parse(String[] arguments) { + if (arguments == null || arguments.length == 0) { + throw new ConfigurationException( + format("Malformed arguments [%s]", toString(arguments))); + } + + for (String argument : arguments) { + if (argument == null || argument.trim().isEmpty()) { + throw new ConfigurationException( + format("Malformed arguments [%s]", toString(arguments))); + } + } + + Mode mode; + String host = null; + Integer port = null; + String filename; + + if (arguments.length == 2) { + mode = Mode.HTTP; + filename = arguments[1]; + } else { + mode = Mode.OPEN_TELEMETRY; + filename = arguments[0]; + } + + switch (mode) { + case HTTP: + { + host = DEFAULT_HOST; + + int colonIndex = arguments[0].lastIndexOf(':'); + + try { + if (colonIndex < 0) { + port = Integer.parseInt(arguments[0]); + } else { + port = Integer.parseInt(arguments[0].substring(colonIndex + 1)); + host = arguments[0].substring(0, colonIndex); + } + } catch (NumberFormatException e) { + throw new ConfigurationException( + format("Malformed arguments [%s]", toString(arguments))); + } + + break; + } + case OPEN_TELEMETRY: + { + // INTENTIONALLY BLANK + break; + } + default: + { + throw new ConfigurationException( + format("Malformed arguments [%s]", toString(arguments))); + } + } + + return new Arguments(mode, host, port, filename); + } + + private static String toString(String[] strings) { + if (strings == null) { + return null; + } + + StringBuilder stringBuilder = new StringBuilder(); + for (String string : strings) { + if (stringBuilder.length() > 0) { + stringBuilder.append(" "); + } + stringBuilder.append(string); + } + + return stringBuilder.toString(); + } +} diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java index deb8c355..2c10b3bb 100644 --- a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java @@ -16,6 +16,8 @@ package io.prometheus.jmx; +import static java.lang.String.format; + import io.prometheus.jmx.common.http.ConfigurationException; import io.prometheus.jmx.common.http.HTTPServerFactory; import io.prometheus.jmx.common.opentelemetry.OpenTelemetryExporterFactory; @@ -29,18 +31,18 @@ import java.util.Date; import java.util.Locale; +/** Class to implement Standalone */ public class Standalone { - private static final String DEFAULT_HOST = "0.0.0.0"; - private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd | HH:mm:ss.SSS", Locale.getDefault()); - private enum Mode { - HTTP, - OPEN_TELEMETRY - } - + /** + * Main method + * + * @param args args + * @throws Exception Exception + */ public static void main(String[] args) throws Exception { HTTPServer httpServer = null; OpenTelemetryExporter openTelemetryExporter = null; @@ -52,73 +54,57 @@ public static void main(String[] args) throws Exception { System.exit(1); } - Mode mode; - if (args.length == 2) { - mode = Mode.HTTP; - } else { - mode = Mode.OPEN_TELEMETRY; - } - try { + Arguments arguments = Arguments.parse(args); + File file = new File(arguments.getFilename()); + new BuildInfoMetrics().register(PrometheusRegistry.defaultRegistry); + new JmxCollector(file, JmxCollector.Mode.STANDALONE) + .register(PrometheusRegistry.defaultRegistry); - switch (mode) { + switch (arguments.getMode()) { case HTTP: { - String host = DEFAULT_HOST; - int port; - int colonIndex = args[0].lastIndexOf(':'); - - if (colonIndex < 0) { - port = Integer.parseInt(args[0]); - } else { - port = Integer.parseInt(args[0].substring(colonIndex + 1)); - host = args[0].substring(0, colonIndex); - } - - new JmxCollector(new File(args[1]), JmxCollector.Mode.STANDALONE) - .register(PrometheusRegistry.defaultRegistry); - httpServer = HTTPServerFactory.getInstance() .createHTTPServer( - InetAddress.getByName(host), - port, + InetAddress.getByName(arguments.getHost()), + arguments.getPort(), PrometheusRegistry.defaultRegistry, - new File(args[1])); + file); break; } case OPEN_TELEMETRY: { - new JmxCollector(new File(args[0]), JmxCollector.Mode.STANDALONE) - .register(PrometheusRegistry.defaultRegistry); - openTelemetryExporter = OpenTelemetryExporterFactory.getInstance() .createOpenTelemetryExporter( - PrometheusRegistry.defaultRegistry, - new File(args[0])); + PrometheusRegistry.defaultRegistry, file); + break; + } + default: + { + throw new RuntimeException("Undefined mode"); } } - System.out.println( - String.format( - "%s | %s | INFO | %s | %s (%s)", - SIMPLE_DATE_FORMAT.format(new Date()), - Thread.currentThread().getName(), - Standalone.class.getName(), - "Running", - mode == Mode.HTTP ? "HTTP" : "OpenTelemetry")); + info( + "Running (%s)", + arguments.getMode() == Arguments.Mode.HTTP ? "HTTP" : "OpenTelemetry"); Thread.currentThread().join(); } catch (ConfigurationException e) { - System.err.println("Configuration Exception : " + e.getMessage()); - e.printStackTrace(System.err); - System.exit(1); + synchronized (System.err) { + System.err.println("Configuration Exception : " + e.getMessage()); + e.printStackTrace(System.err); + System.exit(1); + } } catch (Throwable t) { - System.err.println("Exception starting"); - t.printStackTrace(System.err); - System.exit(1); + synchronized (System.err) { + System.err.println("Exception starting"); + t.printStackTrace(System.err); + System.exit(1); + } } finally { if (openTelemetryExporter != null) { openTelemetryExporter.close(); @@ -128,4 +114,14 @@ public static void main(String[] args) throws Exception { } } } + + private static void info(String format, Object... objects) { + System.out.println( + format( + "%s | %s | INFO | %s | %s", + SIMPLE_DATE_FORMAT.format(new Date()), + Thread.currentThread().getName(), + Standalone.class.getName(), + format(format, objects))); + } } diff --git a/stress-test.sh b/stress-test.sh index 38ecca85..b743484f 100755 --- a/stress-test.sh +++ b/stress-test.sh @@ -22,6 +22,9 @@ # ( + export JAVA_DOCKER_IMAGES=ALL + export PROMETHEUS_DOCKER_IMAGES=ALL + while true; do DATE=`date` From 746ba2e0d13b6be9cf4a2ce46688d9a430460541 Mon Sep 17 00:00:00 2001 From: dhoard Date: Fri, 2 Aug 2024 01:31:39 -0400 Subject: [PATCH 71/77] Updated Verifyica test engine version Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- .../io/prometheus/jmx/test/common/AbstractExporterTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index f05ceee4..514cb436 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.4 + 0.0.5 diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java index 7c420f0d..e4c47a52 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/AbstractExporterTest.java @@ -73,7 +73,7 @@ public static void prepare(ClassContext classContext) { @Verifyica.BeforeAll public void beforeAll(ArgumentContext argumentContext) { - Network network = argumentContext.getClassContext().getStore().get(NETWORK); + Network network = argumentContext.getClassContext().getStore().get(NETWORK, Network.class); Class testClass = argumentContext.getClassContext().getTestClass(); argumentContext From 01bfc9283d209decc65531f4bc0f129314246baa Mon Sep 17 00:00:00 2001 From: dhoard Date: Sun, 4 Aug 2024 15:56:55 -0400 Subject: [PATCH 72/77] Changed/fix shell script Signed-off-by: dhoard --- ...pserver_sample_config.yml => standalone_sample_config.yml} | 0 run_sample_httpserver.sh => run_sample_standalone.sh | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename example_configs/{httpserver_sample_config.yml => standalone_sample_config.yml} (100%) rename run_sample_httpserver.sh => run_sample_standalone.sh (75%) diff --git a/example_configs/httpserver_sample_config.yml b/example_configs/standalone_sample_config.yml similarity index 100% rename from example_configs/httpserver_sample_config.yml rename to example_configs/standalone_sample_config.yml diff --git a/run_sample_httpserver.sh b/run_sample_standalone.sh similarity index 75% rename from run_sample_httpserver.sh rename to run_sample_standalone.sh index 53fd32f4..25aa5a4c 100755 --- a/run_sample_httpserver.sh +++ b/run_sample_standalone.sh @@ -2,7 +2,7 @@ # Script to run a java application for testing the Prometheus JMX Standalone exporter. -VERSION=$(sed -n -e 's#.*\(.*-SNAPSHOT\)#\1#p' pom.xml) +VERSION=$(grep "" pom.xml | head -1 | sed -n 's/.*\(.*\)<\/version>.*/\1/p') # Note: You can use localhost:5556 instead of 5556 for configuring socket hostname. @@ -11,4 +11,4 @@ java \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.port=5555 \ -jar jmx_prometheus_standalone/target/jmx_prometheus_standalone-"${VERSION}".jar 5556 \ - example_configs/httpserver_sample_config.yml + example_configs/standalone_sample_config.yml From 4cc136905c04f13cdefebe64c38d2cc07fa446a3 Mon Sep 17 00:00:00 2001 From: dhoard Date: Sun, 4 Aug 2024 15:58:16 -0400 Subject: [PATCH 73/77] Fixed usage information Signed-off-by: dhoard --- tools/patch-and-run-integration-test-suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/patch-and-run-integration-test-suite.sh b/tools/patch-and-run-integration-test-suite.sh index 880baa12..ed981a53 100755 --- a/tools/patch-and-run-integration-test-suite.sh +++ b/tools/patch-and-run-integration-test-suite.sh @@ -21,7 +21,7 @@ PROJECT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel) if [ "$#" -ne 2 ]; then - echo "Usage: ${0} " + echo "Usage: ${0} " exit 1 fi @@ -60,7 +60,7 @@ then emit_error "Java agent jar mismatch" fi -# Validate the java httpserver jar version +# Validate the java standalone jar version DOWNLOAD_STANDALONE_JAR_SHA256=$(sha256sum "${STANDALONE_JAR}") INTEGRATION_STANDALONE_JAR_SHA256=$(sha256sum ./integration_tests/src/test/resources/common/jmx_prometheus_standalone.jar) From a08970bb4757aa3d9551462148e455662b3b3d7a Mon Sep 17 00:00:00 2001 From: dhoard Date: Mon, 5 Aug 2024 08:48:47 -0400 Subject: [PATCH 74/77] Changed per code review Signed-off-by: dhoard --- .../integration_tests/pom.xml | 2 +- .../java/io/prometheus/jmx/Arguments.java | 7 ++- .../java/io/prometheus/jmx/JavaAgent.java | 34 ++++--------- .../java/io/prometheus/jmx/Arguments.java | 50 +++++++------------ .../java/io/prometheus/jmx/Standalone.java | 37 +++++--------- 5 files changed, 46 insertions(+), 84 deletions(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 514cb436..27c0452e 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.5 + 0.0.6-SNAPSHOT diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java index 7a0bc4e4..d54db949 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/Arguments.java @@ -130,12 +130,15 @@ public static Arguments parse(String agentArgument) { default: { throw new ConfigurationException( - format("Malformed arguments [%s]", agentArgument)); + format( + "Malformed arguments for Standalone HTTP mode [%s]", + agentArgument)); } } if (host.trim().isEmpty()) { - throw new ConfigurationException(format("Malformed arguments [%s]", agentArgument)); + throw new ConfigurationException( + format("Malformed arguments for Standalone HTTP mode [%s]", agentArgument)); } } else { mode = Mode.OPEN_TELEMETRY; diff --git a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java index f6e52a61..1ba7ae3f 100644 --- a/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java +++ b/jmx_prometheus_javaagent/src/main/java/io/prometheus/jmx/JavaAgent.java @@ -52,30 +52,16 @@ public static void premain(String agentArgument, Instrumentation instrumentation new JmxCollector(new File(arguments.getFilename()), JmxCollector.Mode.AGENT) .register(PrometheusRegistry.defaultRegistry); - switch (arguments.getMode()) { - case HTTP: - { - HTTPServerFactory.getInstance() - .createHTTPServer( - InetAddress.getByName(arguments.getHost()), - arguments.getPort(), - PrometheusRegistry.defaultRegistry, - file); - - break; - } - case OPEN_TELEMETRY: - { - OpenTelemetryExporterFactory.getInstance() - .createOpenTelemetryExporter( - PrometheusRegistry.defaultRegistry, file); - - break; - } - default: - { - throw new RuntimeException("Undefined mode"); - } + if (arguments.getMode() == Arguments.Mode.HTTP) { + HTTPServerFactory.getInstance() + .createHTTPServer( + InetAddress.getByName(arguments.getHost()), + arguments.getPort(), + PrometheusRegistry.defaultRegistry, + file); + } else { + OpenTelemetryExporterFactory.getInstance() + .createOpenTelemetryExporter(PrometheusRegistry.defaultRegistry, file); } } catch (Throwable t) { synchronized (System.err) { diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java index f8a0feed..b9ecc270 100644 --- a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Arguments.java @@ -96,45 +96,29 @@ public static Arguments parse(String[] arguments) { if (arguments.length == 2) { mode = Mode.HTTP; + + host = DEFAULT_HOST; + + int colonIndex = arguments[0].lastIndexOf(':'); + + try { + if (colonIndex < 0) { + port = Integer.parseInt(arguments[0]); + } else { + port = Integer.parseInt(arguments[0].substring(colonIndex + 1)); + host = arguments[0].substring(0, colonIndex); + } + } catch (NumberFormatException e) { + throw new ConfigurationException( + format("Malformed arguments [%s]", toString(arguments))); + } + filename = arguments[1]; } else { mode = Mode.OPEN_TELEMETRY; filename = arguments[0]; } - switch (mode) { - case HTTP: - { - host = DEFAULT_HOST; - - int colonIndex = arguments[0].lastIndexOf(':'); - - try { - if (colonIndex < 0) { - port = Integer.parseInt(arguments[0]); - } else { - port = Integer.parseInt(arguments[0].substring(colonIndex + 1)); - host = arguments[0].substring(0, colonIndex); - } - } catch (NumberFormatException e) { - throw new ConfigurationException( - format("Malformed arguments [%s]", toString(arguments))); - } - - break; - } - case OPEN_TELEMETRY: - { - // INTENTIONALLY BLANK - break; - } - default: - { - throw new ConfigurationException( - format("Malformed arguments [%s]", toString(arguments))); - } - } - return new Arguments(mode, host, port, filename); } diff --git a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java index 2c10b3bb..02943d58 100644 --- a/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java +++ b/jmx_prometheus_standalone/src/main/java/io/prometheus/jmx/Standalone.java @@ -62,30 +62,19 @@ public static void main(String[] args) throws Exception { new JmxCollector(file, JmxCollector.Mode.STANDALONE) .register(PrometheusRegistry.defaultRegistry); - switch (arguments.getMode()) { - case HTTP: - { - httpServer = - HTTPServerFactory.getInstance() - .createHTTPServer( - InetAddress.getByName(arguments.getHost()), - arguments.getPort(), - PrometheusRegistry.defaultRegistry, - file); - break; - } - case OPEN_TELEMETRY: - { - openTelemetryExporter = - OpenTelemetryExporterFactory.getInstance() - .createOpenTelemetryExporter( - PrometheusRegistry.defaultRegistry, file); - break; - } - default: - { - throw new RuntimeException("Undefined mode"); - } + if (arguments.getMode() == Arguments.Mode.HTTP) { + httpServer = + HTTPServerFactory.getInstance() + .createHTTPServer( + InetAddress.getByName(arguments.getHost()), + arguments.getPort(), + PrometheusRegistry.defaultRegistry, + file); + } else { + openTelemetryExporter = + OpenTelemetryExporterFactory.getInstance() + .createOpenTelemetryExporter( + PrometheusRegistry.defaultRegistry, file); } info( From 6c84cbb3b1fc36a4d171052c848c4cbcc64eea0c Mon Sep 17 00:00:00 2001 From: dhoard Date: Tue, 6 Aug 2024 00:04:21 -0400 Subject: [PATCH 75/77] Rolled Verifyica version Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 27c0452e..514cb436 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.6-SNAPSHOT + 0.0.5 From f577cf0beab74f49e610c1c4331d102ecc019d5a Mon Sep 17 00:00:00 2001 From: dhoard Date: Wed, 7 Aug 2024 01:22:42 -0400 Subject: [PATCH 76/77] Updated Verifyica test engine version Signed-off-by: dhoard --- integration_test_suite/integration_tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test_suite/integration_tests/pom.xml b/integration_test_suite/integration_tests/pom.xml index 514cb436..3583b0b5 100644 --- a/integration_test_suite/integration_tests/pom.xml +++ b/integration_test_suite/integration_tests/pom.xml @@ -28,7 +28,7 @@ 11 UTF-8 UTF-8 - 0.0.5 + 0.0.6 From 7b98afedb4b7a3a1dad5f8c359d0690735d55f67 Mon Sep 17 00:00:00 2001 From: dhoard Date: Thu, 8 Aug 2024 01:37:24 -0400 Subject: [PATCH 77/77] Fixed container startup check Signed-off-by: dhoard --- .../prometheus/jmx/test/common/ExporterTestEnvironment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java index ba0f45ce..1a5e6c73 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/common/ExporterTestEnvironment.java @@ -220,7 +220,8 @@ private GenericContainer createStandaloneApplicationContainer() { .withNetworkAliases("application") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); + .withWorkingDirectory("/temp") + .waitingFor(Wait.forLogMessage(".*Running.*", 1)); } /** @@ -261,7 +262,8 @@ private GenericContainer createStandaloneExporterContainer() { .withNetworkAliases("exporter") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()) .withStartupTimeout(Duration.ofMillis(30000)) - .withWorkingDirectory("/temp"); + .withWorkingDirectory("/temp") + .waitingFor(Wait.forLogMessage(".*Running.*", 1)); } /**