Skip to content

Commit

Permalink
[Windows] Stabilizing flaky Quarkus unit tests (keycloak#35638)
Browse files Browse the repository at this point in the history
[Windows] Stabilizing flaky Quarkus unit tests

Closes: keycloak#35405

Signed-off-by: Peter Zaoral <[email protected]>
  • Loading branch information
Pepo48 authored Dec 6, 2024
1 parent d3b759b commit 0e1a62f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@
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;

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 0e1a62f

Please sign in to comment.