Skip to content

Commit 979b83a

Browse files
authored
More principled way to wait for the CRD (operator-framework#852)
1 parent ade382e commit 979b83a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/OperatorExtension.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,9 @@ protected void before(ExtensionContext context) {
169169
}
170170

171171
try (InputStream is = getClass().getResourceAsStream(path)) {
172-
kubernetesClient.load(is).createOrReplace();
173-
// this fixes an issue with CRD registration, integration tests were failing, since the CRD
174-
// was not found yet
175-
// when the operator started. This seems to be fixing this issue (maybe a problem with
176-
// minikube?)
177-
Thread.sleep(2000);
172+
final var crd = kubernetesClient.load(is);
173+
crd.createOrReplace();
174+
crd.waitUntilReady(2, TimeUnit.SECONDS);
178175
LOGGER.debug("Applied CRD with name: {}", config.getResourceTypeName());
179176
} catch (Exception ex) {
180177
throw new IllegalStateException("Cannot apply CRD yaml: " + path, ex);

0 commit comments

Comments
 (0)