Skip to content

Commit 265f584

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent ba2663a commit 265f584

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public class GenericRetry implements Retry, AnnotationConfigurable<GradualRetry>
1010
private double intervalMultiplier = GradualRetry.DEFAULT_MULTIPLIER;
1111
private long maxInterval = GradualRetry.DEFAULT_MAX_INTERVAL;
1212

13-
public static final Retry DEFAULT = new GenericRetry();
13+
public static final GenericRetry DEFAULT = new GenericRetry();
1414

1515
public static GenericRetry defaultLimitedExponentialRetry() {
16-
return (GenericRetry) DEFAULT;
16+
return DEFAULT;
1717
}
1818

1919
public static GenericRetry noRetry() {

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,66 @@ void triggerOnAllEventRetriesDeleteEventError() {
598598
}
599599

600600
@Test
601-
void processesAdditionalEventWhileInDeleteModeRetry() {}
601+
void processesAdditionalEventWhileInDeleteModeRetry() {
602+
when(eventSourceManagerMock.retryEventSource()).thenReturn(mock(TimerEventSource.class));
603+
eventProcessor =
604+
spy(
605+
new EventProcessor(
606+
controllerConfigTriggerAllEvent(
607+
GenericRetry.DEFAULT.setInitialInterval(1000).setMaxAttempts(-1),
608+
rateLimiterMock),
609+
reconciliationDispatcherMock,
610+
eventSourceManagerMock,
611+
null));
612+
when(reconciliationDispatcherMock.handleExecution(any()))
613+
.thenReturn(PostExecutionControl.defaultDispatch())
614+
.thenReturn(PostExecutionControl.exceptionDuringExecution(new RuntimeException()));
615+
616+
eventProcessor.start();
617+
618+
eventProcessor.handleEvent(prepareCREvent1());
619+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
620+
eventProcessor.handleEvent(prepareCRDeleteEvent1());
621+
verify(reconciliationDispatcherMock, times(2)).handleExecution(any());
622+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
623+
// retry event
624+
eventProcessor.handleEvent(new Event(TestUtils.testCustomResource1Id()));
625+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
626+
verify(reconciliationDispatcherMock, times(3)).handleExecution(any());
627+
}
602628

603629
@Test
604-
void triggerOnAllEventIfNoRetryInCleanupOnError() {}
630+
void afterRetryExhaustedAdditionalEventTriggerReconciliationWhenDeleteEventPresent() {
631+
when(eventSourceManagerMock.retryEventSource()).thenReturn(mock(TimerEventSource.class));
632+
eventProcessor =
633+
spy(
634+
new EventProcessor(
635+
controllerConfigTriggerAllEvent(
636+
GenericRetry.DEFAULT
637+
.setInitialInterval(100)
638+
.setIntervalMultiplier(1)
639+
.setMaxAttempts(1),
640+
rateLimiterMock),
641+
reconciliationDispatcherMock,
642+
eventSourceManagerMock,
643+
null));
644+
when(reconciliationDispatcherMock.handleExecution(any()))
645+
.thenReturn(PostExecutionControl.defaultDispatch())
646+
.thenReturn(PostExecutionControl.exceptionDuringExecution(new RuntimeException()));
647+
eventProcessor.start();
648+
649+
eventProcessor.handleEvent(prepareCREvent1());
650+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
651+
eventProcessor.handleEvent(prepareCRDeleteEvent1());
652+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
653+
eventProcessor.handleEvent(new Event(TestUtils.testCustomResource1Id()));
654+
await()
655+
.untilAsserted(() -> verify(reconciliationDispatcherMock, times(3)).handleExecution(any()));
656+
657+
eventProcessor.handleEvent(new Event(TestUtils.testCustomResource1Id()));
658+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
659+
verify(reconciliationDispatcherMock, times(4)).handleExecution(any());
660+
}
605661

606662
@Test
607663
void passesResourceFromStateToDispatcher() {

0 commit comments

Comments
 (0)