task: use informer rather than 0 interval polling (#28901)
related to: #28869 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
parent
ef45629df4
commit
d7ef650623
1 changed files with 18 additions and 14 deletions
|
@ -57,6 +57,9 @@ import java.util.Base64;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
@ -583,24 +586,25 @@ public class KeycloakDeploymentTest extends BaseOperatorTest {
|
||||||
deployKeycloak(k8sclient, kc, true);
|
deployKeycloak(k8sclient, kc, true);
|
||||||
|
|
||||||
var stsGetter = k8sclient.apps().statefulSets().inNamespace(namespace).withName(kc.getMetadata().getName());
|
var stsGetter = k8sclient.apps().statefulSets().inNamespace(namespace).withName(kc.getMetadata().getName());
|
||||||
final String origImage = stsGetter.get().getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
|
|
||||||
final String newImage = "quay.io/keycloak/non-existing-keycloak";
|
final String newImage = "quay.io/keycloak/non-existing-keycloak";
|
||||||
|
|
||||||
kc.getSpec().setImage(newImage);
|
kc.getSpec().setImage(newImage);
|
||||||
|
|
||||||
|
var upgradeCondition = k8sclient.resource(kc).informOnCondition(kcs -> {
|
||||||
|
try {
|
||||||
|
assertKeycloakStatusCondition(kcs.get(0), KeycloakStatusCondition.READY, false, "Performing Keycloak upgrade");
|
||||||
|
return true;
|
||||||
|
} catch (AssertionError e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
deployKeycloak(k8sclient, kc, false);
|
deployKeycloak(k8sclient, kc, false);
|
||||||
|
try {
|
||||||
Awaitility.await()
|
upgradeCondition.get(2, TimeUnit.MINUTES);
|
||||||
.ignoreExceptions()
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
.pollInterval(Duration.ZERO) // make the test super fast not to miss the moment when Operator changes the STS
|
throw new AssertionError(e);
|
||||||
.untilAsserted(() -> {
|
}
|
||||||
var sts = stsGetter.get();
|
|
||||||
assertEquals(1, sts.getStatus().getReplicas());
|
|
||||||
assertEquals(origImage, sts.getSpec().getTemplate().getSpec().getContainers().get(0).getImage());
|
|
||||||
|
|
||||||
var currentKc = k8sclient.resources(Keycloak.class)
|
|
||||||
.inNamespace(namespace).withName(kc.getMetadata().getName()).get();
|
|
||||||
assertKeycloakStatusCondition(currentKc, KeycloakStatusCondition.READY, false, "Performing Keycloak upgrade");
|
|
||||||
});
|
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.ignoreExceptions()
|
.ignoreExceptions()
|
||||||
|
|
Loading…
Reference in a new issue