Skip to content

Commit

Permalink
Use fixed version of Prometheus image for IT
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shakuzen committed Nov 15, 2024
1 parent c898032 commit bd90d13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions implementations/micrometer-registry-prometheus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ dependencies {
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.awaitility:awaitility'
}

dockerTest {
systemProperty 'prometheus.version', 'v2.55.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
Expand Down

0 comments on commit bd90d13

Please sign in to comment.