apiserver/filters test: fix data race and do not leak goroutines

Signed-off-by: Adhityaa Chandrasekar <adtac@google.com>
This commit is contained in:
Adhityaa Chandrasekar 2020-11-04 18:58:06 +00:00
parent 396b90f06c
commit a2eb6d67ee

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",