Skip to content

Commit

Permalink
Fix operator tests flakiness in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Nov 7, 2024
1 parent 76401cb commit b83a400
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

public class ITBase {

Expand Down Expand Up @@ -142,6 +143,10 @@ private static void createCRDs() {
try {
var crd = client.load(new FileInputStream(CRD_FILE));
crd.createOrReplace();
await().ignoreExceptions().until(() -> {
crd.resources().forEach(r -> assertThat(r.get()).isNotNull());
return true;
});
} catch (Exception e) {
Log.warn("Failed to create the CRD, retrying", e);
createCRDs();
Expand Down Expand Up @@ -185,7 +190,7 @@ public void cleanup() {
if (cleanup) {
Log.info("Deleting CRs");
client.resources(ApicurioRegistry3.class).delete();
Awaitility.await().untilAsserted(() -> {
await().untilAsserted(() -> {
var registryDeployments = client.apps().deployments().inNamespace(namespace)
.withLabels(Constants.BASIC_LABELS).list().getItems();
assertThat(registryDeployments.size()).isZero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static void beforeAll() throws Exception {

@Test
void testKafkaSQLPlain() {
client.load(getClass().getResourceAsStream("/k8s/examples/kafkasql/plain/ephemeral.kafka.yaml"))
client.load(
KafkaSQLITTest.class.getResourceAsStream("/k8s/examples/kafkasql/plain/ephemeral.kafka.yaml"))
.create();
final var clusterNAme = "my-cluster";

Expand Down Expand Up @@ -80,8 +81,12 @@ private static void applyStrimziResources() throws IOException {
var crb = (RoleBinding) r;
crb.getSubjects().forEach(s -> s.setNamespace(namespace));
}
log.info("Creating Strimzi in namespace {}", namespace);
log.info("Creating Strimzi resource kind {} in namespace {}", r.getKind(), namespace);
client.resource(r).inNamespace(namespace).createOrReplace();
await().ignoreExceptions().until(() -> {
assertThat(client.resource(r).inNamespace(namespace).get()).isNotNull();
return true;
});
});
}
}
Expand Down

0 comments on commit b83a400

Please sign in to comment.