Skip to content

Commit 318bbb4

Browse files
authored
Merge pull request kroxylicious#2039 from robobario/healing-it
operator: add IT checking healing after danglingRef
2 parents ab16736 + f28a50c commit 318bbb4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/KafkaProxyReconcilerIT.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,45 @@ void moveVirtualKafkaClusterToAnotherKafkaProxy() {
455455
assertServiceTargetsProxyInstances(proxyB, fooCluster, ingressFoo);
456456
}
457457

458+
// we want to ensure that if a dangling ref is created, for example if a KafkaIngress is deleted, and then
459+
// that KafkaIngress is created, the proxy springs back into life.
460+
@Test
461+
void deleteAndRestoreADependency() {
462+
// given
463+
KafkaProxy proxyA = testActor.create(kafkaProxy(PROXY_A));
464+
465+
KafkaProxyIngress ingress = clusterIpIngress(CLUSTER_FOO_CLUSTERIP_INGRESS, proxyA);
466+
KafkaProxyIngress ingressFoo = testActor.create(ingress.edit().build());
467+
468+
KafkaService fooService = testActor.create(kafkaService(CLUSTER_FOO_REF, CLUSTER_FOO_BOOTSTRAP));
469+
KafkaProtocolFilter filter = testActor.create(filter(FILTER_NAME));
470+
471+
VirtualKafkaCluster fooCluster = testActor.create(virtualKafkaCluster(CLUSTER_FOO, proxyA, fooService, ingressFoo, filter));
472+
473+
assertProxyConfigContents(proxyA, Set.of(CLUSTER_FOO_BOOTSTRAP), Set.of());
474+
assertServiceTargetsProxyInstances(proxyA, fooCluster, ingressFoo);
475+
476+
// when
477+
testActor.delete(ingressFoo);
478+
479+
// then
480+
assertDeploymentIsRemoved(proxyA);
481+
482+
// and when
483+
// we need an ingress without uid/resourceVersion in its metadata, so we clone an unadulterated ingress
484+
testActor.create(ingress.edit().build());
485+
486+
// and then
487+
assertDeploymentBecomesReady(proxyA);
488+
}
489+
490+
private void assertDeploymentIsRemoved(KafkaProxy proxy) {
491+
// wait longer for initial operator image download
492+
AWAIT.alias("Deployment is removed").untilAsserted(() -> {
493+
assertThat(testActor.get(Deployment.class, ProxyDeploymentDependentResource.deploymentName(proxy))).isNull();
494+
});
495+
}
496+
458497
private AbstractStringAssert<?> assertThatProxyConfigFor(KafkaProxy proxy) {
459498
var configMap = testActor.get(ConfigMap.class, ProxyConfigDependentResource.configMapName(proxy));
460499
return assertThat(configMap)

0 commit comments

Comments
 (0)