Skip to content

Commit 528adbe

Browse files
committed
Remove client cleanup from TestCleanup
All tests remove the test client pod, usually in TestVolumeClient. Rename TestCleanup to TestServerCleanup. In addition, remove few calls to Test(Server)Cleanup that do not do anything useful (server pod is not used in these tests).
1 parent 2430c48 commit 528adbe

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
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: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,17 @@ func startVolumeServer(client clientset.Interface, config TestConfig) *v1.Pod {
334334
return pod
335335
}
336336

337-
// TestCleanup cleans both server and client pods.
338-
func TestCleanup(f *framework.Framework, config TestConfig) {
337+
// TestServerCleanup cleans server pod.
338+
func TestServerCleanup(f *framework.Framework, config TestConfig) {
339339
ginkgo.By(fmt.Sprint("cleaning the environment after ", config.Prefix))
340-
341340
defer ginkgo.GinkgoRecover()
342341

343-
cs := f.ClientSet
344-
345-
err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-client", config.Namespace)
346-
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-client", config.Namespace)
347-
348-
if config.ServerImage != "" {
349-
err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-server", config.Namespace)
350-
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace)
342+
if config.ServerImage == "" {
343+
return
351344
}
345+
346+
err := e2epod.DeletePodWithWaitByName(f.ClientSet, config.Prefix+"-server", config.Namespace)
347+
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace)
352348
}
353349

354350
func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix string, privileged bool, fsGroup *int64, tests []Test) (*v1.Pod, error) {

test/e2e/storage/flexvolume.go

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

7169
// 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)