mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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:
parent
9c69db3f04
commit
adfff27279
@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
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) {
|
func (tpd *testPodData) deletePodsForTest(f *framework.Framework) {
|
||||||
|
podNS := f.Namespace.Name
|
||||||
|
var wg sync.WaitGroup
|
||||||
for podName := range tpd.PodMap {
|
for podName := range tpd.PodMap {
|
||||||
|
wg.Add(1)
|
||||||
|
go func(podName string) {
|
||||||
|
defer ginkgo.GinkgoRecover()
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
deletePodSyncByName(f, podName)
|
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) {
|
func (tpd *testPodData) deletePod(f *framework.Framework, podName string) {
|
||||||
_, ok := tpd.PodMap[podName]
|
_, ok := tpd.PodMap[podName]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user