From 0e1a62fa60166940eb2065fd7cb91862918f36eb Mon Sep 17 00:00:00 2001 From: Peter Zaoral Date: Fri, 6 Dec 2024 15:01:50 +0100 Subject: [PATCH] [Windows] Stabilizing flaky Quarkus unit tests (#35638) [Windows] Stabilizing flaky Quarkus unit tests Closes: #35405 Signed-off-by: Peter Zaoral --- .../health/KeycloakMetricsConfigurationTest.java | 14 +++++++++++++- .../health/KeycloakNegativeHealthCheckTest.java | 2 ++ .../health/KeycloakPathConfigurationTest.java | 14 +++++++++++++- .../health/KeycloakReadyHealthCheckTest.java | 14 +++++++++++++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakMetricsConfigurationTest.java b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakMetricsConfigurationTest.java index 31d9b8fd55fd..bdc1a3aa5cf2 100644 --- a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakMetricsConfigurationTest.java +++ b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakMetricsConfigurationTest.java @@ -20,7 +20,9 @@ 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 @@ 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; } diff --git a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakNegativeHealthCheckTest.java b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakNegativeHealthCheckTest.java index a821544d1abb..7cce2c7de31e 100644 --- a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakNegativeHealthCheckTest.java +++ b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakNegativeHealthCheckTest.java @@ -45,10 +45,12 @@ public void testReadinessDown() { 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"); } } diff --git a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakPathConfigurationTest.java b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakPathConfigurationTest.java index c392ff4d5e25..cb351cbe8c52 100644 --- a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakPathConfigurationTest.java +++ b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakPathConfigurationTest.java @@ -20,6 +20,8 @@ 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 @@ 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; } diff --git a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakReadyHealthCheckTest.java b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakReadyHealthCheckTest.java index 12e079979d97..7c8fb9fbe939 100644 --- a/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakReadyHealthCheckTest.java +++ b/quarkus/deployment/src/test/java/test/org/keycloak/quarkus/services/health/KeycloakReadyHealthCheckTest.java @@ -21,6 +21,8 @@ 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 @@ 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; }