From 319e33f786ad7a8fd050a5e0540c4a05e25c247b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 19 Sep 2024 15:23:47 +0100 Subject: [PATCH] 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 --- ...nectionDetailsFactoryIntegrationTests.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java index c48d6a2135ce..50b558711ebc 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java @@ -80,24 +80,20 @@ void connectionCanBeMadeToOpenTelemetryCollectorContainer() { Timer.builder("test.timer").register(this.meterRegistry).record(Duration.ofMillis(123)); DistributionSummary.builder("test.distributionsummary").register(this.meterRegistry).record(24); Awaitility.await() - .atMost(Duration.ofSeconds(5)) - .pollDelay(Duration.ofMillis(100)) - .pollInterval(Duration.ofMillis(100)) + .atMost(Duration.ofSeconds(30)) .untilAsserted(() -> whenPrometheusScraped().then() .statusCode(200) .contentType(OPENMETRICS_001) - .body(endsWith("# EOF\n"), containsString("service_name"))); - whenPrometheusScraped().then() - .body(containsString( - "{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""), - matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"), - matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"), - matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"), - matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"), - matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"), - matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"), - matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"), - matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$")); + .body(endsWith("# EOF\n"), containsString( + "{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""), + matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"), + matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"), + matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"), + matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"), + matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"), + matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"), + matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"), + matchesPattern("(?s)^.*test_distributionsummary_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"))); } private Response whenPrometheusScraped() {