1
1
package io .javaoperatorsdk .operator .processing .event ;
2
2
3
+ import java .time .Duration ;
3
4
import java .util .List ;
4
5
import java .util .Optional ;
5
6
import java .util .UUID ;
24
25
25
26
import static io .javaoperatorsdk .operator .TestUtils .testCustomResource ;
26
27
import static org .assertj .core .api .Assertions .assertThat ;
28
+ import static org .awaitility .Awaitility .await ;
27
29
import static org .mockito .ArgumentMatchers .eq ;
28
30
import static org .mockito .ArgumentMatchers .isNull ;
29
31
import static org .mockito .Mockito .*;
@@ -152,16 +154,20 @@ void successfulExecutionResetsTheRetry() {
152
154
eventProcessorWithRetry .handleEvent (event );
153
155
verify (reconciliationDispatcherMock , timeout (SEPARATE_EXECUTION_TIMEOUT ).times (1 ))
154
156
.handleExecution (any ());
157
+ waitUntilProcessingFinished (eventProcessorWithRetry , event .getRelatedCustomResourceID ());
155
158
156
159
eventProcessorWithRetry .handleEvent (event );
157
160
verify (reconciliationDispatcherMock , timeout (SEPARATE_EXECUTION_TIMEOUT ).times (2 ))
158
161
.handleExecution (any ());
162
+ waitUntilProcessingFinished (eventProcessorWithRetry , event .getRelatedCustomResourceID ());
159
163
160
164
eventProcessorWithRetry .handleEvent (event );
161
165
verify (reconciliationDispatcherMock , timeout (SEPARATE_EXECUTION_TIMEOUT ).times (3 ))
162
166
.handleExecution (executionScopeArgumentCaptor .capture ());
167
+ waitUntilProcessingFinished (eventProcessorWithRetry , event .getRelatedCustomResourceID ());
163
168
log .info ("Finished successfulExecutionResetsTheRetry" );
164
169
170
+
165
171
List <ExecutionScope > executionScopes = executionScopeArgumentCaptor .getAllValues ();
166
172
167
173
assertThat (executionScopes ).hasSize (3 );
@@ -171,6 +177,12 @@ void successfulExecutionResetsTheRetry() {
171
177
assertThat (executionScopes .get (1 ).getRetryInfo ().isLastAttempt ()).isEqualTo (false );
172
178
}
173
179
180
+ private void waitUntilProcessingFinished (EventProcessor eventProcessor ,
181
+ ResourceID relatedCustomResourceID ) {
182
+ await ().atMost (Duration .ofSeconds (3 ))
183
+ .until (() -> !eventProcessor .isUnderProcessing (relatedCustomResourceID ));
184
+ }
185
+
174
186
@ Test
175
187
void scheduleTimedEventIfInstructedByPostExecutionControl () {
176
188
var testDelay = 10000L ;
0 commit comments