Skip to content

Commit e41c693

Browse files
k-walltombentley
andauthored
test(operator): fix race condition in Route status update IT test (kroxylicious#3801)
* test(operator): fix race condition in Route status update test The deploymentChecksumUpdatesWhenOpenshiftRouteHostAssigned test was failing non-deterministically with 409 Conflict errors when racing with the OpenShift IngressController. Changed from patchStatus() to editStatus() which handles resource version conflicts automatically. Use a distinct host value to ensure updates are never no-ops. Fixes kroxylicious#3673 Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Keith Wall <kwall@apache.org> * Update kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/reconciler/kafkaproxy/KafkaProxyReconcilerIT.java Signed-off-by: Tom Bentley <tombentley@users.noreply.github.com> --------- Signed-off-by: Keith Wall <kwall@apache.org> Signed-off-by: Tom Bentley <tombentley@users.noreply.github.com> Co-authored-by: Tom Bentley <tombentley@users.noreply.github.com>
1 parent 5a868d8 commit e41c693

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -976,24 +976,28 @@ void deploymentChecksumUpdatesWhenOpenshiftRouteHostAssigned() {
976976
updateStatusObservedGeneration(testActor.create(cluster));
977977

978978
String bootstrapRouteName = name(cluster) + "-bootstrap";
979-
AWAIT.alias("bootstrap route created").untilAsserted(() -> assertThat(testActor.get(Route.class, bootstrapRouteName)).isNotNull());
979+
Route bootstrapRoute = AWAIT.alias("bootstrap route created").until(() -> testActor.get(Route.class, bootstrapRouteName), Objects::nonNull);
980980

981-
String initialChecksum = deploymentPodTemplateChecksum(proxy);
981+
var observedChecksum = deploymentPodTemplateChecksum(proxy);
982982

983-
// When - OpenShift assigns a host to the bootstrap route
984-
Route bootstrapRoute = testActor.get(Route.class, bootstrapRouteName);
985-
Route routeWithHost = new RouteBuilder(bootstrapRoute)
983+
// When
984+
985+
// The test is racing with the Ingress controller. We don't know if the ingress
986+
// controller will have updated the resource or not yet. We make an update to
987+
// the Route that we are certain will be different to that made by the controller
988+
// in order to be certain an update is made.
989+
testActor.resources(Route.class).resource(bootstrapRoute).editStatus(r -> new RouteBuilder(bootstrapRoute)
986990
.withNewStatus()
987-
.addNewIngress().withHost(bootstrapRouteName + ".apps-crc.testing").endIngress()
991+
.addNewIngress().withHost("different.invalid").endIngress()
988992
.endStatus()
989-
.build();
990-
testActor.patchStatus(routeWithHost);
993+
.build());
991994

992995
// Then - deployment pod template checksum should change so the proxy is restarted
993996
AWAIT.alias("deployment checksum updated after route host assignment")
994-
.untilAsserted(() -> assertThat(deploymentPodTemplateChecksum(proxy)).isNotEqualTo(initialChecksum));
997+
.untilAsserted(() -> assertThat(deploymentPodTemplateChecksum(proxy)).isNotEqualTo(observedChecksum));
995998
}
996999

1000+
@Nullable
9971001
private String deploymentPodTemplateChecksum(KafkaProxy proxy) {
9981002
var deployment = testActor.get(Deployment.class, ProxyDeploymentDependentResource.deploymentName(proxy));
9991003
assertThat(deployment).isNotNull();

0 commit comments

Comments
 (0)