Skip to content

Commit 615b44f

Browse files
authored
Multiwriter Test Update (#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 6d5f693 commit 615b44f

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

test/e2e/tests/setup_e2e_test.go

+39-17
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,30 @@ 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")
4953
cloudtopHost = flag.Bool("cloudtop-host", false, "The local host is cloudtop, a kind of googler machine with special requirements to access GCP")
5054
extraDriverFlags = flag.String("extra-driver-flags", "", "Extra flags to pass to the driver")
5155
enableConfidentialCompute = flag.Bool("enable-confidential-compute", false, "Create VMs with confidential compute mode. This uses NVMe devices")
5256

53-
testContexts = []*remote.TestContext{}
54-
computeService *compute.Service
55-
computeAlphaService *computealpha.Service
56-
computeBetaService *computebeta.Service
57-
kmsClient *cloudkms.KeyManagementClient
57+
testContexts = []*remote.TestContext{}
58+
multiWriterTestContexts = []*remote.TestContext{}
59+
computeService *compute.Service
60+
computeAlphaService *computealpha.Service
61+
computeBetaService *computebeta.Service
62+
kmsClient *cloudkms.KeyManagementClient
5863
)
5964

6065
func init() {
@@ -70,7 +75,9 @@ func TestE2E(t *testing.T) {
7075
var _ = BeforeSuite(func() {
7176
var err error
7277
tcc := make(chan *remote.TestContext)
78+
mwTcc := make(chan *remote.TestContext)
7379
defer close(tcc)
80+
defer close(mwTcc)
7481

7582
zones := strings.Split(*zones, ",")
7683

@@ -101,13 +108,16 @@ var _ = BeforeSuite(func() {
101108
for _, zone := range zones {
102109
go func(curZone string) {
103110
defer GinkgoRecover()
104-
tcc <- NewTestContext(curZone)
111+
tcc <- NewTestContext(curZone, *machineType, *minCpuPlatform)
112+
mwTcc <- NewTestContext(curZone, *mwMachineType, *mwMinCpuPlatform)
105113
}(zone)
106114
}
107115

108116
for i := 0; i < len(zones); i++ {
109117
tc := <-tcc
110118
testContexts = append(testContexts, tc)
119+
mwTc := <-mwTcc
120+
multiWriterTestContexts = append(multiWriterTestContexts, mwTc)
111121
klog.Infof("Added TestContext for node %s", tc.Instance.GetName())
112122
}
113123
})
@@ -120,6 +130,13 @@ var _ = AfterSuite(func() {
120130
tc.Instance.DeleteInstance()
121131
}
122132
}
133+
for _, mwTc := range multiWriterTestContexts {
134+
err := remote.TeardownDriverAndClient(mwTc)
135+
Expect(err).To(BeNil(), "Multiwriter Teardown Driver and Client failed with error")
136+
if *deleteInstances {
137+
mwTc.Instance.DeleteInstance()
138+
}
139+
}
123140
})
124141

125142
func notEmpty(v string) bool {
@@ -133,17 +150,17 @@ func getDriverConfig() testutils.DriverConfig {
133150
}
134151
}
135152

136-
func NewTestContext(zone string) *remote.TestContext {
137-
nodeID := fmt.Sprintf("%s-%s", *vmNamePrefix, zone)
153+
func NewTestContext(zone string, machineType string, minCpuPlatform string) *remote.TestContext {
154+
nodeID := fmt.Sprintf("%s-%s-%s", *vmNamePrefix, zone, machineType)
138155
klog.Infof("Setting up node %s", nodeID)
139156

140157
instanceConfig := remote.InstanceConfig{
141158
Project: *project,
142159
Architecture: *architecture,
143-
MinCpuPlatform: *minCpuPlatform,
160+
MinCpuPlatform: minCpuPlatform,
144161
Zone: zone,
145162
Name: nodeID,
146-
MachineType: *machineType,
163+
MachineType: machineType,
147164
ServiceAccount: *serviceAccount,
148165
ImageURL: *imageURL,
149166
CloudtopHost: *cloudtopHost,
@@ -185,3 +202,8 @@ func getRandomTestContext() *remote.TestContext {
185202
rn := rand.Intn(len(testContexts))
186203
return testContexts[rn]
187204
}
205+
func getRandomMwTestContext() *remote.TestContext {
206+
Expect(multiWriterTestContexts).ToNot(BeEmpty())
207+
rn := rand.Intn(len(multiWriterTestContexts))
208+
return multiWriterTestContexts[rn]
209+
}

test/e2e/tests/single_zone_e2e_test.go

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

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

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

911-
p, _, _ := testContext.Instance.GetIdentity()
911+
p, z, _ := testContext.Instance.GetIdentity()
912912
client := testContext.Client
913-
914-
// Hardcode to us-east1-a while feature is in alpha
915-
zone := "us-east1-a"
916-
917913
// Create and Validate Disk
918-
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, zone, hdbDiskType)
914+
volName, volID := createAndValidateUniqueZonalMultiWriterDisk(client, p, z, hdbDiskType)
919915

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

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

931927
It("Should complete entire disk lifecycle with multi-writer disk", func() {
932-
testContext := getRandomTestContext()
928+
testContext := getRandomMwTestContext()
933929

934930
p, z, _ := testContext.Instance.GetIdentity()
935931
client := testContext.Client
@@ -1710,7 +1706,6 @@ func createAndValidateUniqueZonalMultiWriterDisk(client *remote.CsiClient, proje
17101706
disk := typeToDisk[diskType]
17111707

17121708
disk.params[common.ParameterAccessMode] = "READ_WRITE_MANY"
1713-
17141709
volName := testNamePrefix + string(uuid.NewUUID())
17151710
volume, err := client.CreateVolumeWithCaps(volName, disk.params, defaultMwSizeGb,
17161711
&csi.TopologyRequirement{
@@ -1738,12 +1733,9 @@ func createAndValidateUniqueZonalMultiWriterDisk(client *remote.CsiClient, proje
17381733
Expect(cloudDisk.Status).To(Equal(readyState))
17391734
Expect(cloudDisk.SizeGb).To(Equal(defaultMwSizeGb))
17401735
Expect(cloudDisk.Name).To(Equal(volName))
1736+
Expect(cloudDisk.AccessMode).To(Equal("READ_WRITE_MANY"))
17411737
disk.validate(cloudDisk)
17421738

1743-
alphaDisk, err := computeAlphaService.Disks.Get(project, zone, volName).Do()
1744-
Expect(err).To(BeNil(), "Failed to get cloud disk using alpha API")
1745-
Expect(alphaDisk.MultiWriter).To(Equal(true))
1746-
17471739
return volName, volume.VolumeId
17481740
}
17491741

0 commit comments

Comments
 (0)