Unverified Commit c36a5043 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #54613 from jianglingxia/jlx-flexvolume

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. if judgement always true in e2e **What this PR does / why we need it**: the if judge always true so remove the var and fix defer func **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents 12e5db56 7a1195fd
...@@ -56,9 +56,7 @@ import ( ...@@ -56,9 +56,7 @@ import (
var _ = Describe("[sig-storage] GCP Volumes", func() { var _ = Describe("[sig-storage] GCP Volumes", func() {
f := framework.NewDefaultFramework("gcp-volume") f := framework.NewDefaultFramework("gcp-volume")
// If 'false', the test won't clear its volumes upon completion. Useful for debugging,
// note that namespace deletion is handled by delete-namespace flag // note that namespace deletion is handled by delete-namespace flag
clean := true
// filled in BeforeEach // filled in BeforeEach
var namespace *v1.Namespace var namespace *v1.Namespace
var c clientset.Interface var c clientset.Interface
...@@ -76,11 +74,7 @@ var _ = Describe("[sig-storage] GCP Volumes", func() { ...@@ -76,11 +74,7 @@ var _ = Describe("[sig-storage] GCP Volumes", func() {
Describe("NFSv4", func() { Describe("NFSv4", func() {
It("should be mountable for NFSv4", func() { It("should be mountable for NFSv4", func() {
config, _, serverIP := framework.NewNFSServer(c, namespace.Name, []string{}) config, _, serverIP := framework.NewNFSServer(c, namespace.Name, []string{})
defer func() { defer framework.VolumeTestCleanup(f, config)
if clean {
framework.VolumeTestCleanup(f, config)
}
}()
tests := []framework.VolumeTest{ tests := []framework.VolumeTest{
{ {
...@@ -104,11 +98,7 @@ var _ = Describe("[sig-storage] GCP Volumes", func() { ...@@ -104,11 +98,7 @@ var _ = Describe("[sig-storage] GCP Volumes", func() {
Describe("NFSv3", func() { Describe("NFSv3", func() {
It("should be mountable for NFSv3", func() { It("should be mountable for NFSv3", func() {
config, _, serverIP := framework.NewNFSServer(c, namespace.Name, []string{}) config, _, serverIP := framework.NewNFSServer(c, namespace.Name, []string{})
defer func() { defer framework.VolumeTestCleanup(f, config)
if clean {
framework.VolumeTestCleanup(f, config)
}
}()
tests := []framework.VolumeTest{ tests := []framework.VolumeTest{
{ {
...@@ -137,11 +127,9 @@ var _ = Describe("[sig-storage] GCP Volumes", func() { ...@@ -137,11 +127,9 @@ var _ = Describe("[sig-storage] GCP Volumes", func() {
config, _, _ := framework.NewGlusterfsServer(c, namespace.Name) config, _, _ := framework.NewGlusterfsServer(c, namespace.Name)
name := config.Prefix + "-server" name := config.Prefix + "-server"
defer func() { defer func() {
if clean { framework.VolumeTestCleanup(f, config)
framework.VolumeTestCleanup(f, config) err := c.CoreV1().Endpoints(namespace.Name).Delete(name, nil)
err := c.CoreV1().Endpoints(namespace.Name).Delete(name, nil) Expect(err).NotTo(HaveOccurred(), "defer: Gluster delete endpoints failed")
Expect(err).NotTo(HaveOccurred(), "defer: Gluster delete endpoints failed")
}
}() }()
tests := []framework.VolumeTest{ tests := []framework.VolumeTest{
......
...@@ -43,7 +43,7 @@ const ( ...@@ -43,7 +43,7 @@ const (
// testFlexVolume tests that a client pod using a given flexvolume driver // testFlexVolume tests that a client pod using a given flexvolume driver
// successfully mounts it and runs // successfully mounts it and runs
func testFlexVolume(driver string, cs clientset.Interface, config framework.VolumeTestConfig, f *framework.Framework, clean bool) { func testFlexVolume(driver string, cs clientset.Interface, config framework.VolumeTestConfig, f *framework.Framework) {
tests := []framework.VolumeTest{ tests := []framework.VolumeTest{
{ {
Volume: v1.VolumeSource{ Volume: v1.VolumeSource{
...@@ -58,9 +58,7 @@ func testFlexVolume(driver string, cs clientset.Interface, config framework.Volu ...@@ -58,9 +58,7 @@ func testFlexVolume(driver string, cs clientset.Interface, config framework.Volu
} }
framework.TestVolumeClient(cs, config, nil, tests) framework.TestVolumeClient(cs, config, nil, tests)
if clean { framework.VolumeTestCleanup(f, config)
framework.VolumeTestCleanup(f, config)
}
} }
// installFlex installs the driver found at filePath on the node, and restarts // installFlex installs the driver found at filePath on the node, and restarts
...@@ -141,9 +139,7 @@ func sshAndLog(cmd, host string) { ...@@ -141,9 +139,7 @@ func sshAndLog(cmd, host string) {
var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() { var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() {
f := framework.NewDefaultFramework("flexvolume") f := framework.NewDefaultFramework("flexvolume")
// If 'false', the test won't clear its volumes upon completion. Useful for debugging,
// note that namespace deletion is handled by delete-namespace flag // note that namespace deletion is handled by delete-namespace flag
clean := true
var cs clientset.Interface var cs clientset.Interface
var ns *v1.Namespace var ns *v1.Namespace
...@@ -176,7 +172,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() { ...@@ -176,7 +172,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() {
By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs)) By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs))
installFlex(&node, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */) installFlex(&node, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */)
testFlexVolume(driverInstallAs, cs, config, f, clean) testFlexVolume(driverInstallAs, cs, config, f)
By("waiting for flex client pod to terminate") By("waiting for flex client pod to terminate")
if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) { if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) {
...@@ -196,7 +192,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() { ...@@ -196,7 +192,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() {
By(fmt.Sprintf("installing flexvolume %s on master as %s", path.Join(driverDir, driver), driverInstallAs)) By(fmt.Sprintf("installing flexvolume %s on master as %s", path.Join(driverDir, driver), driverInstallAs))
installFlex(nil, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */) installFlex(nil, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */)
testFlexVolume(driverInstallAs, cs, config, f, clean) testFlexVolume(driverInstallAs, cs, config, f)
By("waiting for flex client pod to terminate") By("waiting for flex client pod to terminate")
if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) { if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) {
...@@ -216,7 +212,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() { ...@@ -216,7 +212,7 @@ var _ = SIGDescribe("Flexvolumes [Disruptive] [Feature:FlexVolume]", func() {
By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs)) By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs))
installFlex(&node, "k8s", driverInstallAs, path.Join(driverDir, driver), false /* restart */) installFlex(&node, "k8s", driverInstallAs, path.Join(driverDir, driver), false /* restart */)
testFlexVolume(driverInstallAs, cs, config, f, clean) testFlexVolume(driverInstallAs, cs, config, f)
By("waiting for flex client pod to terminate") By("waiting for flex client pod to terminate")
if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) { if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment