node: e2e: run deleteSync in parallel

speedup the cleanup after testcases deleting pods in separate
goroutines.
The post-test cleanup stage must be done carefully since pod require
exclusive allocation - so pods must take all the steps to properly
cleanup the tests to avoid to pollute the environment, but
this has a negative effect on test duration (take longer).

Hence, we add safe speedups like doing pod deletions in parallel.

Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
Francesco Romani 2020-11-02 08:54:19 +01:00
parent 9c69db3f04
commit adfff27279

View File

@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"strings"
"sync"
"time"
v1 "k8s.io/api/core/v1"
@ -140,12 +141,24 @@ func (tpd *testPodData) createPodsForTest(f *framework.Framework, podReqs []podD
}
}
/* deletePodsForTest clean up all the pods run for a testcase. Must ensure proper cleanup */
func (tpd *testPodData) deletePodsForTest(f *framework.Framework) {
podNS := f.Namespace.Name
var wg sync.WaitGroup
for podName := range tpd.PodMap {
deletePodSyncByName(f, podName)
wg.Add(1)
go func(podName string) {
defer ginkgo.GinkgoRecover()
defer wg.Done()
deletePodSyncByName(f, podName)
waitForAllContainerRemoval(podName, podNS)
}(podName)
}
wg.Wait()
}
/* deletePod removes pod during a test. Should do a best-effort clean up */
func (tpd *testPodData) deletePod(f *framework.Framework, podName string) {
_, ok := tpd.PodMap[podName]
if !ok {