Skip to content

Commit 319e33f

Browse files
committed
Make a single scrape attempt, protected by Awaitility
Using a single scrape attempt that is protected by Awaitility should protect against instability of the OpenTelemetry Collector instance running in the container and will hopefully stabilize the test. This commit has also increased the timeout for a successful response to 30 seconds and removed the configuration of the configuration of the polling delay and interval as the values being set were the same as the defaults. Closes gh-42377
1 parent 87c647c commit 319e33f

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,20 @@ void connectionCanBeMadeToOpenTelemetryCollectorContainer() {
8080
Timer.builder("test.timer").register(this.meterRegistry).record(Duration.ofMillis(123));
8181
DistributionSummary.builder("test.distributionsummary").register(this.meterRegistry).record(24);
8282
Awaitility.await()
83-
.atMost(Duration.ofSeconds(5))
84-
.pollDelay(Duration.ofMillis(100))
85-
.pollInterval(Duration.ofMillis(100))
83+
.atMost(Duration.ofSeconds(30))
8684
.untilAsserted(() -> whenPrometheusScraped().then()
8785
.statusCode(200)
8886
.contentType(OPENMETRICS_001)
89-
.body(endsWith("# EOF\n"), containsString("service_name")));
90-
whenPrometheusScraped().then()
91-
.body(containsString(
92-
"{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""),
93-
matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"),
94-
matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"),
95-
matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"),
96-
matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"),
97-
matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"),
98-
matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"),
99-
matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"),
100-
matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"));
87+
.body(endsWith("# EOF\n"), containsString(
88+
"{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""),
89+
matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"),
90+
matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"),
91+
matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"),
92+
matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"),
93+
matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"),
94+
matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"),
95+
matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"),
96+
matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$")));
10197
}
10298

10399
private Response whenPrometheusScraped() {

0 commit comments

Comments
 (0)