Skip to content

Commit f7cb942

Browse files
committed
Replace PollImmediate with PollUntilContextTimeout
Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent 7c83034 commit f7cb942

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

test/integration/framework/server.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,25 @@ func StartTestServer(tb testing.TB) (kcpclientset.ClusterInterface, kcpkubernete
100100

101101
kcpServerClientConfig := rest.CopyConfig(completedConfig.GenericConfig.LoopbackClientConfig)
102102

103-
if err := wait.PollImmediate(1*time.Second, 60*time.Second, func() (done bool, err error) {
104-
if err := ctx.Err(); err != nil {
105-
return false, err
106-
}
107-
108-
healthzConfig := rest.CopyConfig(kcpServerClientConfig)
109-
kcpClient, err := client.NewForConfig(healthzConfig)
110-
if err != nil {
111-
// this happens because we race the API server start
112-
tb.Log(err)
113-
return false, nil
114-
}
115-
116-
healthStatus := 0
117-
kcpClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do(ctx).StatusCode(&healthStatus)
118-
if healthStatus != http.StatusOK {
119-
return false, nil
120-
}
121-
122-
return true, nil
123-
}); err != nil {
103+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 60*time.Second, true,
104+
func(ctx context.Context) (done bool, err error) {
105+
healthzConfig := rest.CopyConfig(kcpServerClientConfig)
106+
kcpClient, err := client.NewForConfig(healthzConfig)
107+
if err != nil {
108+
// this happens because we race the API server start
109+
tb.Log(err)
110+
return false, nil
111+
}
112+
113+
healthStatus := 0
114+
kcpClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do(ctx).StatusCode(&healthStatus)
115+
if healthStatus != http.StatusOK {
116+
return false, nil
117+
}
118+
119+
return true, nil
120+
},
121+
); err != nil {
124122
tb.Fatal(err)
125123
}
126124

0 commit comments

Comments
 (0)