Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 834e72b

Browse files
committed
Remove sleep from probe unit test
Signed-off-by: JoshVanL <[email protected]>
1 parent bb141c9 commit 834e72b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pkg/probe/probe_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"net/http"
99
"testing"
10-
"time"
1110

1211
"k8s.io/apiserver/pkg/authentication/authenticator"
1312

@@ -50,14 +49,22 @@ func TestRun(t *testing.T) {
5049
t.FailNow()
5150
}
5251

53-
// Wait for probe to become ready
54-
time.Sleep(time.Second)
55-
5652
url := fmt.Sprintf("http://0.0.0.0:%s", port)
5753

58-
resp, err := http.Get(url + "/ready")
59-
if err != nil {
60-
t.Fatalf("unexpected error: %s", err)
54+
var resp *http.Response
55+
var i int
56+
57+
for {
58+
resp, err = http.Get(url + "/ready")
59+
if err == nil {
60+
break
61+
}
62+
63+
if i >= 5 {
64+
t.Errorf("unexpected error: %s", err)
65+
t.FailNow()
66+
}
67+
i++
6168
}
6269

6370
if resp.StatusCode != 503 {

0 commit comments

Comments
 (0)