Skip to content

Commit c1dbb41

Browse files
authored
Merge pull request kubernetes-client#1865 from dddddai/master
Kill some hard-coded sleep in tests
2 parents c932fbe + cedca7e commit c1dbb41

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

util/src/test/java/io/kubernetes/client/CopyTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.kubernetes.client.util.exception.CopyNotSupportedException;
3030
import java.io.File;
3131
import java.io.IOException;
32+
import java.io.InputStream;
3233
import java.nio.file.Paths;
3334
import org.junit.Before;
3435
import org.junit.Rule;
@@ -69,13 +70,14 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
6970
.withBody("{}")));
7071

7172
try {
72-
copy.copyFileFromPod(pod, "container", "/some/path/to/file");
73+
InputStream inputStream = copy.copyFileFromPod(pod, "container", "/some/path/to/file");
74+
// block until the connection is established
75+
inputStream.read();
76+
inputStream.close();
7377
} catch (IOException | ApiException e) {
7478
e.printStackTrace();
7579
}
7680

77-
Thread.sleep(2000);
78-
7981
wireMockRule.verify(
8082
getRequestedFor(
8183
urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec"))

util/src/test/java/io/kubernetes/client/PortForwardTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
7878
assertThrows(
7979
ApiException.class,
8080
() -> {
81-
forward.forward(pod, ports);
81+
InputStream inputStream = forward.forward(pod, ports).getInputStream(portNumber);
82+
// block until the connection is established
83+
inputStream.read();
84+
inputStream.close();
8285
});
8386

84-
// TODO: Kill this sleep, the trouble is that the test tries to validate before the
85-
// connection
86-
// event has happened
87-
Thread.sleep(2000);
88-
8987
wireMockRule.verify(
9088
getRequestedFor(
9189
urlPathEqualTo(

0 commit comments

Comments
 (0)