sigs.k8s.io/blob-csi-driver@v1.24.1/test/e2e/testsuites/dynamically_provisioned_reclaim_policy_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 "context" 21 22 "sigs.k8s.io/blob-csi-driver/pkg/blob" 23 "sigs.k8s.io/blob-csi-driver/test/e2e/driver" 24 25 v1 "k8s.io/api/core/v1" 26 clientset "k8s.io/client-go/kubernetes" 27 ) 28 29 // DynamicallyProvisionedReclaimPolicyTest will provision required PV(s) and PVC(s) 30 // Testing the correct behavior for different reclaimPolicies 31 type DynamicallyProvisionedReclaimPolicyTest struct { 32 CSIDriver driver.DynamicPVTestDriver 33 Volumes []VolumeDetails 34 Driver *blob.Driver 35 StorageClassParameters map[string]string 36 } 37 38 func (t *DynamicallyProvisionedReclaimPolicyTest) Run(ctx context.Context, client clientset.Interface, namespace *v1.Namespace) { 39 for _, volume := range t.Volumes { 40 tpvc, _ := volume.SetupDynamicPersistentVolumeClaim(ctx, client, namespace, t.CSIDriver, t.StorageClassParameters) 41 42 // will delete the PVC 43 // will also wait for PV to be deleted when reclaimPolicy=Delete 44 tpvc.Cleanup(ctx) 45 // first check PV stills exists, then manually delete it 46 if tpvc.ReclaimPolicy() == v1.PersistentVolumeReclaimRetain { 47 tpvc.WaitForPersistentVolumePhase(ctx, v1.VolumeReleased) 48 tpvc.DeleteBoundPersistentVolume(ctx) 49 tpvc.DeleteBackingVolume(ctx, t.Driver) 50 } 51 } 52 }