Skip to content

Commit

Permalink
Improve test reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobat committed Jan 29, 2025
1 parent 8edf94b commit c34a2de
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 c34a2de

Please sign in to comment.