|
15 | 15 | */ |
16 | 16 | package io.javaoperatorsdk.operator.baseapi.perresourceeventsource; |
17 | 17 |
|
| 18 | +import java.time.Duration; |
| 19 | + |
18 | 20 | import org.junit.jupiter.api.Test; |
19 | 21 | import org.junit.jupiter.api.extension.RegisterExtension; |
20 | 22 |
|
21 | 23 | import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; |
22 | 24 | import io.javaoperatorsdk.annotation.Sample; |
23 | 25 | import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension; |
24 | 26 |
|
| 27 | +import static io.javaoperatorsdk.operator.baseapi.perresourceeventsource.PerResourcePollingEventSourceTestReconciler.POLL_PERIOD; |
25 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
26 | 29 | import static org.awaitility.Awaitility.await; |
27 | 30 |
|
@@ -49,20 +52,32 @@ class PerResourcePollingEventSourceIT { |
49 | 52 | * works with the underling mechanisms in event source manager and other parts of the system. |
50 | 53 | */ |
51 | 54 | @Test |
52 | | - void fetchedAndReconciledMultipleTimes() { |
| 55 | + void fetchedAndReconciledMultipleTimes() throws InterruptedException { |
53 | 56 | operator.create(resource(NAME_1)); |
54 | 57 | operator.create(resource(NAME_2)); |
55 | 58 |
|
56 | 59 | var reconciler = |
57 | 60 | operator.getReconcilerOfType(PerResourcePollingEventSourceTestReconciler.class); |
58 | 61 | await() |
| 62 | + .pollInterval(Duration.ofMillis(POLL_PERIOD)) |
59 | 63 | .untilAsserted( |
60 | 64 | () -> { |
61 | 65 | assertThat(reconciler.getNumberOfExecutions(NAME_1)).isGreaterThan(2); |
62 | 66 | assertThat(reconciler.getNumberOfFetchExecution(NAME_1)).isGreaterThan(2); |
63 | 67 | assertThat(reconciler.getNumberOfExecutions(NAME_2)).isGreaterThan(2); |
64 | 68 | assertThat(reconciler.getNumberOfFetchExecution(NAME_2)).isGreaterThan(2); |
65 | 69 | }); |
| 70 | + |
| 71 | + operator.delete(resource(NAME_2)); |
| 72 | + Thread.sleep(1000 + POLL_PERIOD); |
| 73 | + |
| 74 | + var fe1 = reconciler.getNumberOfFetchExecution(NAME_1); |
| 75 | + var fe2 = reconciler.getNumberOfFetchExecution(NAME_2); |
| 76 | + await() |
| 77 | + .pollInterval(Duration.ofMillis(POLL_PERIOD)) |
| 78 | + .untilAsserted( |
| 79 | + () -> assertThat(reconciler.getNumberOfFetchExecution(NAME_1)).isGreaterThan(fe1 + 5)); |
| 80 | + assertThat(reconciler.getNumberOfFetchExecution(NAME_2)).isEqualTo(fe2); |
66 | 81 | } |
67 | 82 |
|
68 | 83 | private PerResourceEventSourceCustomResource resource(String name) { |
|
0 commit comments