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
This commit is contained in:
Phillip Webb 2025-05-08 17:39:04 -07:00
parent 69fb56a5e1
commit 234e7414e2
1 changed files with 2 additions and 1 deletions

View File

@ -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 {
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();