k8s.io/kubernetes@v1.29.3/test/e2e/storage/vsphere/vsphere_common.go (about) 1 /* 2 Copyright 2017 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 vsphere 18 19 import ( 20 "os" 21 "strconv" 22 23 "github.com/onsi/gomega" 24 "k8s.io/kubernetes/test/e2e/framework" 25 ) 26 27 // VSphereCSIMigrationEnabled is the environment variables to help 28 // determine test verification flow. 29 const VSphereCSIMigrationEnabled = "VSPHERE_CSI_MIGRATION_ENABLED" 30 31 // environment variables related to datastore parameters 32 const ( 33 SPBMPolicyName = "VSPHERE_SPBM_POLICY_NAME" 34 StorageClassDatastoreName = "VSPHERE_DATASTORE" 35 SecondSharedDatastore = "VSPHERE_SECOND_SHARED_DATASTORE" 36 KubernetesClusterName = "VSPHERE_KUBERNETES_CLUSTER" 37 SPBMTagPolicy = "VSPHERE_SPBM_TAG_POLICY" 38 VCPClusterDatastore = "CLUSTER_DATASTORE" 39 SPBMPolicyDataStoreCluster = "VSPHERE_SPBM_POLICY_DS_CLUSTER" 40 ) 41 42 // environment variables used for scaling tests 43 const ( 44 VCPScaleVolumeCount = "VCP_SCALE_VOLUME_COUNT" 45 VCPScaleVolumesPerPod = "VCP_SCALE_VOLUME_PER_POD" 46 VCPScaleInstances = "VCP_SCALE_INSTANCES" 47 ) 48 49 // environment variables used for stress tests 50 const ( 51 VCPStressInstances = "VCP_STRESS_INSTANCES" 52 VCPStressIterations = "VCP_STRESS_ITERATIONS" 53 ) 54 55 // environment variables used for performance tests 56 const ( 57 VCPPerfVolumeCount = "VCP_PERF_VOLUME_COUNT" 58 VCPPerfVolumesPerPod = "VCP_PERF_VOLUME_PER_POD" 59 VCPPerfIterations = "VCP_PERF_ITERATIONS" 60 ) 61 62 // environment variables used for zone tests 63 const ( 64 VCPZoneVsanDatastore1 = "VCP_ZONE_VSANDATASTORE1" 65 VCPZoneVsanDatastore2 = "VCP_ZONE_VSANDATASTORE2" 66 VCPZoneLocalDatastore = "VCP_ZONE_LOCALDATASTORE" 67 VCPZoneCompatPolicyName = "VCP_ZONE_COMPATPOLICY_NAME" 68 VCPZoneNonCompatPolicyName = "VCP_ZONE_NONCOMPATPOLICY_NAME" 69 VCPZoneA = "VCP_ZONE_A" 70 VCPZoneB = "VCP_ZONE_B" 71 VCPZoneC = "VCP_ZONE_C" 72 VCPZoneD = "VCP_ZONE_D" 73 VCPInvalidZone = "VCP_INVALID_ZONE" 74 ) 75 76 // storage class parameters 77 const ( 78 Datastore = "datastore" 79 PolicyDiskStripes = "diskStripes" 80 PolicyHostFailuresToTolerate = "hostFailuresToTolerate" 81 PolicyCacheReservation = "cacheReservation" 82 PolicyObjectSpaceReservation = "objectSpaceReservation" 83 PolicyIopsLimit = "iopsLimit" 84 DiskFormat = "diskformat" 85 SpbmStoragePolicy = "storagepolicyname" 86 ) 87 88 // test values for storage class parameters 89 const ( 90 ThinDisk = "thin" 91 BronzeStoragePolicy = "bronze" 92 HostFailuresToTolerateCapabilityVal = "0" 93 CacheReservationCapabilityVal = "20" 94 DiskStripesCapabilityVal = "1" 95 ObjectSpaceReservationCapabilityVal = "30" 96 IopsLimitCapabilityVal = "100" 97 StripeWidthCapabilityVal = "2" 98 DiskStripesCapabilityInvalidVal = "14" 99 HostFailuresToTolerateCapabilityInvalidVal = "4" 100 ) 101 102 // GetAndExpectStringEnvVar returns the string value of an environment variable or fails if 103 // the variable is not set 104 func GetAndExpectStringEnvVar(varName string) string { 105 varValue := os.Getenv(varName) 106 gomega.Expect(varValue).NotTo(gomega.BeEmpty(), "ENV "+varName+" is not set") 107 return varValue 108 } 109 110 // GetAndExpectIntEnvVar returns the integer value of an environment variable or fails if 111 // the variable is not set 112 func GetAndExpectIntEnvVar(varName string) int { 113 varValue := GetAndExpectStringEnvVar(varName) 114 varIntValue, err := strconv.Atoi(varValue) 115 framework.ExpectNoError(err, "Error Parsing "+varName) 116 return varIntValue 117 } 118 119 // GetAndExpectBoolEnvVar returns the bool value of an environment variable 120 // if environment variable is not set return false 121 func GetAndExpectBoolEnvVar(varName string) bool { 122 varValue := os.Getenv(varName) 123 if varValue == "" { 124 return false 125 } 126 varBoolValue, err := strconv.ParseBool(varValue) 127 framework.ExpectNoError(err, "Error Parsing "+varName) 128 return varBoolValue 129 }