Skip to content

Commit 853feb2

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 53f57ea commit 853feb2

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • sample-operators/metrics-processing/src/test/java/io/javaoperatorsdk/operator/sample/metrics

sample-operators/metrics-processing/src/test/java/io/javaoperatorsdk/operator/sample/metrics/MetricsHandlingE2E.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.ArrayDeque;
2424
import java.util.Deque;
2525
import java.util.Optional;
26+
import java.util.concurrent.atomic.AtomicReference;
2627

2728
import org.junit.jupiter.api.AfterAll;
2829
import org.junit.jupiter.api.BeforeAll;
@@ -101,16 +102,18 @@ void cleanup() throws IOException {
101102

102103
private LocalPortForward portForward(String labelKey, String labelValue, int port) {
103104
log.info("Waiting for pod with label {}={} to be ready...", labelKey, labelValue);
105+
AtomicReference<Pod> portForwardPod = new AtomicReference<>();
106+
104107
await()
105108
.atMost(Duration.ofMinutes(15))
106109
.pollInterval(Duration.ofSeconds(10))
107-
.until(() -> findReadyPod(labelKey, labelValue).isPresent());
108-
var pod =
109-
findReadyPod(labelKey, labelValue)
110-
.orElseThrow(
111-
() ->
112-
new IllegalStateException(
113-
"Pod not found for label " + labelKey + "=" + labelValue));
110+
.untilAsserted(
111+
() -> {
112+
var pod = findReadyPod(labelKey, labelValue);
113+
assertThat(pod).isPresent();
114+
portForwardPod.set(pod.orElseThrow());
115+
});
116+
var pod = portForwardPod.get();
114117
log.info(
115118
"Pod {} is ready, establishing port-forward on port {}", pod.getMetadata().getName(), port);
116119
return client

0 commit comments

Comments
 (0)