Skip to content

Commit bd90d13

Browse files
committed
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
1 parent c898032 commit bd90d13

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

implementations/micrometer-registry-prometheus/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ dependencies {
1818
testImplementation 'org.testcontainers:junit-jupiter'
1919
testImplementation 'org.awaitility:awaitility'
2020
}
21+
22+
dockerTest {
23+
systemProperty 'prometheus.version', 'v2.55.1'
24+
}

implementations/micrometer-registry-prometheus/src/test/java/io/micrometer/prometheusmetrics/PrometheusMeterRegistryIntegrationTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
class PrometheusMeterRegistryIntegrationTest {
5858

5959
@Container
60-
static GenericContainer<?> prometheus = new GenericContainer<>(DockerImageName.parse("prom/prometheus:latest"))
60+
static GenericContainer<?> prometheus = new GenericContainer<>(
61+
DockerImageName.parse("prom/prometheus:" + getPrometheusImageVersion()))
6162
.withCommand("--config.file=/etc/prometheus/prometheus.yml")
6263
.withClasspathResourceMapping("prometheus.yml", "/etc/prometheus/prometheus.yml", READ_ONLY)
6364
.waitingFor(Wait.forLogMessage(".*Server is ready to receive web requests.*", 1))
@@ -72,6 +73,15 @@ class PrometheusMeterRegistryIntegrationTest {
7273
@Nullable
7374
private HttpServer prometheusTextServer;
7475

76+
private static String getPrometheusImageVersion() {
77+
String version = System.getProperty("prometheus.version");
78+
if (version == null) {
79+
throw new IllegalStateException(
80+
"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.");
81+
}
82+
return version;
83+
}
84+
7585
@BeforeEach
7686
void setUp() {
7787
org.testcontainers.Testcontainers.exposeHostPorts(12345, 12346);

0 commit comments

Comments
 (0)