mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #88016 from jsafrane/wait-for-pod-deletion
Delete pod in volume tests
This commit is contained in:
commit
5cf65077ad
@ -44,7 +44,8 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
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.Describe("NFSv4", func() {
|
||||||
ginkgo.It("should be mountable for NFSv4", func() {
|
ginkgo.It("should be mountable for NFSv4", func() {
|
||||||
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
|
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
|
||||||
defer volume.TestCleanup(f, config)
|
defer volume.TestServerCleanup(f, config)
|
||||||
|
|
||||||
tests := []volume.Test{
|
tests := []volume.Test{
|
||||||
{
|
{
|
||||||
@ -100,7 +101,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
|
|||||||
ginkgo.Describe("NFSv3", func() {
|
ginkgo.Describe("NFSv3", func() {
|
||||||
ginkgo.It("should be mountable for NFSv3", func() {
|
ginkgo.It("should be mountable for NFSv3", func() {
|
||||||
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
|
config, _, serverIP := volume.NewNFSServer(c, namespace.Name, []string{})
|
||||||
defer volume.TestCleanup(f, config)
|
defer volume.TestServerCleanup(f, config)
|
||||||
|
|
||||||
tests := []volume.Test{
|
tests := []volume.Test{
|
||||||
{
|
{
|
||||||
@ -129,7 +130,7 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() {
|
|||||||
config, _, _ := volume.NewGlusterfsServer(c, namespace.Name)
|
config, _, _ := volume.NewGlusterfsServer(c, namespace.Name)
|
||||||
name := config.Prefix + "-server"
|
name := config.Prefix + "-server"
|
||||||
defer func() {
|
defer func() {
|
||||||
volume.TestCleanup(f, config)
|
volume.TestServerCleanup(f, config)
|
||||||
err := c.CoreV1().Endpoints(namespace.Name).Delete(context.TODO(), name, nil)
|
err := c.CoreV1().Endpoints(namespace.Name).Delete(context.TODO(), name, nil)
|
||||||
framework.ExpectNoError(err, "defer: Gluster delete endpoints failed")
|
framework.ExpectNoError(err, "defer: Gluster delete endpoints failed")
|
||||||
}()
|
}()
|
||||||
|
@ -328,21 +328,17 @@ func startVolumeServer(client clientset.Interface, config TestConfig) *v1.Pod {
|
|||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCleanup cleans both server and client pods.
|
// TestServerCleanup cleans server pod.
|
||||||
func TestCleanup(f *framework.Framework, config TestConfig) {
|
func TestServerCleanup(f *framework.Framework, config TestConfig) {
|
||||||
ginkgo.By(fmt.Sprint("cleaning the environment after ", config.Prefix))
|
ginkgo.By(fmt.Sprint("cleaning the environment after ", config.Prefix))
|
||||||
|
|
||||||
defer ginkgo.GinkgoRecover()
|
defer ginkgo.GinkgoRecover()
|
||||||
|
|
||||||
cs := f.ClientSet
|
if config.ServerImage == "" {
|
||||||
|
return
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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,
|
|||||||
clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests)
|
clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("Failed to create client pod: %v", err)
|
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))
|
framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(f.ClientSet, clientPod))
|
||||||
testVolumeContent(f, clientPod, fsGroup, fsType, tests)
|
testVolumeContent(f, clientPod, fsGroup, fsType, tests)
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,6 @@ func testFlexVolume(driver string, config volume.TestConfig, f *framework.Framew
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
volume.TestVolumeClient(f, config, nil, "" /* fsType */, tests)
|
volume.TestVolumeClient(f, config, nil, "" /* fsType */, tests)
|
||||||
|
|
||||||
volume.TestCleanup(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
|
||||||
|
@ -156,7 +156,7 @@ func (t *volumesTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
|
|||||||
|
|
||||||
init()
|
init()
|
||||||
defer func() {
|
defer func() {
|
||||||
volume.TestCleanup(f, convertTestConfig(l.config))
|
volume.TestServerCleanup(f, convertTestConfig(l.config))
|
||||||
cleanup()
|
cleanup()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -49,8 +50,6 @@ var _ = utils.SIGDescribe("Volumes", func() {
|
|||||||
Namespace: namespace.Name,
|
Namespace: namespace.Name,
|
||||||
Prefix: "configmap",
|
Prefix: "configmap",
|
||||||
}
|
}
|
||||||
|
|
||||||
defer volume.TestCleanup(f, config)
|
|
||||||
configMap := &v1.ConfigMap{
|
configMap := &v1.ConfigMap{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
Kind: "ConfigMap",
|
Kind: "ConfigMap",
|
||||||
|
Loading…
Reference in New Issue
Block a user