Skip to content

Commit b9d0e5a

Browse files
csviriCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 268bb3d commit b9d0e5a

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/cachingfilteringupdate/CachingFilteringUpdateIT.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,35 @@ void testResourceAccessAfterUpdate() {
4545
await()
4646
.pollDelay(Duration.ofSeconds(5))
4747
.atMost(Duration.ofMinutes(1))
48-
.untilAsserted(
48+
.until(
4949
() -> {
50-
for (int i = 0; i < RESOURCE_NUMBER; i++) {
51-
if (operator
52-
.getReconcilerOfType(CachingFilteringUpdateReconciler.class)
53-
.isIssueFound()) {
54-
throw new IllegalStateException("Error already found.");
55-
}
56-
var res = operator.get(CachingFilteringUpdateCustomResource.class, "resource" + i);
57-
assertThat(res.getStatus()).isNotNull();
58-
assertThat(res.getStatus().getUpdated()).isTrue();
50+
if (operator
51+
.getReconcilerOfType(CachingFilteringUpdateReconciler.class)
52+
.isIssueFound()) {
53+
// Stop waiting as soon as an issue is detected.
54+
return true;
5955
}
56+
// Use a single representative resource to detect that updates have completed.
57+
var res =
58+
operator.get(
59+
CachingFilteringUpdateCustomResource.class,
60+
"resource" + (RESOURCE_NUMBER - 1));
61+
return res != null
62+
&& res.getStatus() != null
63+
&& Boolean.TRUE.equals(res.getStatus().getUpdated());
6064
});
65+
66+
if (operator
67+
.getReconcilerOfType(CachingFilteringUpdateReconciler.class)
68+
.isIssueFound()) {
69+
throw new IllegalStateException("Error already found.");
70+
}
71+
72+
for (int i = 0; i < RESOURCE_NUMBER; i++) {
73+
var res = operator.get(CachingFilteringUpdateCustomResource.class, "resource" + i);
74+
assertThat(res.getStatus()).isNotNull();
75+
assertThat(res.getStatus().getUpdated()).isTrue();
76+
}
6177
}
6278

6379
public CachingFilteringUpdateCustomResource createCustomResource(int i) {

0 commit comments

Comments
 (0)