Skip to content

Commit

Permalink
Merge pull request #45960 from brunobat/fix-test-stability
Browse files Browse the repository at this point in the history
Improve MetricsTest reliability
  • Loading branch information
gsmet authored Jan 30, 2025
2 parents 7901fe1 + c34a2de commit 3e7485f
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ public class MetricsTest {
@BeforeEach
@AfterEach
void reset() {
given().get("/reset").then().statusCode(HTTP_OK);
await().atMost(5, SECONDS).until(() -> {
List<Map<String, Object>> spans = getSpans();
if (spans.size() == 0) {
return true;
} else {
given().get("/reset").then().statusCode(HTTP_OK);
return false;
}
});
}

private List<Map<String, Object>> getSpans() {
Expand Down Expand Up @@ -54,7 +62,11 @@ public void directCounterTest() {
.then()
.statusCode(200);

await().atMost(5, SECONDS).until(() -> getSpans().size() == 2);
await().atMost(10, SECONDS).until(() -> {
List<Map<String, Object>> spans = getSpans();
System.out.println("spans size " + spans.size());
return spans.size() == 2;
});
await().atMost(10, SECONDS).until(() -> getMetrics("direct-trace-counter").size() > 2);

List<Map<String, Object>> metrics = getMetrics("direct-trace-counter");
Expand Down

0 comments on commit 3e7485f

Please sign in to comment.