mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Fix MaxInFlight test
This commit is contained in:
parent
147b6911f5
commit
2766272fff
@ -61,8 +61,8 @@ func TestMaxInFlight(t *testing.T) {
|
|||||||
const Iterations = 3
|
const Iterations = 3
|
||||||
block := sync.WaitGroup{}
|
block := sync.WaitGroup{}
|
||||||
block.Add(1)
|
block.Add(1)
|
||||||
oneFinished := sync.WaitGroup{}
|
oneAccountedFinished := sync.WaitGroup{}
|
||||||
oneFinished.Add(1)
|
oneAccountedFinished.Add(1)
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
sem := make(chan bool, Iterations)
|
sem := make(chan bool, Iterations)
|
||||||
|
|
||||||
@ -88,15 +88,14 @@ func TestMaxInFlight(t *testing.T) {
|
|||||||
// These should hang waiting on block...
|
// These should hang waiting on block...
|
||||||
go func() {
|
go func() {
|
||||||
expectHTTP(server.URL+"/foo/bar/watch", http.StatusOK, t)
|
expectHTTP(server.URL+"/foo/bar/watch", http.StatusOK, t)
|
||||||
once.Do(oneFinished.Done)
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These should hang, but not affect accounting.
|
||||||
for i := 0; i < Iterations; i++ {
|
for i := 0; i < Iterations; i++ {
|
||||||
// These should hang waiting on block...
|
// These should hang waiting on block...
|
||||||
go func() {
|
go func() {
|
||||||
expectHTTP(server.URL+"/proxy/foo/bar", http.StatusOK, t)
|
expectHTTP(server.URL+"/proxy/foo/bar", http.StatusOK, t)
|
||||||
once.Do(oneFinished.Done)
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
expectHTTP(server.URL+"/dontwait", http.StatusOK, t)
|
expectHTTP(server.URL+"/dontwait", http.StatusOK, t)
|
||||||
@ -105,7 +104,7 @@ func TestMaxInFlight(t *testing.T) {
|
|||||||
// These should hang waiting on block...
|
// These should hang waiting on block...
|
||||||
go func() {
|
go func() {
|
||||||
expectHTTP(server.URL, http.StatusOK, t)
|
expectHTTP(server.URL, http.StatusOK, t)
|
||||||
once.Do(oneFinished.Done)
|
once.Do(oneAccountedFinished.Done)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
calls.Wait()
|
calls.Wait()
|
||||||
@ -123,7 +122,7 @@ func TestMaxInFlight(t *testing.T) {
|
|||||||
|
|
||||||
// Show that we recover from being blocked up.
|
// Show that we recover from being blocked up.
|
||||||
// However, we should until at least one of the requests really finishes.
|
// However, we should until at least one of the requests really finishes.
|
||||||
oneFinished.Wait()
|
oneAccountedFinished.Wait()
|
||||||
expectHTTP(server.URL, http.StatusOK, t)
|
expectHTTP(server.URL, http.StatusOK, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user