github.com/kubernetes-sigs/blobfuse-csi-driver@v0.5.0/test/e2e/testsuites/dynamically_provisioned_collocated_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 // DynamicallyProvisionedCollocatedPodTest will provision required StorageClass(es), PVC(s) and Pod(s) 28 // Waiting for the PV provisioner to create a new PV 29 // Testing if multiple Pod(s) can write simultaneously 30 type DynamicallyProvisionedCollocatedPodTest struct { 31 CSIDriver driver.DynamicPVTestDriver 32 Pods []PodDetails 33 ColocatePods bool 34 } 35 36 func (t *DynamicallyProvisionedCollocatedPodTest) Run(client clientset.Interface, namespace *v1.Namespace) { 37 nodeName := "" 38 for _, pod := range t.Pods { 39 tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver) 40 if t.ColocatePods && nodeName != "" { 41 tpod.SetNodeSelector(map[string]string{"name": nodeName}) 42 } 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 pod") 49 tpod.Create() 50 defer tpod.Cleanup() 51 52 ginkgo.By("checking that the pod is running") 53 tpod.WaitForRunning() 54 nodeName = tpod.pod.Spec.NodeName 55 } 56 }