Skip to content

Commit 1282707

Browse files
authored
fix: ClusterDeployedOperatorExtension should alway apply CRDs before test (#3312)
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent e598e22 commit 1282707

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

operator-framework-junit/src/main/java/io/javaoperatorsdk/operator/junit/ClusterDeployedOperatorExtension.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,20 @@ public static Builder builder() {
8282
return new Builder();
8383
}
8484

85-
protected void before(ExtensionContext context) {
86-
super.before(context);
85+
// note that if extension is not static beforeAll is not called
86+
@Override
87+
protected void beforeEachImpl(ExtensionContext context) {
88+
applyCrds(context);
89+
super.beforeEachImpl(context);
90+
}
91+
92+
@Override
93+
protected void beforeAllImpl(ExtensionContext context) {
94+
applyCrds(context);
95+
super.beforeAllImpl(context);
96+
}
8797

98+
protected void applyCrds(ExtensionContext context) {
8899
final var crdPath = "./target/classes/META-INF/fabric8/";
89100
final var crdSuffix = "-v1.yml";
90101

@@ -109,7 +120,12 @@ protected void before(ExtensionContext context) {
109120
throw new IllegalStateException("Cannot apply CRD yaml: " + crdFile.getAbsolutePath(), ex);
110121
}
111122
}
123+
}
112124

125+
@Override
126+
protected void before(ExtensionContext context) {
127+
super.before(context);
128+
final var kubernetesClient = getInfrastructureKubernetesClient();
113129
LOGGER.debug("Deploying the operator into Kubernetes. Target namespace: {}", namespace);
114130
operatorDeployment.forEach(
115131
hm -> {

0 commit comments

Comments
 (0)