Skip to content

Commit dd705c4

Browse files
committed
test: use @DisabledIfSystemProperty to skip ingress tests
1 parent 73e6615 commit dd705c4

File tree

2 files changed

+41
-46
lines changed

2 files changed

+41
-46
lines changed

operator/controller/src/test/java/io/apicurio/registry/operator/it/IngressManager.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public class IngressManager {
2626
public IngressManager(KubernetesClient k8sClient, String namespace) {
2727
this.k8sClient = k8sClient;
2828
this.namespace = namespace;
29+
if (isSkipIngress()) {
30+
log.warn("Ingress testing is skipped. This is not recommended.");
31+
}
2932
}
3033

3134
public String getIngressHost(String prefix) {
@@ -41,16 +44,8 @@ private static Optional<String> getBaseIngressHost() {
4144
return ConfigProvider.getConfig().getOptionalValue(INGRESS_HOST_PROP, String.class);
4245
}
4346

44-
public boolean isIngressSupported() {
45-
if (isSkipIngress()) {
46-
log.warn("Ingress testing is skipped. This is not recommended.");
47-
return false;
48-
}
49-
return true;
50-
}
51-
5247
public RequestSpecification startHttpRequest(String ingressName) {
53-
if (!isIngressSupported()) {
48+
if (isSkipIngress()) {
5449
throw new OperatorException("Ingress tests are not supported.");
5550
}
5651

operator/controller/src/test/java/io/apicurio/registry/operator/it/SmokeITTest.java

+37-37
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.fabric8.kubernetes.api.model.ObjectMeta;
66
import io.quarkus.test.junit.QuarkusTest;
77
import org.junit.jupiter.api.Test;
8+
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

@@ -109,43 +110,42 @@ void testService() {
109110
}
110111

111112
@Test
113+
@DisabledIfSystemProperty(named = INGRESS_SKIP_PROP, matches = "true")
112114
void testIngress() {
113-
if (ingressManager.isIngressSupported()) {
114-
// spotless:off
115-
var registry = new ApicurioRegistry3();
116-
var meta = new ObjectMeta();
117-
meta.setName("demo");
118-
meta.setNamespace(namespace);
119-
registry.setMetadata(meta);
120-
registry.setSpec(ApicurioRegistry3Spec.builder()
121-
.appHost(ingressManager.getIngressHost("demo-app"))
122-
.uiHost(ingressManager.getIngressHost("demo-ui"))
123-
.build());
124-
// spotless:on
125-
126-
// Act
127-
client.resources(ApicurioRegistry3.class).inNamespace(namespace).create(registry);
128-
129-
// Wait for Ingresses
130-
await().ignoreExceptions().until(() -> {
131-
assertThat(client.network().v1().ingresses().inNamespace(namespace)
132-
.withName("demo-app-ingress").get()).isNotNull();
133-
assertThat(client.network().v1().ingresses().inNamespace(namespace)
134-
.withName("demo-ui-ingress").get()).isNotNull();
135-
return true;
136-
});
137-
138-
await().ignoreExceptions().until(() -> {
139-
ingressManager.startHttpRequest("demo-app-ingress").basePath("/apis/registry/v3/system/info")
140-
.get().then().statusCode(200);
141-
return true;
142-
});
143-
144-
await().ignoreExceptions().until(() -> {
145-
ingressManager.startHttpRequest("demo-ui-ingress").basePath("/config.js").get().then()
146-
.statusCode(200);
147-
return true;
148-
});
149-
}
115+
// spotless:off
116+
var registry = new ApicurioRegistry3();
117+
var meta = new ObjectMeta();
118+
meta.setName("demo");
119+
meta.setNamespace(namespace);
120+
registry.setMetadata(meta);
121+
registry.setSpec(ApicurioRegistry3Spec.builder()
122+
.appHost(ingressManager.getIngressHost("demo-app"))
123+
.uiHost(ingressManager.getIngressHost("demo-ui"))
124+
.build());
125+
// spotless:on
126+
127+
// Act
128+
client.resources(ApicurioRegistry3.class).inNamespace(namespace).create(registry);
129+
130+
// Wait for Ingresses
131+
await().ignoreExceptions().until(() -> {
132+
assertThat(client.network().v1().ingresses().inNamespace(namespace).withName("demo-app-ingress")
133+
.get()).isNotNull();
134+
assertThat(client.network().v1().ingresses().inNamespace(namespace).withName("demo-ui-ingress")
135+
.get()).isNotNull();
136+
return true;
137+
});
138+
139+
await().ignoreExceptions().until(() -> {
140+
ingressManager.startHttpRequest("demo-app-ingress").basePath("/apis/registry/v3/system/info")
141+
.get().then().statusCode(200);
142+
return true;
143+
});
144+
145+
await().ignoreExceptions().until(() -> {
146+
ingressManager.startHttpRequest("demo-ui-ingress").basePath("/config.js").get().then()
147+
.statusCode(200);
148+
return true;
149+
});
150150
}
151151
}

0 commit comments

Comments
 (0)