[Windows] Stabilizing flaky Quarkus unit tests (#35638)

[Windows] Stabilizing flaky Quarkus unit tests

Closes: #35405

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
This commit is contained in:
Peter Zaoral 2024-12-06 15:01:50 +01:00 committed by GitHub
parent d3b759b56f
commit 0e1a62fa60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 3 deletions

View File

@ -20,7 +20,9 @@ import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@ -28,8 +30,18 @@ import static io.restassured.RestAssured.given;
class KeycloakMetricsConfigurationTest {
@BeforeAll
static void setUpAll() {
System.setProperty("KC_CACHE", "local");
}
@AfterAll
static void tearDownAll() {
System.clearProperty("KC_CACHE");
}
@BeforeEach
void setUpPort() {
void setUp() {
RestAssured.port = 9001;
}

View File

@ -45,10 +45,12 @@ public class KeycloakNegativeHealthCheckTest {
agroalDataSource.close();
RestAssured.port = 9001;
System.setProperty("KC_CACHE", "local"); // avoid flaky port conflicts
given()
.when().get("/health/ready")
.then()
.statusCode(503)
.body(Matchers.containsString("DOWN"));
System.clearProperty("KC_CACHE");
}
}

View File

@ -20,6 +20,8 @@ import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@ -29,8 +31,18 @@ import static org.hamcrest.CoreMatchers.is;
class KeycloakPathConfigurationTest {
@BeforeAll
static void setUpAll() {
System.setProperty("KC_CACHE", "local");
}
@AfterAll
static void tearDownAll() {
System.clearProperty("KC_CACHE");
}
@BeforeEach
void setUpPort() {
void setUp() {
RestAssured.port = 9001;
}

View File

@ -21,6 +21,8 @@ import io.restassured.RestAssured;
import org.hamcrest.Matchers;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@ -29,8 +31,18 @@ import static io.restassured.RestAssured.given;
public class KeycloakReadyHealthCheckTest {
@BeforeAll
static void setUpAll() {
System.setProperty("KC_CACHE", "local");
}
@AfterAll
static void tearDownAll() {
System.clearProperty("KC_CACHE");
}
@BeforeEach
void setUpPort() {
void setUp() {
RestAssured.port = 9001;
}