From d743dae722f0c44cc5b8b1ff4152cc76db39a5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Fri, 25 Sep 2026 14:01:01 +0200 Subject: [PATCH] test: fix flaky TriggerReconcilerOnAllEventIT.additionalEventDuringRetryOnDeleteEvent The test assumed at least 3 reconciliations happen before the reconciler starts waiting on the first retry. If the delete event arrives before the first reconciliation reads the resource, the finalizer-adding reconciliation is skipped, the reconciler starts waiting at count 2, and the test and the reconciler block on each other until timeout. Wait for the reconciler to be waiting and snapshot the event count then instead. --- .../eventing/TriggerReconcilerOnAllEventIT.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java index a8b022b642..3226611ea1 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/triggerallevent/eventing/TriggerReconcilerOnAllEventIT.java @@ -181,19 +181,16 @@ void additionalEventDuringRetryOnDeleteEvent() { extension.create(res); extension.delete(getResource()); - await() - .pollDelay(Duration.ofMillis(30)) - .untilAsserted( - () -> { - assertThat(reconciler.getEventCount()).isGreaterThan(2); - }); - var eventCount = reconciler.getEventCount(); - + // Don't assume a fixed number of reconciliations before the first retry: if the delete event + // arrives before the first reconciliation reads the resource, the finalizer-adding + // reconciliation is skipped. The reconciler increments the counter before it starts waiting, + // and nothing else reconciles while it waits, so the count read after this is stable. await() .untilAsserted( () -> { assertThat(reconciler.isWaiting()).isTrue(); }); + var eventCount = reconciler.getEventCount(); // trigger reconciliation while waiting in reconciler res = getResource();