@@ -132,7 +132,7 @@ void ifExecutionInProgressWaitsUntilItsFinished() {
132
132
void schedulesAnEventRetryOnException () {
133
133
TestCustomResource customResource = testCustomResource ();
134
134
135
- ExecutionScope executionScope = new ExecutionScope (null , false , false );
135
+ ExecutionScope executionScope = new ExecutionScope (null , null , false , false );
136
136
executionScope .setResource (customResource );
137
137
PostExecutionControl postExecutionControl =
138
138
PostExecutionControl .exceptionDuringExecution (new RuntimeException ("test" ));
@@ -274,7 +274,7 @@ void cancelScheduleOnceEventsOnSuccessfulExecution() {
274
274
var cr = testCustomResource (crID );
275
275
276
276
eventProcessor .eventProcessingFinished (
277
- new ExecutionScope (null , false , false ).setResource (cr ),
277
+ new ExecutionScope (null , null , false , false ).setResource (cr ),
278
278
PostExecutionControl .defaultDispatch ());
279
279
280
280
verify (retryTimerEventSourceMock , times (1 )).cancelOnceSchedule (eq (crID ));
@@ -329,7 +329,7 @@ void startProcessedMarkedEventReceivedBefore() {
329
329
void notUpdatesEventSourceHandlerIfResourceUpdated () {
330
330
TestCustomResource customResource = testCustomResource ();
331
331
ExecutionScope executionScope =
332
- new ExecutionScope (null , false , false ).setResource (customResource );
332
+ new ExecutionScope (null , null , false , false ).setResource (customResource );
333
333
PostExecutionControl postExecutionControl =
334
334
PostExecutionControl .customResourceStatusPatched (customResource );
335
335
@@ -343,7 +343,7 @@ void notReschedulesAfterTheFinalizerRemoveProcessed() {
343
343
TestCustomResource customResource = testCustomResource ();
344
344
markForDeletion (customResource );
345
345
ExecutionScope executionScope =
346
- new ExecutionScope (null , false , false ).setResource (customResource );
346
+ new ExecutionScope (null , null , false , false ).setResource (customResource );
347
347
PostExecutionControl postExecutionControl =
348
348
PostExecutionControl .customResourceFinalizerRemoved (customResource );
349
349
@@ -357,7 +357,7 @@ void skipEventProcessingIfFinalizerRemoveProcessed() {
357
357
TestCustomResource customResource = testCustomResource ();
358
358
markForDeletion (customResource );
359
359
ExecutionScope executionScope =
360
- new ExecutionScope (null , false , false ).setResource (customResource );
360
+ new ExecutionScope (null , null , false , false ).setResource (customResource );
361
361
PostExecutionControl postExecutionControl =
362
362
PostExecutionControl .customResourceFinalizerRemoved (customResource );
363
363
@@ -375,7 +375,7 @@ void newResourceAfterMissedDeleteEvent() {
375
375
TestCustomResource customResource = testCustomResource ();
376
376
markForDeletion (customResource );
377
377
ExecutionScope executionScope =
378
- new ExecutionScope (null , false , false ).setResource (customResource );
378
+ new ExecutionScope (null , null , false , false ).setResource (customResource );
379
379
PostExecutionControl postExecutionControl =
380
380
PostExecutionControl .customResourceFinalizerRemoved (customResource );
381
381
var newResource = testCustomResource ();
@@ -412,7 +412,7 @@ void rateLimitsReconciliationSubmission() {
412
412
void schedulesRetryForMarReconciliationInterval () {
413
413
TestCustomResource customResource = testCustomResource ();
414
414
ExecutionScope executionScope =
415
- new ExecutionScope (null , false , false ).setResource (customResource );
415
+ new ExecutionScope (null , null , false , false ).setResource (customResource );
416
416
PostExecutionControl postExecutionControl = PostExecutionControl .defaultDispatch ();
417
417
418
418
eventProcessorWithRetry .eventProcessingFinished (executionScope , postExecutionControl );
@@ -435,7 +435,7 @@ void schedulesRetryForMarReconciliationIntervalIfRetryExhausted() {
435
435
metricsMock ));
436
436
eventProcessorWithRetry .start ();
437
437
ExecutionScope executionScope =
438
- new ExecutionScope (null , false , false ).setResource (testCustomResource ());
438
+ new ExecutionScope (null , null , false , false ).setResource (testCustomResource ());
439
439
PostExecutionControl postExecutionControl =
440
440
PostExecutionControl .exceptionDuringExecution (new RuntimeException ());
441
441
when (eventProcessorWithRetry .retryEventSource ()).thenReturn (retryTimerEventSourceMock );
@@ -522,6 +522,7 @@ void triggerOnAllEventProcessesDeleteEvent() {
522
522
verify (reconciliationDispatcherMock , times (2 )).handleExecution (any ());
523
523
}
524
524
525
+ // this is a special corner case that needs special care
525
526
@ Test
526
527
void triggerOnAllEventDeleteEventInstantlyAfterEvent () {
527
528
var reconciliationDispatcherMock = mock (ReconciliationDispatcher .class );
@@ -540,6 +541,29 @@ void triggerOnAllEventDeleteEventInstantlyAfterEvent() {
540
541
eventProcessor .handleEvent (prepareCREvent1 ());
541
542
eventProcessor .handleEvent (prepareCRDeleteEvent1 ());
542
543
544
+ waitUntilProcessingFinished (eventProcessor , TestUtils .testCustomResource1Id ());
545
+ verify (reconciliationDispatcherMock , times (1 )).handleExecution (any ());
546
+ }
547
+
548
+ @ Test
549
+ void triggerOnAllEventDeleteEventAfterEventProcessed () {
550
+ var reconciliationDispatcherMock = mock (ReconciliationDispatcher .class );
551
+ when (reconciliationDispatcherMock .handleExecution (any ()))
552
+ .thenReturn (PostExecutionControl .defaultDispatch ());
553
+ when (eventSourceManagerMock .retryEventSource ()).thenReturn (mock (TimerEventSource .class ));
554
+ eventProcessor =
555
+ spy (
556
+ new EventProcessor (
557
+ controllerConfigTriggerAllEvent (null , rateLimiterMock ),
558
+ reconciliationDispatcherMock ,
559
+ eventSourceManagerMock ,
560
+ null ));
561
+ eventProcessor .start ();
562
+
563
+ eventProcessor .handleEvent (prepareCREvent1 ());
564
+ waitUntilProcessingFinished (eventProcessor , TestUtils .testCustomResource1Id ());
565
+
566
+ eventProcessor .handleEvent (prepareCRDeleteEvent1 ());
543
567
waitUntilProcessingFinished (eventProcessor , TestUtils .testCustomResource1Id ());
544
568
verify (reconciliationDispatcherMock , times (2 )).handleExecution (any ());
545
569
}
@@ -584,6 +608,9 @@ void passesResourceFromStateToDispatcher() {
584
608
// check also last state unknown
585
609
}
586
610
611
+ @ Test
612
+ void onAllEventRateLimiting () {}
613
+
587
614
private ResourceID eventAlreadyUnderProcessing () {
588
615
when (reconciliationDispatcherMock .handleExecution (any ()))
589
616
.then (
0 commit comments