mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-29 04:02:18 +00:00
Fix discovery default timeout test
Kubernetes-commit: af2353f8a3ab06ca105d15a0b1b27605e4093da5
This commit is contained in:
parent
d36be08adf
commit
581437501a
@ -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