Browse Source

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
pull/42868/head
Andy Wilkinson 1 year ago
parent
commit
319e33f786
  1. 26
      spring-boot-project/spring-boot-testcontainers/src/dockerTest/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests.java

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

@ -80,24 +80,20 @@ class OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests { @@ -80,24 +80,20 @@ class OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests {
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() {

Loading…
Cancel
Save