Unverified Commit a53df4d9 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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 ```
parents 81c00aa6 af2353f8
...@@ -131,18 +131,23 @@ func TestGetServerGroupsWithBrokenServer(t *testing.T) { ...@@ -131,18 +131,23 @@ func TestGetServerGroupsWithBrokenServer(t *testing.T) {
} }
} }
func TestGetServerGroupsWithTimeout(t *testing.T) { func TestGetServerGroupsWithTimeout(t *testing.T) {
done := make(chan bool)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 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) w.WriteHeader(http.StatusOK)
<-done
})) }))
defer server.Close() defer server.Close()
defer close(done)
tmp := defaultTimeout tmp := defaultTimeout
defaultTimeout = 1 * time.Second defaultTimeout = 2 * time.Second
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
_, err := client.ServerGroups() _, 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) t.Fatalf("unexpected error: %v", err)
} }
done <- true
defaultTimeout = tmp defaultTimeout = tmp
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment