Improve Operator CI robustness
This commit is contained in:
parent
d083b6c484
commit
8912b6dc96
6 changed files with 40 additions and 18 deletions
|
@ -63,8 +63,8 @@ public class ClusteringE2EIT extends ClusterOperatorTest {
|
|||
.untilAsserted(() -> assertThat(kcPodsSelector.list().getItems().size()).isEqualTo(2));
|
||||
|
||||
Awaitility.await()
|
||||
.atMost(2, MINUTES)
|
||||
.pollDelay(5, SECONDS)
|
||||
.atMost(5, MINUTES)
|
||||
.pollDelay(1, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> CRAssert.assertKeycloakStatusCondition(crSelector.get(), KeycloakStatusCondition.READY, true));
|
||||
|
||||
|
@ -122,7 +122,11 @@ public class ClusteringE2EIT extends ClusterOperatorTest {
|
|||
realmImportSelector.delete();
|
||||
|
||||
Log.info("Testing the Keycloak Cluster");
|
||||
Awaitility.await().atMost(5, MINUTES).ignoreExceptions().untilAsserted(() -> {
|
||||
Awaitility.await()
|
||||
.atMost(20, MINUTES)
|
||||
.pollDelay(5, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
// Get the list of Keycloak pods
|
||||
var pods = k8sclient
|
||||
.pods()
|
||||
|
@ -173,11 +177,14 @@ public class ClusteringE2EIT extends ClusterOperatorTest {
|
|||
// This is to test passing through the "Service", not 100% deterministic, but a smoke test that things are working as expected
|
||||
// Executed here to avoid paying the setup time again
|
||||
var service = new KeycloakService(k8sclient, kc);
|
||||
Awaitility.await().atMost(5, MINUTES).ignoreExceptions().untilAsserted(() -> {
|
||||
Awaitility.await()
|
||||
.atMost(20, MINUTES)
|
||||
.pollDelay(5, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
String token2 = null;
|
||||
// Obtaining the token from the first pod
|
||||
// Connecting using port-forward and a fixed port to respect the instance issuer used hostname
|
||||
for (int i = 0; i < (targetInstances * 2); i++) {
|
||||
for (int i = 0; i < (targetInstances + 1); i++) {
|
||||
|
||||
if (token2 == null) {
|
||||
var tokenUrl = "https://" + service.getName() + "." + namespace + ":" + Constants.KEYCLOAK_HTTPS_PORT + "/realms/token-test/protocol/openid-connect/token";
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
@ -146,6 +148,9 @@ public class KeycloakDeploymentE2EIT extends ClusterOperatorTest {
|
|||
k8sclient.apps().deployments().createOrReplace(deployment);
|
||||
|
||||
Awaitility.await()
|
||||
.atMost(5, MINUTES)
|
||||
.pollDelay(1, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
var d = k8sclient.apps().deployments().withName(deploymentName).get();
|
||||
assertThat(d.getMetadata().getLabels().entrySet().containsAll(labels.entrySet())).isTrue(); // additional labels should not be overwritten
|
||||
|
|
|
@ -136,6 +136,7 @@ public class KeycloakIngressE2EIT extends ClusterOperatorTest {
|
|||
ingressSelector.createOrReplace(currentIngress);
|
||||
|
||||
Awaitility.await()
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
var i = ingressSelector.get();
|
||||
assertThat(i.getMetadata().getLabels().entrySet().containsAll(labels.entrySet())).isTrue(); // additional labels should not be overwritten
|
||||
|
|
|
@ -79,8 +79,8 @@ public class RealmImportE2EIT extends ClusterOperatorTest {
|
|||
.inNamespace(namespace)
|
||||
.withName("example-count0-kc");
|
||||
Awaitility.await()
|
||||
.atMost(3, MINUTES)
|
||||
.pollDelay(5, SECONDS)
|
||||
.atMost(5, MINUTES)
|
||||
.pollDelay(1, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, false);
|
||||
|
@ -89,8 +89,8 @@ public class RealmImportE2EIT extends ClusterOperatorTest {
|
|||
});
|
||||
|
||||
Awaitility.await()
|
||||
.atMost(3, MINUTES)
|
||||
.pollDelay(5, SECONDS)
|
||||
.atMost(5, MINUTES)
|
||||
.pollDelay(1, SECONDS)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, true);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.keycloak.operator.utils;
|
||||
|
||||
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||
import io.quarkus.logging.Log;
|
||||
import org.keycloak.operator.v2alpha1.crds.Keycloak;
|
||||
import org.keycloak.operator.v2alpha1.crds.KeycloakRealmImport;
|
||||
|
@ -32,13 +33,18 @@ public final class CRAssert {
|
|||
assertKeycloakStatusCondition(kc, condition, status, null);
|
||||
}
|
||||
public static void assertKeycloakStatusCondition(Keycloak kc, String condition, boolean status, String containedMessage) {
|
||||
Log.infof("Asserting CR: %s, condition: %s, status: %s, message: %s", kc.getMetadata().getName(), condition, status, containedMessage);
|
||||
assertThat(kc.getStatus().getConditions().stream()
|
||||
.anyMatch(c ->
|
||||
c.getType().equals(condition) &&
|
||||
c.getStatus() == status &&
|
||||
(containedMessage == null || c.getMessage().contains(containedMessage)))
|
||||
).isTrue();
|
||||
Log.debugf("Asserting CR: %s, condition: %s, status: %s, message: %s", kc.getMetadata().getName(), condition, status, containedMessage);
|
||||
try {
|
||||
assertThat(kc.getStatus().getConditions().stream()
|
||||
.anyMatch(c ->
|
||||
c.getType().equals(condition) &&
|
||||
c.getStatus() == status &&
|
||||
(containedMessage == null || c.getMessage().contains(containedMessage)))
|
||||
).isTrue();
|
||||
} catch (Exception e) {
|
||||
Log.infof("Asserting CR: %s with status:\n%s", kc.getMetadata().getName(), Serialization.asYaml(kc.getStatus()));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertKeycloakRealmImportStatusCondition(KeycloakRealmImport kri, String condition, boolean status) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
quarkus.test.hang-detection-timeout=30m
|
||||
|
||||
# we start operator manually during tests
|
||||
quarkus.operator-sdk.start-operator=false
|
||||
quarkus.operator-sdk.start-operator=false
|
||||
|
||||
quarkus.log.level=INFO
|
||||
quarkus.log.category."io.javaoperatorsdk".level=DEBUG
|
||||
|
|
Loading…
Reference in a new issue