Skip to content

Commit

Permalink
Fix flaky otel quickstart test
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobat committed Jan 16, 2025
1 parent 3eb1947 commit d605c31
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static java.net.HttpURLConnection.HTTP_OK;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is;

import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;
Expand All @@ -18,6 +22,19 @@
@TestProfile(OpenTelemetryDisabledTest.MyProfile.class)
public class OpenTelemetryDisabledTest extends BaseTest {

@BeforeEach
void reset() {
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;
}
});
}

@Test
void buildTimeDisabled() {
given()
Expand All @@ -26,7 +43,7 @@ void buildTimeDisabled() {
.statusCode(200)
.body(is("Hello from Quarkus REST"));
// Service will start nevertheless.
await().atMost(200, MILLISECONDS).until(() -> getSpans().size() == 0);
await().atMost(300, MILLISECONDS).until(() -> getSpans().size() == 0);
}

public static class MyProfile implements QuarkusTestProfile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@

import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static java.net.HttpURLConnection.HTTP_OK;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is;

import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class OpenTelemetryTest extends BaseTest {

@BeforeEach
void reset() {
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;
}
});
}

@Test
void buildTimeEnabled() {
given()
Expand Down

0 comments on commit d605c31

Please sign in to comment.