mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-26 07:02:01 +00:00
Merge pull request #63875 from deads2k/client-10-timeout
Automatic merge from submit-queue (batch tested with PRs 63875, 63817). 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>. make TestGetServerGroupsWithTimeout more reliable Stops overriding a global variable in a test and tolerates a different kind of timeout message you can see. /assign @soltysh Kubernetes-commit: baad3d4159db43927e250d4b3f23d6e083b01294
This commit is contained in:
commit
ea16f6128e
60
Godeps/Godeps.json
generated
60
Godeps/Godeps.json
generated
@ -268,123 +268,123 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
|
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
|
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1",
|
"ImportPath": "k8s.io/api/apps/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1beta1",
|
"ImportPath": "k8s.io/api/apps/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/apps/v1beta2",
|
"ImportPath": "k8s.io/api/apps/v1beta2",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authentication/v1",
|
"ImportPath": "k8s.io/api/authentication/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authentication/v1beta1",
|
"ImportPath": "k8s.io/api/authentication/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authorization/v1",
|
"ImportPath": "k8s.io/api/authorization/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/authorization/v1beta1",
|
"ImportPath": "k8s.io/api/authorization/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/autoscaling/v1",
|
"ImportPath": "k8s.io/api/autoscaling/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
|
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v1",
|
"ImportPath": "k8s.io/api/batch/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v1beta1",
|
"ImportPath": "k8s.io/api/batch/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/batch/v2alpha1",
|
"ImportPath": "k8s.io/api/batch/v2alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/certificates/v1beta1",
|
"ImportPath": "k8s.io/api/certificates/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/core/v1",
|
"ImportPath": "k8s.io/api/core/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/events/v1beta1",
|
"ImportPath": "k8s.io/api/events/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/extensions/v1beta1",
|
"ImportPath": "k8s.io/api/extensions/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
|
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/networking/v1",
|
"ImportPath": "k8s.io/api/networking/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/policy/v1beta1",
|
"ImportPath": "k8s.io/api/policy/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1",
|
"ImportPath": "k8s.io/api/rbac/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1alpha1",
|
"ImportPath": "k8s.io/api/rbac/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/rbac/v1beta1",
|
"ImportPath": "k8s.io/api/rbac/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
|
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/scheduling/v1beta1",
|
"ImportPath": "k8s.io/api/scheduling/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/settings/v1alpha1",
|
"ImportPath": "k8s.io/api/settings/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/storage/v1",
|
"ImportPath": "k8s.io/api/storage/v1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/storage/v1alpha1",
|
"ImportPath": "k8s.io/api/storage/v1alpha1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api/storage/v1beta1",
|
"ImportPath": "k8s.io/api/storage/v1beta1",
|
||||||
"Rev": "ef391d2c23625c579885ab0a689293ded22d11b4"
|
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||||
|
@ -136,20 +136,26 @@ func TestGetServerGroupsWithTimeout(t *testing.T) {
|
|||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
// first we need to write headers, otherwise http client will complain about
|
// first we need to write headers, otherwise http client will complain about
|
||||||
// exceeding timeout awaiting headers, only after we can block the call
|
// exceeding timeout awaiting headers, only after we can block the call
|
||||||
w.WriteHeader(http.StatusOK)
|
w.Header().Set("Connection", "keep-alive")
|
||||||
|
if wf, ok := w.(http.Flusher); ok {
|
||||||
|
wf.Flush()
|
||||||
|
}
|
||||||
<-done
|
<-done
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
defer close(done)
|
defer close(done)
|
||||||
tmp := defaultTimeout
|
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL, Timeout: 2 * time.Second})
|
||||||
defaultTimeout = 2 * time.Second
|
|
||||||
client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL})
|
|
||||||
_, err := client.ServerGroups()
|
_, err := client.ServerGroups()
|
||||||
if err == nil || !strings.Contains(err.Error(), "deadline") {
|
// the error we're getting here is wrapped in errors.errorString which makes
|
||||||
|
// it impossible to unwrap and check it's attributes, so instead we're checking
|
||||||
|
// the textual output which is presenting http.httpError with timeout set to true
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("missing error")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "timeout:true") &&
|
||||||
|
!strings.Contains(err.Error(), "context.deadlineExceededError") {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
done <- true
|
|
||||||
defaultTimeout = tmp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetServerResourcesWithV1Server(t *testing.T) {
|
func TestGetServerResourcesWithV1Server(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user