From 41540dc5a8c73ecfd22c34b2f559a75f56bd2bc1 Mon Sep 17 00:00:00 2001 From: Doug Hoard Date: Mon, 9 Dec 2024 22:33:48 -0500 Subject: [PATCH] Refactored integration tests to get the build info name from a common location (#1094) Signed-off-by: dhoard --- docs/content/1.1.0/_index.md | 2 +- docs/content/older-versions/_index.md | 2 +- .../test/support/metrics/MetricsParser.java | 33 ++++++++----------- .../test/core/AutoIncrementingMBeanTest.java | 4 +-- .../prometheus/jmx/test/core/BasicTest.java | 4 +-- .../jmx/test/core/OptionalValueMBeanTest.java | 4 +-- .../CompleteHttpServerConfigurationTest.java | 4 +-- .../AuthenticatorPluginTest.java | 4 +-- ...cAuthenticationPBKDF2WithHmacSHA1Test.java | 4 +-- ...uthenticationPBKDF2WithHmacSHA256Test.java | 4 +-- ...uthenticationPBKDF2WithHmacSHA512Test.java | 4 +-- .../BasicAuthenticationPlaintextTest.java | 4 +-- .../BasicAuthenticationSHA1Test.java | 4 +-- .../BasicAuthenticationSHA256Test.java | 4 +-- .../BasicAuthenticationSHA512Test.java | 4 +-- ...uthenticationPBKDF2WithHmacSHA512Test.java | 4 +-- ...thJKSKeyStoreMultipleCertificatesTest.java | 4 +-- .../test/http/ssl/SSLWithJKSKeyStoreTest.java | 4 +-- .../http/ssl/SSLWithJKSKeyStoreTest2.java | 4 +-- ...KCS12KeyStoreMultipleCertificatesTest.java | 4 +-- .../http/ssl/SSLWithPKCS12KeyStoreTest.java | 4 +-- .../http/ssl/SSLWithPKCS12KeyStoreTest2.java | 4 +-- .../threads/ThreadsConfigurationTest.java | 4 +-- .../test/opentelemetry/CombinedModeTest.java | 4 +-- .../jmx/test/rmi/ssl/MinimalRMISSLTest.java | 4 +-- .../rmi/ssl/RMIRegistrySSLDisabledTest.java | 4 +-- .../jmx/test/support/TestSupport.java | 16 +++++++++ 27 files changed, 54 insertions(+), 91 deletions(-) diff --git a/docs/content/1.1.0/_index.md b/docs/content/1.1.0/_index.md index dc4a43e1..94654f13 100644 --- a/docs/content/1.1.0/_index.md +++ b/docs/content/1.1.0/_index.md @@ -1,6 +1,6 @@ --- title: "JMX Exporter 1.1.0" -weight: 1 +weight: 2 geekdocCollapseSection: true --- diff --git a/docs/content/older-versions/_index.md b/docs/content/older-versions/_index.md index 083c85a1..aa448e54 100644 --- a/docs/content/older-versions/_index.md +++ b/docs/content/older-versions/_index.md @@ -1,6 +1,6 @@ --- title: "Versions < 1.1.0" -weight: 2 +weight: 100 --- Documentation for previous JMX Exporter versions can be found in associated release branches. 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 1d081d59..d11763ce 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 @@ -92,8 +92,6 @@ public static Collection parseCollection(HttpResponse httpResponse) { * @return a Collection of Metrics */ private static Collection parseTextMetrics(String body) { - // System.out.println("DEBUG parseTextMetrics()"); - Collection metrics = new ArrayList<>(); try (LineReader lineReader = new LineReader(new StringReader(body))) { @@ -124,8 +122,6 @@ private static Collection parseTextMetrics(String body) { } private static Collection parseOpenMetricsTextMetrics(String body) { - // System.out.println("DEBUG parseOpenMetricsTextMetrics()"); - Collection metrics = new ArrayList<>(); String line; @@ -141,8 +137,6 @@ private static Collection parseOpenMetricsTextMetrics(String body) { break; } - // System.out.printf("LINE > %s%n", line); - if (line.startsWith("# EOF")) { break; } @@ -173,21 +167,11 @@ private static Collection parseOpenMetricsTextMetrics(String body) { lineReader.unreadLine(line); break; } else { - // System.out.printf("LINE > %s%n", line); - /* - System.out.println("CREATE METRIC"); - System.out.printf(" > %s%n", typeLine); - System.out.printf(" > %s%n", helpLine); - System.out.printf(" > %s%n", line); - */ - if (type.equals("INFO")) { type = "GAUGE"; } - Metric metric = createMetric(type, help, line); - // System.out.printf(" > %s%n", metric); - metrics.add(metric); + metrics.add(createMetric(type, help, line)); } } } @@ -205,8 +189,6 @@ private static Collection parseOpenMetricsTextMetrics(String body) { * @return a Collection of metrics */ private static Collection parseProtobufMetrics(byte[] bytes) { - // System.out.println("DEBUG parseProtobufMetrics()"); - Collection collection = new ArrayList<>(); try (InputStream inputStream = new ByteArrayInputStream(bytes)) { @@ -265,15 +247,26 @@ private static Collection parseProtobufMetrics(byte[] bytes) { break; } + case SUMMARY: + { + // TODO refactor to support Summary metrics + break; + } default: { - // TODO ignore? + throw new MetricsParserException( + format( + "Exception parsing Protobuf metrics. MetricsParser" + + " doesn't support metric type [%s]", + metricType)); } } } } return collection; + } catch (MetricsParserException e) { + throw e; } catch (Throwable t) { throw new MetricsParserException("Exception parsing Protobuf metrics", t); } diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/AutoIncrementingMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/AutoIncrementingMBeanTest.java index 7027acb3..47555b35 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/AutoIncrementingMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/AutoIncrementingMBeanTest.java @@ -196,9 +196,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/BasicTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/BasicTest.java index adbe3d97..0b547d4a 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/BasicTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/BasicTest.java @@ -178,9 +178,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/OptionalValueMBeanTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/OptionalValueMBeanTest.java index 1f482e09..8a910668 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/OptionalValueMBeanTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/core/OptionalValueMBeanTest.java @@ -157,9 +157,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 1b16d622..6a5a0b0f 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 @@ -275,9 +275,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AuthenticatorPluginTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AuthenticatorPluginTest.java index 5a6720fb..e9b891d5 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AuthenticatorPluginTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/http/authentication/AuthenticatorPluginTest.java @@ -268,9 +268,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 1df31baa..4bf6a845 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 @@ -286,9 +286,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 bc5a407a..791424a5 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 @@ -286,9 +286,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 e5cc4342..4cc72870 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 @@ -286,9 +286,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 68ae523b..0c6b37e8 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 @@ -264,9 +264,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 b38115aa..5a223f80 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 @@ -264,9 +264,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 9a1687db..6befeffb 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 @@ -264,9 +264,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 f77b2d1c..522b2a28 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 @@ -264,9 +264,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 d8e53fd2..c76f7a40 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 @@ -295,9 +295,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 f17b034b..1b2c91f1 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 @@ -189,9 +189,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 b449edaa..7c7ea0cf 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 @@ -189,9 +189,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 67c1074a..cda73417 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 @@ -189,9 +189,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 a0b9b501..dca81188 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 @@ -185,9 +185,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 1868e6b4..e2c3f023 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 @@ -185,9 +185,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 77e697cd..04a3c25f 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 @@ -184,9 +184,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 811542ae..fcfd50ff 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 @@ -157,9 +157,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/CombinedModeTest.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/CombinedModeTest.java index ed7398cd..f7a51e9d 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/CombinedModeTest.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/opentelemetry/CombinedModeTest.java @@ -230,9 +230,7 @@ private void assertMetricsResponse( openTelemetryTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(openTelemetryTestEnvironment.getJmxExporterMode()); 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 0521a8f3..d5500c10 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 @@ -174,9 +174,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); 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 dffabd49..d2c3ea66 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 @@ -174,9 +174,7 @@ private void assertMetricsResponse( exporterTestEnvironment.getJmxExporterMode() == JmxExporterMode.JavaAgent; String buildInfoName = - isJmxExporterModeJavaAgent - ? "jmx_prometheus_javaagent" - : "jmx_prometheus_standalone"; + TestSupport.getBuildInfoName(exporterTestEnvironment.getJmxExporterMode()); assertMetric(metrics) .ofType(Metric.Type.GAUGE) diff --git a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/support/TestSupport.java b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/support/TestSupport.java index 6ec4545a..b487d614 100644 --- a/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/support/TestSupport.java +++ b/integration_test_suite/integration_tests/src/test/java/io/prometheus/jmx/test/support/TestSupport.java @@ -11,6 +11,10 @@ public class TestSupport { /** Network configuration constant */ public static final String NETWORK = "network"; + private static final String BUILD_INFO_JAVAAGENT = "jmx_prometheus_javaagent"; + + private static final String BUILD_INFO_STANDALONE = "jmx_prometheus_standalone"; + /** Constructor */ private TestSupport() { // INTENTIONALLY BLANK @@ -124,4 +128,16 @@ public static void destroyNetwork(ClassContext classContext) { Optional.ofNullable(classContext.map().removeAs(NETWORK, Network.class)) .ifPresent(Network::close); } + + /** + * Method to get the build info name based on the JMX exporter mode + * + * @param jmxExporterMode jmxExporterMode + * @return the build info name + */ + public static String getBuildInfoName(JmxExporterMode jmxExporterMode) { + return jmxExporterMode == JmxExporterMode.JavaAgent + ? BUILD_INFO_JAVAAGENT + : BUILD_INFO_STANDALONE; + } }