Skip to content

Commit 6b0748d

Browse files
committed
Added e2e test to verify zone support across datacenters in the same vCenter
1 parent 0f46a8a commit 6b0748d

File tree

2 files changed

+49
-29
lines changed

2 files changed

+49
-29
lines changed

test/e2e/storage/vsphere/vsphere_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ const (
5757
const (
5858
VCPZoneVsanDatastore1 = "VCP_ZONE_VSANDATASTORE1"
5959
VCPZoneVsanDatastore2 = "VCP_ZONE_VSANDATASTORE2"
60+
VCPZoneLocalDatastore = "VCP_ZONE_LOCALDATASTORE"
6061
VCPZoneCompatPolicyName = "VCP_ZONE_COMPATPOLICY_NAME"
6162
VCPZoneNonCompatPolicyName = "VCP_ZONE_NONCOMPATPOLICY_NAME"
6263
VCPZoneA = "VCP_ZONE_A"
6364
VCPZoneB = "VCP_ZONE_B"
6465
VCPZoneC = "VCP_ZONE_C"
6566
VCPZoneD = "VCP_ZONE_D"
67+
VCPInvalidZone = "VCP_INVALID_ZONE"
6668
)
6769

6870
func GetAndExpectStringEnvVar(varName string) string {

test/e2e/storage/vsphere/vsphere_zone_support.go

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,38 @@ import (
3939
Test to verify multi-zone support for dynamic volume provisioning in kubernetes.
4040
The test environment is illustrated below:
4141
42-
datacenter
43-
--->cluster-vsan-1 (zone-a) ____________________ _________________
44-
--->host-1 : master | | | |
45-
--->host-2 : node1 | vsanDatastore | | |
46-
--->host-3 : node2 |____________________| | |
47-
| |
48-
| sharedVmfs-0 |
49-
--->cluster-vsan-2 (zone-b) ____________________ | |
50-
--->host-4 : node3 | | | |
51-
--->host-5 : node4 | vsanDatastore (1) | | |
52-
--->host-6 |____________________| |_________________|
53-
54-
--->cluster-3 (zone-c) ________________
55-
--->host-7 : node5 | |
56-
| localDatastore |
57-
|________________|
58-
____________________
59-
--->host-8 (zone-c) : node6 | |
60-
| localDatastore (1) |
61-
|____________________|
62-
42+
datacenter-1
43+
--->cluster-vsan-1 (zone-a) ____________________ _________________
44+
--->host-1 : master | | | |
45+
--->host-2 : node1 ___________________ | | | |
46+
--->host-3 (zone-c): node2 | || vsanDatastore | | |
47+
| localDatastore || | | |
48+
|___________________||____________________| | sharedVmfs-0 |
49+
--->cluster-vsan-2 (zone-b) ____________________ | |
50+
--->host-4 : node3 | | | |
51+
--->host-5 : node4 | vsanDatastore (1) | | |
52+
--->host-6 | | | |
53+
|____________________| |_________________|
54+
--->cluster-3 (zone-c) ___________________
55+
--->host-7 : node5 | |
56+
| localDatastore (1)|
57+
|___________________|
58+
datacenter-2
59+
--->cluster-1 (zone-d) ___________________
60+
--->host-8 : node6 | |
61+
| localDatastore |
62+
|___________________|
6363
6464
Testbed description :
6565
1. cluster-vsan-1 is tagged with zone-a. So, vsanDatastore inherits zone-a since all the hosts under zone-a have vsanDatastore mounted on them.
6666
2. cluster-vsan-2 is tagged with zone-b. So, vsanDatastore (1) inherits zone-b since all the hosts under zone-b have vsanDatastore (1) mounted on them.
6767
3. sharedVmfs-0 inherits both zone-a and zone-b since all the hosts in both zone-a and zone-b have this datastore mounted on them.
6868
4. cluster-3 is tagged with zone-c. cluster-3 only contains host-7.
69-
5. host-8 is not under any cluster and is tagged with zone-c.
70-
6. Since there are no shared datastores between host-7 under cluster-3 and host-8, no datastores in the environment inherit zone-c.
71-
7. The six worker nodes are distributed among the hosts as shown in the above illustration.
72-
8. Two storage policies are created on VC. One is a VSAN storage policy named as compatpolicy with hostFailuresToTolerate capability set to 1.
73-
Second is a VSAN storage policy named as noncompatpolicy with hostFailuresToTolerate capability set to 4.
69+
5. host-3 under cluster-vsan-1 is tagged with zone-c.
70+
6. Since there are no shared datastores between host-7 under cluster-3 and host-3 under cluster-vsan-1, no datastores in the environment inherit zone-c.
71+
7. host-8 under datacenter-2 and cluster-1 is tagged with zone-d. So, localDatastore attached to host-8 inherits zone-d.
72+
8. The six worker nodes are distributed among the hosts as shown in the above illustration.
73+
9. Two storage policies are created on VC. One is a VSAN storage policy named as compatpolicy with hostFailuresToTolerate capability set to 1.
7474
7575
Testsuite description :
7676
1. Tests to verify that zone labels are set correctly on a dynamically created PV.
@@ -79,6 +79,7 @@ import (
7979
datastore and VSAN capabilities.
8080
4. Tests to verify dynamic pv creation using availability zones fails in combination with other storage class parameters such as storage policy,
8181
datastore and VSAN capabilities specifications when any of the former mentioned parameters are incompatible with the rest.
82+
5. Tests to verify dynamic pv creation using availability zones work across different datacenters in the same VC.
8283
*/
8384

8485
var _ = utils.SIGDescribe("Zone Support", func() {
@@ -90,12 +91,14 @@ var _ = utils.SIGDescribe("Zone Support", func() {
9091
zones []string
9192
vsanDatastore1 string
9293
vsanDatastore2 string
94+
localDatastore string
9395
compatPolicy string
9496
nonCompatPolicy string
9597
zoneA string
9698
zoneB string
9799
zoneC string
98100
zoneD string
101+
invalidZone string
99102
)
100103
ginkgo.BeforeEach(func() {
101104
framework.SkipUnlessProviderIs("vsphere")
@@ -104,12 +107,14 @@ var _ = utils.SIGDescribe("Zone Support", func() {
104107
namespace = f.Namespace.Name
105108
vsanDatastore1 = GetAndExpectStringEnvVar(VCPZoneVsanDatastore1)
106109
vsanDatastore2 = GetAndExpectStringEnvVar(VCPZoneVsanDatastore2)
110+
localDatastore = GetAndExpectStringEnvVar(VCPZoneLocalDatastore)
107111
compatPolicy = GetAndExpectStringEnvVar(VCPZoneCompatPolicyName)
108112
nonCompatPolicy = GetAndExpectStringEnvVar(VCPZoneNonCompatPolicyName)
109113
zoneA = GetAndExpectStringEnvVar(VCPZoneA)
110114
zoneB = GetAndExpectStringEnvVar(VCPZoneB)
111115
zoneC = GetAndExpectStringEnvVar(VCPZoneC)
112116
zoneD = GetAndExpectStringEnvVar(VCPZoneD)
117+
invalidZone = GetAndExpectStringEnvVar(VCPInvalidZone)
113118
scParameters = make(map[string]string)
114119
zones = make([]string, 0)
115120
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
@@ -132,11 +137,11 @@ var _ = utils.SIGDescribe("Zone Support", func() {
132137
})
133138

134139
ginkgo.It("Verify PVC creation with invalid zone specified in storage class fails", func() {
135-
ginkgo.By(fmt.Sprintf("Creating storage class with unknown zone : %s", zoneD))
136-
zones = append(zones, zoneD)
140+
ginkgo.By(fmt.Sprintf("Creating storage class with unknown zone : %s", invalidZone))
141+
zones = append(zones, invalidZone)
137142
err := verifyPVCCreationFails(client, namespace, nil, zones, "")
138143
framework.ExpectError(err)
139-
errorMsg := "Failed to find a shared datastore matching zone [" + zoneD + "]"
144+
errorMsg := "Failed to find a shared datastore matching zone [" + invalidZone + "]"
140145
if !strings.Contains(err.Error(), errorMsg) {
141146
framework.ExpectNoError(err, errorMsg)
142147
}
@@ -311,6 +316,19 @@ var _ = utils.SIGDescribe("Zone Support", func() {
311316
verifyPVCAndPodCreationSucceeds(client, namespace, scParameters, zones, "")
312317
})
313318

319+
ginkgo.It("Verify a pod is created and attached to a dynamically created PV, based on the allowed zones specified in storage class when the datastore under the zone is present in another datacenter", func() {
320+
ginkgo.By(fmt.Sprintf("Creating storage class with zone :%s", zoneD))
321+
zones = append(zones, zoneD)
322+
verifyPVCAndPodCreationSucceeds(client, namespace, scParameters, zones, "")
323+
})
324+
325+
ginkgo.It("Verify a pod is created and attached to a dynamically created PV, based on the allowed zones and datastore specified in storage class when there are multiple datastores with the same name under different zones across datacenters", func() {
326+
ginkgo.By(fmt.Sprintf("Creating storage class with zone :%s and datastore name :%s", zoneD, localDatastore))
327+
scParameters[Datastore] = localDatastore
328+
zones = append(zones, zoneD)
329+
verifyPVCAndPodCreationSucceeds(client, namespace, scParameters, zones, "")
330+
})
331+
314332
ginkgo.It("Verify a pod is created and attached to a dynamically created PV with storage policy specified in storage class in waitForFirstConsumer binding mode", func() {
315333
ginkgo.By(fmt.Sprintf("Creating storage class with waitForFirstConsumer mode and storage policy :%s", compatPolicy))
316334
scParameters[SpbmStoragePolicy] = compatPolicy

0 commit comments

Comments
 (0)