vsphere_common.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package vsphere
  14. import (
  15. "os"
  16. "strconv"
  17. "github.com/onsi/gomega"
  18. "k8s.io/kubernetes/test/e2e/framework"
  19. )
  20. // environment variables related to datastore parameters
  21. const (
  22. SPBMPolicyName = "VSPHERE_SPBM_POLICY_NAME"
  23. StorageClassDatastoreName = "VSPHERE_DATASTORE"
  24. SecondSharedDatastore = "VSPHERE_SECOND_SHARED_DATASTORE"
  25. KubernetesClusterName = "VSPHERE_KUBERNETES_CLUSTER"
  26. SPBMTagPolicy = "VSPHERE_SPBM_TAG_POLICY"
  27. VCPClusterDatastore = "CLUSTER_DATASTORE"
  28. SPBMPolicyDataStoreCluster = "VSPHERE_SPBM_POLICY_DS_CLUSTER"
  29. )
  30. // environment variables used for scaling tests
  31. const (
  32. VCPScaleVolumeCount = "VCP_SCALE_VOLUME_COUNT"
  33. VCPScaleVolumesPerPod = "VCP_SCALE_VOLUME_PER_POD"
  34. VCPScaleInstances = "VCP_SCALE_INSTANCES"
  35. )
  36. // environment variables used for stress tests
  37. const (
  38. VCPStressInstances = "VCP_STRESS_INSTANCES"
  39. VCPStressIterations = "VCP_STRESS_ITERATIONS"
  40. )
  41. // environment variables used for performance tests
  42. const (
  43. VCPPerfVolumeCount = "VCP_PERF_VOLUME_COUNT"
  44. VCPPerfVolumesPerPod = "VCP_PERF_VOLUME_PER_POD"
  45. VCPPerfIterations = "VCP_PERF_ITERATIONS"
  46. )
  47. // environment variables used for zone tests
  48. const (
  49. VCPZoneVsanDatastore1 = "VCP_ZONE_VSANDATASTORE1"
  50. VCPZoneVsanDatastore2 = "VCP_ZONE_VSANDATASTORE2"
  51. VCPZoneLocalDatastore = "VCP_ZONE_LOCALDATASTORE"
  52. VCPZoneCompatPolicyName = "VCP_ZONE_COMPATPOLICY_NAME"
  53. VCPZoneNonCompatPolicyName = "VCP_ZONE_NONCOMPATPOLICY_NAME"
  54. VCPZoneA = "VCP_ZONE_A"
  55. VCPZoneB = "VCP_ZONE_B"
  56. VCPZoneC = "VCP_ZONE_C"
  57. VCPZoneD = "VCP_ZONE_D"
  58. VCPInvalidZone = "VCP_INVALID_ZONE"
  59. )
  60. // storage class parameters
  61. const (
  62. Datastore = "datastore"
  63. PolicyDiskStripes = "diskStripes"
  64. PolicyHostFailuresToTolerate = "hostFailuresToTolerate"
  65. PolicyCacheReservation = "cacheReservation"
  66. PolicyObjectSpaceReservation = "objectSpaceReservation"
  67. PolicyIopsLimit = "iopsLimit"
  68. DiskFormat = "diskformat"
  69. SpbmStoragePolicy = "storagepolicyname"
  70. )
  71. // test values for storage class parameters
  72. const (
  73. ThinDisk = "thin"
  74. BronzeStoragePolicy = "bronze"
  75. HostFailuresToTolerateCapabilityVal = "0"
  76. CacheReservationCapabilityVal = "20"
  77. DiskStripesCapabilityVal = "1"
  78. ObjectSpaceReservationCapabilityVal = "30"
  79. IopsLimitCapabilityVal = "100"
  80. StripeWidthCapabilityVal = "2"
  81. DiskStripesCapabilityInvalidVal = "14"
  82. HostFailuresToTolerateCapabilityInvalidVal = "4"
  83. )
  84. // GetAndExpectStringEnvVar returns the string value of an environment variable or fails if
  85. // the variable is not set
  86. func GetAndExpectStringEnvVar(varName string) string {
  87. varValue := os.Getenv(varName)
  88. gomega.Expect(varValue).NotTo(gomega.BeEmpty(), "ENV "+varName+" is not set")
  89. return varValue
  90. }
  91. // GetAndExpectIntEnvVar returns the integer value of an environment variable or fails if
  92. // the variable is not set
  93. func GetAndExpectIntEnvVar(varName string) int {
  94. varValue := GetAndExpectStringEnvVar(varName)
  95. varIntValue, err := strconv.Atoi(varValue)
  96. framework.ExpectNoError(err, "Error Parsing "+varName)
  97. return varIntValue
  98. }