Skip to content

Commit e9053ee

Browse files
authored
improve: integration test for PerResourcePollingEventSource delete event propagation (#3278)
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent b63edd6 commit e9053ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/perresourceeventsource/PerResourcePollingEventSourceIT.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515
*/
1616
package io.javaoperatorsdk.operator.baseapi.perresourceeventsource;
1717

18+
import java.time.Duration;
19+
1820
import org.junit.jupiter.api.Test;
1921
import org.junit.jupiter.api.extension.RegisterExtension;
2022

2123
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
2224
import io.javaoperatorsdk.annotation.Sample;
2325
import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension;
2426

27+
import static io.javaoperatorsdk.operator.baseapi.perresourceeventsource.PerResourcePollingEventSourceTestReconciler.POLL_PERIOD;
2528
import static org.assertj.core.api.Assertions.assertThat;
2629
import static org.awaitility.Awaitility.await;
2730

@@ -49,20 +52,32 @@ class PerResourcePollingEventSourceIT {
4952
* works with the underling mechanisms in event source manager and other parts of the system.
5053
*/
5154
@Test
52-
void fetchedAndReconciledMultipleTimes() {
55+
void fetchedAndReconciledMultipleTimes() throws InterruptedException {
5356
operator.create(resource(NAME_1));
5457
operator.create(resource(NAME_2));
5558

5659
var reconciler =
5760
operator.getReconcilerOfType(PerResourcePollingEventSourceTestReconciler.class);
5861
await()
62+
.pollInterval(Duration.ofMillis(POLL_PERIOD))
5963
.untilAsserted(
6064
() -> {
6165
assertThat(reconciler.getNumberOfExecutions(NAME_1)).isGreaterThan(2);
6266
assertThat(reconciler.getNumberOfFetchExecution(NAME_1)).isGreaterThan(2);
6367
assertThat(reconciler.getNumberOfExecutions(NAME_2)).isGreaterThan(2);
6468
assertThat(reconciler.getNumberOfFetchExecution(NAME_2)).isGreaterThan(2);
6569
});
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);
6681
}
6782

6883
private PerResourceEventSourceCustomResource resource(String name) {

0 commit comments

Comments
 (0)