Skip to content

Commit c0d5d11

Browse files
authored
Merge pull request kubernetes#75583 from sandeeppsunny/zone_support
Added e2e test to verify zone support across datacenters
2 parents deec633 + 6b0748d commit c0d5d11

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

8586
var _ = utils.SIGDescribe("Zone Support", func() {
@@ -91,12 +92,14 @@ var _ = utils.SIGDescribe("Zone Support", func() {
9192
zones []string
9293
vsanDatastore1 string
9394
vsanDatastore2 string
95+
localDatastore string
9496
compatPolicy string
9597
nonCompatPolicy string
9698
zoneA string
9799
zoneB string
98100
zoneC string
99101
zoneD string
102+
invalidZone string
100103
)
101104
ginkgo.BeforeEach(func() {
102105
framework.SkipUnlessProviderIs("vsphere")
@@ -105,12 +108,14 @@ var _ = utils.SIGDescribe("Zone Support", func() {
105108
namespace = f.Namespace.Name
106109
vsanDatastore1 = GetAndExpectStringEnvVar(VCPZoneVsanDatastore1)
107110
vsanDatastore2 = GetAndExpectStringEnvVar(VCPZoneVsanDatastore2)
111+
localDatastore = GetAndExpectStringEnvVar(VCPZoneLocalDatastore)
108112
compatPolicy = GetAndExpectStringEnvVar(VCPZoneCompatPolicyName)
109113
nonCompatPolicy = GetAndExpectStringEnvVar(VCPZoneNonCompatPolicyName)
110114
zoneA = GetAndExpectStringEnvVar(VCPZoneA)
111115
zoneB = GetAndExpectStringEnvVar(VCPZoneB)
112116
zoneC = GetAndExpectStringEnvVar(VCPZoneC)
113117
zoneD = GetAndExpectStringEnvVar(VCPZoneD)
118+
invalidZone = GetAndExpectStringEnvVar(VCPInvalidZone)
114119
scParameters = make(map[string]string)
115120
zones = make([]string, 0)
116121
_, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
@@ -131,11 +136,11 @@ var _ = utils.SIGDescribe("Zone Support", func() {
131136
})
132137

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

318+
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() {
319+
ginkgo.By(fmt.Sprintf("Creating storage class with zone :%s", zoneD))
320+
zones = append(zones, zoneD)
321+
verifyPVCAndPodCreationSucceeds(client, namespace, scParameters, zones, "")
322+
})
323+
324+
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() {
325+
ginkgo.By(fmt.Sprintf("Creating storage class with zone :%s and datastore name :%s", zoneD, localDatastore))
326+
scParameters[Datastore] = localDatastore
327+
zones = append(zones, zoneD)
328+
verifyPVCAndPodCreationSucceeds(client, namespace, scParameters, zones, "")
329+
})
330+
313331
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() {
314332
ginkgo.By(fmt.Sprintf("Creating storage class with waitForFirstConsumer mode and storage policy :%s", compatPolicy))
315333
scParameters[SpbmStoragePolicy] = compatPolicy

0 commit comments

Comments
 (0)