Skip to content

Commit 0929923

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

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ControllerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ default boolean isGenerationAware() {
5757
String getAssociatedReconcilerClassName();
5858

5959
default Retry getRetry() {
60-
return GenericRetry.DEFAULT;
60+
return GenericRetry.defaultLimitedExponentialRetry();
6161
}
6262

6363
@SuppressWarnings("rawtypes")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class GenericRetry implements Retry, AnnotationConfigurable<GradualRetry>
1313
public static final GenericRetry DEFAULT = new GenericRetry();
1414

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

1919
public static GenericRetry noRetry() {

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static org.mockito.Mockito.after;
4545
import static org.mockito.Mockito.any;
4646
import static org.mockito.Mockito.anyLong;
47+
import static org.mockito.Mockito.atMost;
4748
import static org.mockito.Mockito.atMostOnce;
4849
import static org.mockito.Mockito.doAnswer;
4950
import static org.mockito.Mockito.mock;
@@ -618,7 +619,7 @@ void processesAdditionalEventWhileInDeleteModeRetry() {
618619
eventProcessor.handleEvent(prepareCREvent1());
619620
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
620621
eventProcessor.handleEvent(prepareCRDeleteEvent1());
621-
verify(reconciliationDispatcherMock, times(2)).handleExecution(any());
622+
verify(reconciliationDispatcherMock, atMost(2)).handleExecution(any());
622623
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
623624
// retry event
624625
eventProcessor.handleEvent(new Event(TestUtils.testCustomResource1Id()));
@@ -661,7 +662,26 @@ void afterRetryExhaustedAdditionalEventTriggerReconciliationWhenDeleteEventPrese
661662

662663
@Test
663664
void passesResourceFromStateToDispatcher() {
664-
// check also last state unknown
665+
eventProcessor =
666+
spy(
667+
new EventProcessor(
668+
controllerConfigTriggerAllEvent(null, rateLimiterMock),
669+
reconciliationDispatcherMock,
670+
eventSourceManagerMock,
671+
null));
672+
when(reconciliationDispatcherMock.handleExecution(any()))
673+
.thenReturn(PostExecutionControl.defaultDispatch());
674+
when(eventSourceManagerMock.retryEventSource()).thenReturn(mock(TimerEventSource.class));
675+
eventProcessor.start();
676+
677+
eventProcessor.handleEvent(prepareCREvent1());
678+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
679+
680+
eventProcessor.handleEvent(prepareCRDeleteEvent1());
681+
waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
682+
var captor = ArgumentCaptor.forClass(ExecutionScope.class);
683+
verify(reconciliationDispatcherMock, times(2)).handleExecution(captor.capture());
684+
assertThat(captor.getAllValues().get(1).getResource()).isNotNull();
665685
}
666686

667687
@Test

0 commit comments

Comments
 (0)