From 8ed6ad8784f216bca19e781b9524ad6dcf7aaef9 Mon Sep 17 00:00:00 2001 From: andreaTP Date: Thu, 20 Jan 2022 15:36:26 +0000 Subject: [PATCH] More principled way to wait for the CRD --- .../operator/junit/OperatorExtension.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/OperatorExtension.java b/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/OperatorExtension.java index 03208422de..5941975a71 100644 --- a/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/OperatorExtension.java +++ b/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/OperatorExtension.java @@ -169,12 +169,9 @@ protected void before(ExtensionContext context) { } try (InputStream is = getClass().getResourceAsStream(path)) { - kubernetesClient.load(is).createOrReplace(); - // this fixes an issue with CRD registration, integration tests were failing, since the CRD - // was not found yet - // when the operator started. This seems to be fixing this issue (maybe a problem with - // minikube?) - Thread.sleep(2000); + final var crd = kubernetesClient.load(is); + crd.createOrReplace(); + crd.waitUntilReady(2, TimeUnit.SECONDS); LOGGER.debug("Applied CRD with name: {}", config.getResourceTypeName()); } catch (Exception ex) { throw new IllegalStateException("Cannot apply CRD yaml: " + path, ex);