Browse Source

Fix Jersey test by waiting for metrics

For some reason metrics are not always being recorded before the check
runs when a full build is running. Adding a sleep seems to "solve" the
problem.

See gh-45483
See gh-45404
pull/45379/head
Phillip Webb 9 months ago
parent
commit
234e7414e2
  1. 3
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java

3
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -82,6 +82,7 @@ class JerseyServerMetricsAutoConfigurationTests { @@ -82,6 +82,7 @@ class JerseyServerMetricsAutoConfigurationTests {
void httpRequestsAreTimed() {
this.webContextRunner.run((context) -> {
doRequest(context);
Thread.sleep(500);
MeterRegistry registry = context.getBean(MeterRegistry.class);
Timer timer = registry.get("http.server.requests").tag("uri", "/users/{id}").timer();
assertThat(timer.count()).isOne();

Loading…
Cancel
Save