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);