Skip to content

Commit 5cf6507

Browse files
authored
Merge pull request kubernetes#88016 from jsafrane/wait-for-pod-deletion
Delete pod in volume tests
2 parents 64340bd + 528adbe commit 5cf6507

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

test/e2e/common/volumes.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ package common
4444

4545
import (
4646
"context"
47-
"k8s.io/api/core/v1"
47+
48+
v1 "k8s.io/api/core/v1"
4849
clientset "k8s.io/client-go/kubernetes"
4950
"k8s.io/kubernetes/test/e2e/framework"
5051
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
@@ -76,7 +77,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
7677
ginkgo.Describe("NFSv4", func() {
7778
ginkgo.It("should be mountable for NFSv4", func() {
7879
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
79-
defer volume.TestCleanup(f, config)
80+
defer volume.TestServerCleanup(f, config)
8081

8182
tests := []volume.Test{
8283
{
@@ -100,7 +101,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
100101
ginkgo.Describe("NFSv3", func() {
101102
ginkgo.It("should be mountable for NFSv3", func() {
102103
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
103-
defer volume.TestCleanup(f, config)
104+
defer volume.TestServerCleanup(f, config)
104105

105106
tests := []volume.Test{
106107
{
@@ -129,7 +130,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
129130
config, _, _ := volume.NewGlusterfsServer(c, namespace.Name)
130131
name := config.Prefix + "-server"
131132
defer func() {
132-
volume.TestCleanup(f, config)
133+
volume.TestServerCleanup(f, config)
133134
err := c.CoreV1().Endpoints(namespace.Name).Delete(context.TODO(), name, nil)
134135
framework.ExpectNoError(err, "defer: Gluster delete endpoints failed")
135136
}()

test/e2e/framework/volume/fixtures.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,17 @@ func startVolumeServer(client clientset.Interface, config TestConfig) *v1.Pod {
328328
return pod
329329
}
330330

331-
// TestCleanup cleans both server and client pods.
332-
func TestCleanup(f *framework.Framework, config TestConfig) {
331+
// TestServerCleanup cleans server pod.
332+
func TestServerCleanup(f *framework.Framework, config TestConfig) {
333333
ginkgo.By(fmt.Sprint("cleaning the environment after ", config.Prefix))
334-
335334
defer ginkgo.GinkgoRecover()
336335

337-
cs := f.ClientSet
338-
339-
err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-client", config.Namespace)
340-
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-client", config.Namespace)
341-
342-
if config.ServerImage != "" {
343-
err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-server", config.Namespace)
344-
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace)
336+
if config.ServerImage == "" {
337+
return
345338
}
339+
340+
err := e2epod.DeletePodWithWaitByName(f.ClientSet, config.Prefix+"-server", config.Namespace)
341+
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace)
346342
}
347343

348344
func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix string, privileged bool, fsGroup *int64, tests []Test) (*v1.Pod, error) {
@@ -479,8 +475,12 @@ func TestVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64,
479475
clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests)
480476
if err != nil {
481477
framework.Failf("Failed to create client pod: %v", err)
482-
483478
}
479+
defer func() {
480+
e2epod.DeletePodOrFail(f.ClientSet, clientPod.Namespace, clientPod.Name)
481+
e2epod.WaitForPodToDisappear(f.ClientSet, clientPod.Namespace, clientPod.Name, labels.Everything(), framework.Poll, framework.PodDeleteTimeout)
482+
}()
483+
484484
framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(f.ClientSet, clientPod))
485485
testVolumeContent(f, clientPod, fsGroup, fsType, tests)
486486
}

test/e2e/storage/flexvolume.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ func testFlexVolume(driver string, config volume.TestConfig, f *framework.Framew
6565
},
6666
}
6767
volume.TestVolumeClient(f, config, nil, "" /* fsType */, tests)
68-
69-
volume.TestCleanup(f, config)
7068
}
7169

7270
// installFlex installs the driver found at filePath on the node, and restarts

test/e2e/storage/testsuites/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (t *volumesTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
156156

157157
init()
158158
defer func() {
159-
volume.TestCleanup(f, convertTestConfig(l.config))
159+
volume.TestServerCleanup(f, convertTestConfig(l.config))
160160
cleanup()
161161
}()
162162

test/e2e/storage/volumes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package storage
2020

2121
import (
2222
"context"
23+
2324
"github.com/onsi/ginkgo"
2425
v1 "k8s.io/api/core/v1"
2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -49,8 +50,6 @@ var _ = utils.SIGDescribe("Volumes", func() {
4950
Namespace: namespace.Name,
5051
Prefix: "configmap",
5152
}
52-
53-
defer volume.TestCleanup(f, config)
5453
configMap := &v1.ConfigMap{
5554
TypeMeta: metav1.TypeMeta{
5655
Kind: "ConfigMap",

0 commit comments

Comments
 (0)