Skip to content

Commit 435938c

Browse files
brendandburnsbrendanburns
authored andcommitted
Remove a sleep from CopyTest to deflake it.
1 parent cbbc4a6 commit 435938c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.IOException;
3232
import java.io.InputStream;
3333
import java.nio.file.Paths;
34+
import java.util.concurrent.Semaphore;
3435
import org.junit.Before;
3536
import org.junit.Rule;
3637
import org.junit.Test;
@@ -70,6 +71,8 @@ public void testUrl() throws IOException, ApiException, InterruptedException {
7071
.withHeader("Content-Type", "application/json")
7172
.withBody("{}")));
7273

74+
final Semaphore s = new Semaphore(1);
75+
s.acquire();
7376
Thread t =
7477
new Thread(
7578
new Runnable() {
@@ -79,12 +82,13 @@ public void run() {
7982
InputStream is = copy.copyFileFromPod(pod, "container", "/some/path/to/file");
8083
} catch (IOException | ApiException e) {
8184
e.printStackTrace();
85+
} finally {
86+
s.release();
8287
}
8388
}
8489
});
8590
t.start();
86-
Thread.sleep(2000);
87-
t.interrupt();
91+
s.acquire();
8892

8993
verify(
9094
getRequestedFor(

0 commit comments

Comments
 (0)