mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #107992 from tkashem/flake-timeout
fix flake in TestTimeoutHeaders
This commit is contained in:
commit
5cee90c305
@ -138,7 +138,7 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}()
|
}()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
postTimeoutFn()
|
defer postTimeoutFn()
|
||||||
tw.timeout(err)
|
tw.timeout(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,6 +219,7 @@ func TestTimeoutHeaders(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postTimeoutCh := make(chan struct{})
|
||||||
ts := httptest.NewServer(
|
ts := httptest.NewServer(
|
||||||
withDeadline(
|
withDeadline(
|
||||||
WithTimeout(
|
WithTimeout(
|
||||||
@ -226,13 +227,18 @@ func TestTimeoutHeaders(t *testing.T) {
|
|||||||
h := w.Header()
|
h := w.Header()
|
||||||
// trigger the timeout
|
// trigger the timeout
|
||||||
cancel()
|
cancel()
|
||||||
// mutate response Headers
|
// keep mutating response Headers until the request times out
|
||||||
for j := 0; j < 1000; j++ {
|
for {
|
||||||
|
select {
|
||||||
|
case <-postTimeoutCh:
|
||||||
|
return
|
||||||
|
default:
|
||||||
h.Set("Test", "post")
|
h.Set("Test", "post")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
func(req *http.Request) (*http.Request, bool, func(), *apierrors.StatusError) {
|
func(req *http.Request) (*http.Request, bool, func(), *apierrors.StatusError) {
|
||||||
return req, false, func() {}, apierrors.NewServerTimeout(schema.GroupResource{Group: "foo", Resource: "bar"}, "get", 0)
|
return req, false, func() { close(postTimeoutCh) }, apierrors.NewServerTimeout(schema.GroupResource{Group: "foo", Resource: "bar"}, "get", 0)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user