Skip to content

Commit 3983a96

Browse files
authored
fix: flaky per resource event source test (#1845)
1 parent 1574a88 commit 3983a96

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void run() {
149149
var primary = resourceCache.get(primaryID);
150150
if (primary.isEmpty()) {
151151
log.warn("No resource in cache for resource ID: {}", primaryID);
152-
// no new execution is scheduled in this case, a on delete event should be received shortly
152+
// no new execution is scheduled in this case, an on delete event should be received shortly
153153
} else {
154154
var actualResources = primary.map(p -> getAndCacheResource(p, false));
155155
scheduleNextExecution(primary.get(), actualResources.orElse(null));

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSourceTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,12 @@ void deleteEventCancelsTheScheduling() {
172172
.pollInterval(Duration.ofMillis(20))
173173
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
174174

175+
when(resourceCache.get(any())).thenReturn(Optional.empty());
175176
source.onResourceDeleted(testCustomResource);
176177

177-
// check if not called again.
178-
await().pollDelay(Duration.ofMillis(PERIOD))
179-
.atMost(Duration.ofMillis((2* PERIOD)))
178+
// check if not called again
179+
await().pollDelay(Duration.ofMillis(2*PERIOD))
180+
.atMost(Duration.ofMillis((4* PERIOD)))
180181
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
181182
}
182183

0 commit comments

Comments
 (0)