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));
|
.untilAsserted(() -> assertThat(kcPodsSelector.list().getItems().size()).isEqualTo(2));
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.atMost(2, MINUTES)
|
.atMost(5, MINUTES)
|
||||||
.pollDelay(5, SECONDS)
|
.pollDelay(1, SECONDS)
|
||||||
.ignoreExceptions()
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> CRAssert.assertKeycloakStatusCondition(crSelector.get(), KeycloakStatusCondition.READY, true));
|
.untilAsserted(() -> CRAssert.assertKeycloakStatusCondition(crSelector.get(), KeycloakStatusCondition.READY, true));
|
||||||
|
|
||||||
|
@ -122,7 +122,11 @@ public class ClusteringE2EIT extends ClusterOperatorTest {
|
||||||
realmImportSelector.delete();
|
realmImportSelector.delete();
|
||||||
|
|
||||||
Log.info("Testing the Keycloak Cluster");
|
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
|
// Get the list of Keycloak pods
|
||||||
var pods = k8sclient
|
var pods = k8sclient
|
||||||
.pods()
|
.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
|
// 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
|
// Executed here to avoid paying the setup time again
|
||||||
var service = new KeycloakService(k8sclient, kc);
|
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;
|
String token2 = null;
|
||||||
// Obtaining the token from the first pod
|
// 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 + 1); i++) {
|
||||||
for (int i = 0; i < (targetInstances * 2); i++) {
|
|
||||||
|
|
||||||
if (token2 == null) {
|
if (token2 == null) {
|
||||||
var tokenUrl = "https://" + service.getName() + "." + namespace + ":" + Constants.KEYCLOAK_HTTPS_PORT + "/realms/token-test/protocol/openid-connect/token";
|
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.Map;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
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.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
@ -146,6 +148,9 @@ public class KeycloakDeploymentE2EIT extends ClusterOperatorTest {
|
||||||
k8sclient.apps().deployments().createOrReplace(deployment);
|
k8sclient.apps().deployments().createOrReplace(deployment);
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
|
.atMost(5, MINUTES)
|
||||||
|
.pollDelay(1, SECONDS)
|
||||||
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> {
|
.untilAsserted(() -> {
|
||||||
var d = k8sclient.apps().deployments().withName(deploymentName).get();
|
var d = k8sclient.apps().deployments().withName(deploymentName).get();
|
||||||
assertThat(d.getMetadata().getLabels().entrySet().containsAll(labels.entrySet())).isTrue(); // additional labels should not be overwritten
|
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);
|
ingressSelector.createOrReplace(currentIngress);
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> {
|
.untilAsserted(() -> {
|
||||||
var i = ingressSelector.get();
|
var i = ingressSelector.get();
|
||||||
assertThat(i.getMetadata().getLabels().entrySet().containsAll(labels.entrySet())).isTrue(); // additional labels should not be overwritten
|
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)
|
.inNamespace(namespace)
|
||||||
.withName("example-count0-kc");
|
.withName("example-count0-kc");
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.atMost(3, MINUTES)
|
.atMost(5, MINUTES)
|
||||||
.pollDelay(5, SECONDS)
|
.pollDelay(1, SECONDS)
|
||||||
.ignoreExceptions()
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> {
|
.untilAsserted(() -> {
|
||||||
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, false);
|
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, false);
|
||||||
|
@ -89,8 +89,8 @@ public class RealmImportE2EIT extends ClusterOperatorTest {
|
||||||
});
|
});
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.atMost(3, MINUTES)
|
.atMost(5, MINUTES)
|
||||||
.pollDelay(5, SECONDS)
|
.pollDelay(1, SECONDS)
|
||||||
.ignoreExceptions()
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> {
|
.untilAsserted(() -> {
|
||||||
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, true);
|
CRAssert.assertKeycloakRealmImportStatusCondition(crSelector.get(), DONE, true);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.keycloak.operator.utils;
|
package org.keycloak.operator.utils;
|
||||||
|
|
||||||
|
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||||
import io.quarkus.logging.Log;
|
import io.quarkus.logging.Log;
|
||||||
import org.keycloak.operator.v2alpha1.crds.Keycloak;
|
import org.keycloak.operator.v2alpha1.crds.Keycloak;
|
||||||
import org.keycloak.operator.v2alpha1.crds.KeycloakRealmImport;
|
import org.keycloak.operator.v2alpha1.crds.KeycloakRealmImport;
|
||||||
|
@ -32,13 +33,18 @@ public final class CRAssert {
|
||||||
assertKeycloakStatusCondition(kc, condition, status, null);
|
assertKeycloakStatusCondition(kc, condition, status, null);
|
||||||
}
|
}
|
||||||
public static void assertKeycloakStatusCondition(Keycloak kc, String condition, boolean status, String containedMessage) {
|
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);
|
Log.debugf("Asserting CR: %s, condition: %s, status: %s, message: %s", kc.getMetadata().getName(), condition, status, containedMessage);
|
||||||
assertThat(kc.getStatus().getConditions().stream()
|
try {
|
||||||
.anyMatch(c ->
|
assertThat(kc.getStatus().getConditions().stream()
|
||||||
c.getType().equals(condition) &&
|
.anyMatch(c ->
|
||||||
c.getStatus() == status &&
|
c.getType().equals(condition) &&
|
||||||
(containedMessage == null || c.getMessage().contains(containedMessage)))
|
c.getStatus() == status &&
|
||||||
).isTrue();
|
(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) {
|
public static void assertKeycloakRealmImportStatusCondition(KeycloakRealmImport kri, String condition, boolean status) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
quarkus.test.hang-detection-timeout=30m
|
quarkus.test.hang-detection-timeout=30m
|
||||||
|
|
||||||
# we start operator manually during tests
|
# 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