From adfff27279f10997f67ab4b889ed270118bef52a Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Mon, 2 Nov 2020 08:54:19 +0100 Subject: [PATCH] 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 --- test/e2e_node/podresources_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/e2e_node/podresources_test.go b/test/e2e_node/podresources_test.go index b8704861211..0cc8cc195fb 100644 --- a/test/e2e_node/podresources_test.go +++ b/test/e2e_node/podresources_test.go @@ -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 {