From bd90d13e2708638594525d797b92156e1a5adfd8 Mon Sep 17 00:00:00 2001 From: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:58:25 +0900 Subject: [PATCH] Use fixed version of Prometheus image for IT The dynamic version caused build failures even though nothing was changed due to a new major version of Prometheus released. This uses a fixed version to allow the build to pass and avoid such issues with non-reproducible builds. Resolves gh-5665 --- .../micrometer-registry-prometheus/build.gradle | 4 ++++ .../PrometheusMeterRegistryIntegrationTest.java | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/implementations/micrometer-registry-prometheus/build.gradle b/implementations/micrometer-registry-prometheus/build.gradle index cad117908b..c91ceb20a9 100644 --- a/implementations/micrometer-registry-prometheus/build.gradle +++ b/implementations/micrometer-registry-prometheus/build.gradle @@ -18,3 +18,7 @@ dependencies { testImplementation 'org.testcontainers:junit-jupiter' testImplementation 'org.awaitility:awaitility' } + +dockerTest { + systemProperty 'prometheus.version', 'v2.55.1' +} diff --git a/implementations/micrometer-registry-prometheus/src/test/java/io/micrometer/prometheusmetrics/PrometheusMeterRegistryIntegrationTest.java b/implementations/micrometer-registry-prometheus/src/test/java/io/micrometer/prometheusmetrics/PrometheusMeterRegistryIntegrationTest.java index 6614b12578..b670e166ef 100644 --- a/implementations/micrometer-registry-prometheus/src/test/java/io/micrometer/prometheusmetrics/PrometheusMeterRegistryIntegrationTest.java +++ b/implementations/micrometer-registry-prometheus/src/test/java/io/micrometer/prometheusmetrics/PrometheusMeterRegistryIntegrationTest.java @@ -57,7 +57,8 @@ class PrometheusMeterRegistryIntegrationTest { @Container - static GenericContainer prometheus = new GenericContainer<>(DockerImageName.parse("prom/prometheus:latest")) + static GenericContainer prometheus = new GenericContainer<>( + DockerImageName.parse("prom/prometheus:" + getPrometheusImageVersion())) .withCommand("--config.file=/etc/prometheus/prometheus.yml") .withClasspathResourceMapping("prometheus.yml", "/etc/prometheus/prometheus.yml", READ_ONLY) .waitingFor(Wait.forLogMessage(".*Server is ready to receive web requests.*", 1)) @@ -72,6 +73,15 @@ class PrometheusMeterRegistryIntegrationTest { @Nullable private HttpServer prometheusTextServer; + private static String getPrometheusImageVersion() { + String version = System.getProperty("prometheus.version"); + if (version == null) { + throw new IllegalStateException( + "System property 'prometheus.version' is not set. This should be set in the build configuration for running from the command line. If you are running PrometheusMeterRegistryIntegrationTest from an IDE, set the system property to the desired prom/prometheus image version."); + } + return version; + } + @BeforeEach void setUp() { org.testcontainers.Testcontainers.exposeHostPorts(12345, 12346);