Merge pull request #96229 from adtac/apfrace

apiserver/filters test: fix data race and do not leak goroutines
This commit is contained in:
Kubernetes Prow Robot 2020-11-05 06:31:44 -08:00 committed by GitHub
commit ec1541c38f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -294,15 +294,17 @@ func TestApfExecuteMultipleRequests(t *testing.T) {
defer cancel()
StartPriorityAndFairnessWatermarkMaintenance(ctx.Done())
var wg sync.WaitGroup
wg.Add(concurrentRequests)
for i := 0; i < concurrentRequests; i++ {
var err error
go func() {
err = expectHTTPGet(fmt.Sprintf("%s/api/v1/namespaces/default", server.URL), http.StatusOK)
defer wg.Done()
if err := expectHTTPGet(fmt.Sprintf("%s/api/v1/namespaces/default", server.URL), http.StatusOK); err != nil {
t.Error(err)
}
}()
if err != nil {
t.Error(err)
}
}
wg.Wait()
checkForExpectedMetricsWithRetry(t, []string{
"apiserver_current_inflight_requests",