Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions util/src/test/java/io/kubernetes/client/CopyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ void setup() {
podName = "apod";
}

// Wait (bounded) until the exec request reaches the mock server, instead of a fixed sleep
// which is flaky on slow CI runners.
private void waitForExecRequest() throws InterruptedException {
long deadline = System.currentTimeMillis() + 30000;
while (System.currentTimeMillis() < deadline
&& apiServer
.findAll(
getRequestedFor(
urlPathEqualTo(
"/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")))
.isEmpty()) {
Thread.sleep(100);
}
}

@Test
void url() {
Copy copy = new Copy(client);
Expand Down Expand Up @@ -195,7 +210,7 @@ public void run() {
}
});
t.start();
Thread.sleep(2000);
waitForExecRequest();
t.interrupt();

apiServer.verify(
Expand Down Expand Up @@ -241,7 +256,7 @@ public void run() {
}
});
t.start();
Thread.sleep(2000);
waitForExecRequest();
t.interrupt();

apiServer.verify(
Expand Down Expand Up @@ -285,7 +300,7 @@ public void run() {
}
});
t.start();
Thread.sleep(2000);
waitForExecRequest();
t.interrupt();

apiServer.verify(
Expand Down