Skip to content

Commit 7890527

Browse files
sjswerdlowtonyzhc
authored andcommitted
Multiwriter Test Update (kubernetes-sigs#3)
* Changes update the tests to use two contexts, one for multiwriter and one for the existing tests. This was deemed necessary as only some disks can support multi-writer, and only some VM shapes can support said disks.
1 parent d9f760e commit 7890527

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

test/e2e/tests/setup_e2e_test.go

+25-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ import (
3636
)
3737

3838
var (
39-
project = flag.String("project", "", "Project to run tests in")
40-
serviceAccount = flag.String("service-account", "", "Service account to bring up instance with")
41-
vmNamePrefix = flag.String("vm-name-prefix", "gce-pd-csi-e2e", "VM name prefix")
42-
architecture = flag.String("arch", "amd64", "Architecture pd csi driver build on")
43-
minCpuPlatform = flag.String("min-cpu-platform", "AMD Milan", "Minimum CPU architecture")
44-
zones = flag.String("zones", "us-east4-a,us-east4-c", "Zones to run tests in. If there are multiple zones, separate each by comma")
45-
machineType = flag.String("machine-type", "n2d-standard-2", "Type of machine to provision instance on")
39+
project = flag.String("project", "", "Project to run tests in")
40+
serviceAccount = flag.String("service-account", "", "Service account to bring up instance with")
41+
vmNamePrefix = flag.String("vm-name-prefix", "gce-pd-csi-e2e", "VM name prefix")
42+
architecture = flag.String("arch", "amd64", "Architecture pd csi driver build on")
43+
minCpuPlatform = flag.String("min-cpu-platform", "rome", "Minimum CPU architecture")
44+
mwMinCpuPlatform = flag.String("min-cpu-platform-mw", "sapphirerapids", "Minimum CPU architecture for multiwriter tests")
45+
zones = flag.String("zones", "us-east4-a,us-east4-c", "Zones to run tests in. If there are multiple zones, separate each by comma")
46+
machineType = flag.String("machine-type", "n2d-standard-4", "Type of machine to provision instance on")
47+
// Multi-writer is only supported on M3, C3, and N4
48+
// https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms#hd-multi-writer
49+
mwMachineType = flag.String("mw-machine-type", "c3-standard-4", "Type of machine to provision instance for multiwriter tests")
4650
imageURL = flag.String("image-url", "projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-2404-lts-amd64", "OS image url to get image from")
4751
runInProw = flag.Bool("run-in-prow", false, "If true, use a Boskos loaned project and special CI service accounts and ssh keys")
4852
deleteInstances = flag.Bool("delete-instances", false, "Delete the instances after tests run")
@@ -117,6 +121,8 @@ var _ = BeforeSuite(func() {
117121
for i := 0; i < len(zones); i++ {
118122
tc := <-tcc
119123
testContexts = append(testContexts, tc)
124+
mwTc := <-mwTcc
125+
multiWriterTestContexts = append(multiWriterTestContexts, mwTc)
120126
klog.Infof("Added TestContext for node %s", tc.Instance.GetName())
121127
tc = <-hdtcc
122128
hyperdiskTestContexts = append(hyperdiskTestContexts, tc)
@@ -132,6 +138,13 @@ var _ = AfterSuite(func() {
132138
tc.Instance.DeleteInstance()
133139
}
134140
}
141+
for _, mwTc := range multiWriterTestContexts {
142+
err := remote.TeardownDriverAndClient(mwTc)
143+
Expect(err).To(BeNil(), "Multiwriter Teardown Driver and Client failed with error")
144+
if *deleteInstances {
145+
mwTc.Instance.DeleteInstance()
146+
}
147+
}
135148
})
136149

137150
func notEmpty(v string) bool {
@@ -201,3 +214,8 @@ func getRandomTestContext() *remote.TestContext {
201214
rn := rand.Intn(len(testContexts))
202215
return testContexts[rn]
203216
}
217+
func getRandomMwTestContext() *remote.TestContext {
218+
Expect(multiWriterTestContexts).ToNot(BeEmpty())
219+
rn := rand.Intn(len(multiWriterTestContexts))
220+
return multiWriterTestContexts[rn]
221+
}

test/e2e/tests/single_zone_e2e_test.go

+7-15
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ const (
8080
)
8181

8282
var _ = Describe("GCE PD CSI Driver", func() {
83-
8483
It("Should get reasonable volume limits from nodes with NodeGetInfo", func() {
8584
testContext := getRandomTestContext()
8685
resp, err := testContext.Client.NodeGetInfo()
@@ -284,6 +283,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
284283
Expect(err).To(BeNil(), "Could not find disk in correct zone")
285284
}
286285
})
286+
287287
// TODO(hime): Enable this test once all release branches contain the fix from PR#1708.
288288
// It("Should return InvalidArgument when disk size exceeds limit", func() {
289289
// // If this returns a different error code (like Unknown), the error wrapping logic in #1708 has regressed.
@@ -907,30 +907,26 @@ var _ = Describe("GCE PD CSI Driver", func() {
907907

908908
It("Should create and delete multi-writer disk", func() {
909909
Expect(testContexts).ToNot(BeEmpty())
910-
testContext := getRandomTestContext()
910+
testContext := getRandomMwTestContext()
911911

912-
p, _, _ := testContext.Instance.GetIdentity()
912+
p, z, _ := testContext.Instance.GetIdentity()
913913
client := testContext.Client
914-
915-
// Hardcode to us-east1-a while feature is in alpha
916-
zone := "us-east1-a"
917-
918914
// Create and Validate Disk
919-
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, zone, hdbDiskType)
915+
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, z, hdbDiskType)
920916

921917
defer func() {
922918
// Delete Disk
923919
err := client.DeleteVolume(volID)
924920
Expect(err).To(BeNil(), "DeleteVolume failed")
925921

926922
// Validate Disk Deleted
927-
_, err = computeAlphaService.Disks.Get(p, zone, volName).Do()
923+
_, err = computeService.Disks.Get(p, z, volName).Do()
928924
Expect(gce.IsGCEError(err, "notFound")).To(BeTrue(), "Expected disk to not be found")
929925
}()
930926
})
931927

932928
It("Should complete entire disk lifecycle with multi-writer disk", func() {
933-
testContext := getRandomTestContext()
929+
testContext := getRandomMwTestContext()
934930

935931
p, z, _ := testContext.Instance.GetIdentity()
936932
client := testContext.Client
@@ -1787,7 +1783,6 @@ func createAndValidateUniqueZonalMultiWriterDisk(client *remote.CsiClient, proje
17871783
disk := typeToDisk[diskType]
17881784

17891785
disk.params[common.ParameterAccessMode] = "READ_WRITE_MANY"
1790-
17911786
volName := testNamePrefix + string(uuid.NewUUID())
17921787
volume, err := client.CreateVolumeWithCaps(volName, disk.params, defaultMwSizeGb,
17931788
&csi.TopologyRequirement{
@@ -1815,12 +1810,9 @@ func createAndValidateUniqueZonalMultiWriterDisk(client *remote.CsiClient, proje
18151810
Expect(cloudDisk.Status).To(Equal(readyState))
18161811
Expect(cloudDisk.SizeGb).To(Equal(defaultMwSizeGb))
18171812
Expect(cloudDisk.Name).To(Equal(volName))
1813+
Expect(cloudDisk.AccessMode).To(Equal("READ_WRITE_MANY"))
18181814
disk.validate(cloudDisk)
18191815

1820-
alphaDisk, err := computeAlphaService.Disks.Get(project, zone, volName).Do()
1821-
Expect(err).To(BeNil(), "Failed to get cloud disk using alpha API")
1822-
Expect(alphaDisk.MultiWriter).To(Equal(true))
1823-
18241816
return volName, volume.VolumeId
18251817
}
18261818

0 commit comments

Comments
 (0)