mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 17:39:56 +00:00
Merge pull request #63086 from soltysh/discovery_timeout
Automatic merge from submit-queue (batch tested with PRs 63129, 63066, 60009, 63136, 63086). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix discovery default timeout test /assign @sttts **Release note**: ```release-note NONE ``` Kubernetes-commit: a53df4d90565d9adc8352758c99d7aa0d0624394
This commit is contained in:
commit
3df37beef0
@ -131,18 +131,23 @@ func TestGetServerGroupsWithBrokenServer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestGetServerGroupsWithTimeout(t *testing.T) {
|
||||
done := make(chan bool)
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
time.Sleep(2 * time.Second)
|
||||
// first we need to write headers, otherwise http client will complain about
|
||||
// exceeding timeout awaiting headers, only after we can block the call
|
||||
w.WriteHeader(http.StatusOK)
|
||||
<-done
|
||||
}))
|
||||
defer server.Close()
|
||||
defer close(done)
|
||||
tmp := defaultTimeout
|
||||
defaultTimeout = 1 * time.Second
|
||||
defaultTimeout = 2 * time.Second
|
||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
||||
_, err := client.ServerGroups()
|
||||
if err == nil || strings.Contains(err.Error(), "deadline") {
|
||||
if err == nil || !strings.Contains(err.Error(), "deadline") {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
done <- true
|
||||
defaultTimeout = tmp
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user