Skip to content

Commit 672af94

Browse files
authored
Merge pull request kubernetes#125981 from dims/cleanup-pods-after-test-runs
[e2e-node] Cleanup pods after the test runs
2 parents 4a214f6 + f6836df commit 672af94

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

test/e2e_node/container_lifecycle_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func prefixedName(namePrefix string, name string) string {
5151

5252
var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() {
5353
f := framework.NewDefaultFramework("containers-lifecycle-test")
54+
addAfterEachForCleaningUpPods(f)
5455
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
5556

5657
ginkgo.It("should launch init container serially before a regular container", func() {
@@ -909,6 +910,7 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun
909910

910911
var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() {
911912
f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
913+
addAfterEachForCleaningUpPods(f)
912914
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
913915

914916
ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {
@@ -1049,6 +1051,7 @@ var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() {
10491051

10501052
var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func() {
10511053
f := framework.NewDefaultFramework("containers-lifecycle-test")
1054+
addAfterEachForCleaningUpPods(f)
10521055
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
10531056

10541057
ginkgo.When("using a Pod with restartPolicy=Never, three init container and two restartable init containers", ginkgo.Ordered, func() {
@@ -3119,6 +3122,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
31193122

31203123
var _ = SIGDescribe(nodefeature.SidecarContainers, framework.WithSerial(), "Containers Lifecycle", func() {
31213124
f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
3125+
addAfterEachForCleaningUpPods(f)
31223126
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
31233127

31243128
ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {

test/e2e_node/pids_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,6 @@ var _ = SIGDescribe("PodPidsLimit", framework.WithSerial(), func() {
128128
initialConfig.PodPidsLimit = int64(1024)
129129
})
130130
runPodPidsLimitTests(f)
131+
addAfterEachForCleaningUpPods(f)
131132
})
132133
})

test/e2e_node/pod_conditions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
5858
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, true))
5959
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, true))
6060
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true))
61-
cleanupPods(f)
61+
addAfterEachForCleaningUpPods(f)
6262
})
6363

6464
ginkgo.Context("without PodReadyToStartContainersCondition condition", func() {
6565
ginkgo.It("a pod without init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, false, false))
6666
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false))
6767
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false))
6868
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, false))
69-
cleanupPods(f)
69+
addAfterEachForCleaningUpPods(f)
7070
})
7171
})
7272

test/e2e_node/quota_lsci_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ var _ = SIGDescribe("LocalStorageCapacityIsolationFSQuotaMonitoring", framework.
103103
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
104104
runOneQuotaTest(f, true)
105105
runOneQuotaTest(f, false)
106+
addAfterEachForCleaningUpPods(f)
106107
})
107108

108109
const (

test/e2e_node/swap_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ var (
5656
noLimits *resource.Quantity = nil
5757
)
5858

59-
var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, func() {
59+
var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, framework.WithSerial(), func() {
6060
f := framework.NewDefaultFramework("swap-qos")
61+
addAfterEachForCleaningUpPods(f)
6162
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
6263

6364
ginkgo.BeforeEach(func() {

test/e2e_node/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func getCurrentKubeletConfig(ctx context.Context) (*kubeletconfig.KubeletConfigu
171171
return e2enodekubelet.GetCurrentKubeletConfig(ctx, framework.TestContext.NodeName, "", false, framework.TestContext.StandaloneMode)
172172
}
173173

174-
func cleanupPods(f *framework.Framework) {
174+
func addAfterEachForCleaningUpPods(f *framework.Framework) {
175175
ginkgo.AfterEach(func(ctx context.Context) {
176176
ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name)
177177
l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{})

0 commit comments

Comments
 (0)