From 2430c48c104fd99ce02e14bf1b5d63d40bffea9f Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Tue, 11 Feb 2020 12:54:38 +0100 Subject: [PATCH 1/2] Delete pod in volume tests All storage e2e tests should delete pods they use so we can identify issues on volume cleanup easily. --- test/e2e/framework/volume/fixtures.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 30d0000f75d..73667eedbec 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -486,8 +486,12 @@ func TestVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64, clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests) if err != nil { framework.Failf("Failed to create client pod: %v", err) - } + defer func() { + e2epod.DeletePodOrFail(f.ClientSet, clientPod.Namespace, clientPod.Name) + e2epod.WaitForPodToDisappear(f.ClientSet, clientPod.Namespace, clientPod.Name, labels.Everything(), framework.Poll, framework.PodDeleteTimeout) + }() + framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(f.ClientSet, clientPod)) testVolumeContent(f, clientPod, fsGroup, fsType, tests) } From 528adbefe4daf3a10629fcffa3f085c9d4952af7 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Thu, 13 Feb 2020 09:55:53 +0100 Subject: [PATCH 2/2] 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). --- test/e2e/common/volumes.go | 9 +++++---- test/e2e/framework/volume/fixtures.go | 18 +++++++----------- test/e2e/storage/flexvolume.go | 2 -- test/e2e/storage/testsuites/volumes.go | 2 +- test/e2e/storage/volumes.go | 3 +-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/test/e2e/common/volumes.go b/test/e2e/common/volumes.go index 159fcb303aa..1d1b0975fee 100644 --- a/test/e2e/common/volumes.go +++ b/test/e2e/common/volumes.go @@ -44,7 +44,8 @@ package common import ( "context" - "k8s.io/api/core/v1" + + v1 "k8s.io/api/core/v1" clientset "k8s.io/client-go/kubernetes" "k8s.io/kubernetes/test/e2e/framework" e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper" @@ -76,7 +77,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { ginkgo.Describe("NFSv4", func() { ginkgo.It("should be mountable for NFSv4", func() { config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{}) - defer volume.TestCleanup(f, config) + defer volume.TestServerCleanup(f, config) tests := []volume.Test{ { @@ -100,7 +101,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { ginkgo.Describe("NFSv3", func() { ginkgo.It("should be mountable for NFSv3", func() { config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{}) - defer volume.TestCleanup(f, config) + defer volume.TestServerCleanup(f, config) tests := []volume.Test{ { @@ -129,7 +130,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { config, _, _ := volume.NewGlusterfsServer(c, namespace.Name) name := config.Prefix + "-server" defer func() { - volume.TestCleanup(f, config) + volume.TestServerCleanup(f, config) err := c.CoreV1().Endpoints(namespace.Name).Delete(context.TODO(), name, nil) framework.ExpectNoError(err, "defer: Gluster delete endpoints failed") }() diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 73667eedbec..39f114de97c 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -334,21 +334,17 @@ func startVolumeServer(client clientset.Interface, config TestConfig) *v1.Pod { return pod } -// TestCleanup cleans both server and client pods. -func TestCleanup(f *framework.Framework, config TestConfig) { +// TestServerCleanup cleans server pod. +func TestServerCleanup(f *framework.Framework, config TestConfig) { ginkgo.By(fmt.Sprint("cleaning the environment after ", config.Prefix)) - defer ginkgo.GinkgoRecover() - cs := f.ClientSet - - err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-client", config.Namespace) - gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-client", config.Namespace) - - if config.ServerImage != "" { - err := e2epod.DeletePodWithWaitByName(cs, config.Prefix+"-server", config.Namespace) - gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace) + if config.ServerImage == "" { + return } + + err := e2epod.DeletePodWithWaitByName(f.ClientSet, config.Prefix+"-server", config.Namespace) + gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace) } func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix string, privileged bool, fsGroup *int64, tests []Test) (*v1.Pod, error) { diff --git a/test/e2e/storage/flexvolume.go b/test/e2e/storage/flexvolume.go index bf4cc74950f..b6cbd776fc6 100644 --- a/test/e2e/storage/flexvolume.go +++ b/test/e2e/storage/flexvolume.go @@ -64,8 +64,6 @@ func testFlexVolume(driver string, config volume.TestConfig, f *framework.Framew }, } volume.TestVolumeClient(f, config, nil, "" /* fsType */, tests) - - volume.TestCleanup(f, config) } // installFlex installs the driver found at filePath on the node, and restarts diff --git a/test/e2e/storage/testsuites/volumes.go b/test/e2e/storage/testsuites/volumes.go index 9a20f53df38..e3ce36c163f 100644 --- a/test/e2e/storage/testsuites/volumes.go +++ b/test/e2e/storage/testsuites/volumes.go @@ -156,7 +156,7 @@ func (t *volumesTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T init() defer func() { - volume.TestCleanup(f, convertTestConfig(l.config)) + volume.TestServerCleanup(f, convertTestConfig(l.config)) cleanup() }() diff --git a/test/e2e/storage/volumes.go b/test/e2e/storage/volumes.go index 28c0442378b..001cc2ff5e7 100644 --- a/test/e2e/storage/volumes.go +++ b/test/e2e/storage/volumes.go @@ -20,6 +20,7 @@ package storage import ( "context" + "github.com/onsi/ginkgo" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -49,8 +50,6 @@ var _ = utils.SIGDescribe("Volumes", func() { Namespace: namespace.Name, Prefix: "configmap", } - - defer volume.TestCleanup(f, config) configMap := &v1.ConfigMap{ TypeMeta: metav1.TypeMeta{ Kind: "ConfigMap",