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,25 +586,26 @@ 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);
|
||||||
deployKeycloak(k8sclient, kc, false);
|
|
||||||
|
|
||||||
Awaitility.await()
|
var upgradeCondition = k8sclient.resource(kc).informOnCondition(kcs -> {
|
||||||
.ignoreExceptions()
|
try {
|
||||||
.pollInterval(Duration.ZERO) // make the test super fast not to miss the moment when Operator changes the STS
|
assertKeycloakStatusCondition(kcs.get(0), KeycloakStatusCondition.READY, false, "Performing Keycloak upgrade");
|
||||||
.untilAsserted(() -> {
|
return true;
|
||||||
var sts = stsGetter.get();
|
} catch (AssertionError e) {
|
||||||
assertEquals(1, sts.getStatus().getReplicas());
|
return false;
|
||||||
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");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deployKeycloak(k8sclient, kc, false);
|
||||||
|
try {
|
||||||
|
upgradeCondition.get(2, TimeUnit.MINUTES);
|
||||||
|
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
.ignoreExceptions()
|
.ignoreExceptions()
|
||||||
.untilAsserted(() -> {
|
.untilAsserted(() -> {
|
||||||
|
|
Loading…
Reference in a new issue