github.com/kubernetes-sigs/blobfuse-csi-driver@v0.5.0/test/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package testsuites 18 19 import ( 20 "sigs.k8s.io/blobfuse-csi-driver/test/e2e/driver" 21 22 "github.com/onsi/ginkgo" 23 v1 "k8s.io/api/core/v1" 24 clientset "k8s.io/client-go/kubernetes" 25 ) 26 27 // DynamicallyProvisionedDeletePodTest will provision required StorageClass and Deployment 28 // Testing if the Pod can write and read to mounted volumes 29 // Deleting a pod, and again testing if the Pod can write and read to mounted volumes 30 type DynamicallyProvisionedDeletePodTest struct { 31 CSIDriver driver.DynamicPVTestDriver 32 Pod PodDetails 33 PodCheck *PodExecCheck 34 } 35 36 type PodExecCheck struct { 37 Cmd []string 38 ExpectedString string 39 } 40 41 func (t *DynamicallyProvisionedDeletePodTest) Run(client clientset.Interface, namespace *v1.Namespace) { 42 tDeployment, cleanup := t.Pod.SetupDeployment(client, namespace, t.CSIDriver) 43 // defer must be called here for resources not get removed before using them 44 for i := range cleanup { 45 defer cleanup[i]() 46 } 47 48 ginkgo.By("deploying the deployment") 49 tDeployment.Create() 50 51 ginkgo.By("checking that the pod is running") 52 tDeployment.WaitForPodReady() 53 54 ginkgo.By("deleting the pod for deployment") 55 tDeployment.DeletePodAndWait() 56 57 ginkgo.By("checking again that the pod is running") 58 tDeployment.WaitForPodReady() 59 60 if t.PodCheck != nil { 61 ginkgo.By("checking pod exec") 62 tDeployment.Exec(t.PodCheck.Cmd, t.PodCheck.ExpectedString) 63 } 64 }