Skip to content

Commit c20278a

Browse files
authored
Merge pull request #1636 from pwschuurman/add-support-nvme-tests
Add support for running tests on confidential VMs that use NVMe
2 parents 2c23b17 + ea6ef06 commit c20278a

File tree

8 files changed

+125
-115
lines changed

8 files changed

+125
-115
lines changed

test/e2e/tests/setup_e2e_test.go

+28-22
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ 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-
architecture = flag.String("arch", "amd64", "Architecture pd csi driver build on")
42-
zones = flag.String("zones", "us-east4-a,us-east4-c", "Zones to run tests in. If there are multiple zones, separate each by comma")
43-
machineType = flag.String("machine-type", "n2-standard-2", "Type of machine to provision instance on")
44-
imageURL = flag.String("image-url", "projects/debian-cloud/global/images/family/debian-11", "OS image url to get image from")
45-
runInProw = flag.Bool("run-in-prow", false, "If true, use a Boskos loaned project and special CI service accounts and ssh keys")
46-
deleteInstances = flag.Bool("delete-instances", false, "Delete the instances after tests run")
47-
cloudtopHost = flag.Bool("cloudtop-host", false, "The local host is cloudtop, a kind of googler machine with special requirements to access GCP")
48-
extraDriverFlags = flag.String("extra-driver-flags", "", "Extra flags to pass to the driver")
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")
46+
imageURL = flag.String("image-url", "projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-2310-amd64", "OS image url to get image from")
47+
runInProw = flag.Bool("run-in-prow", false, "If true, use a Boskos loaned project and special CI service accounts and ssh keys")
48+
deleteInstances = flag.Bool("delete-instances", false, "Delete the instances after tests run")
49+
cloudtopHost = flag.Bool("cloudtop-host", false, "The local host is cloudtop, a kind of googler machine with special requirements to access GCP")
50+
extraDriverFlags = flag.String("extra-driver-flags", "", "Extra flags to pass to the driver")
51+
enableConfidentialCompute = flag.Bool("enable-confidential-compute", false, "Create VMs with confidential compute mode. This uses NVMe devices")
4952

5053
testContexts = []*remote.TestContext{}
5154
computeService *compute.Service
@@ -130,21 +133,24 @@ func getDriverConfig() testutils.DriverConfig {
130133
}
131134
}
132135

133-
func getRemoteInstanceConfig() *remote.InstanceConfig {
134-
return &remote.InstanceConfig{
135-
Project: *project,
136-
Architecture: *architecture,
137-
MachineType: *machineType,
138-
ServiceAccount: *serviceAccount,
139-
ImageURL: *imageURL,
140-
CloudtopHost: *cloudtopHost}
141-
}
142-
143136
func NewTestContext(zone string) *remote.TestContext {
144-
nodeID := fmt.Sprintf("gce-pd-csi-e2e-%s", zone)
137+
nodeID := fmt.Sprintf("%s-%s", *vmNamePrefix, zone)
145138
klog.Infof("Setting up node %s", nodeID)
146139

147-
i, err := remote.SetupInstance(getRemoteInstanceConfig(), zone, nodeID, computeService)
140+
instanceConfig := remote.InstanceConfig{
141+
Project: *project,
142+
Architecture: *architecture,
143+
MinCpuPlatform: *minCpuPlatform,
144+
Zone: zone,
145+
Name: nodeID,
146+
MachineType: *machineType,
147+
ServiceAccount: *serviceAccount,
148+
ImageURL: *imageURL,
149+
CloudtopHost: *cloudtopHost,
150+
EnableConfidentialCompute: *enableConfidentialCompute,
151+
ComputeService: computeService,
152+
}
153+
i, err := remote.SetupInstance(instanceConfig)
148154
if err != nil {
149155
klog.Fatalf("Failed to setup instance %v: %v", nodeID, err)
150156
}

test/e2e/tests/single_zone_e2e_test.go

+6-14
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
7676
Expect(volumeLimit).To(Equal(defaultVolumeLimit))
7777
})
7878

79-
It("Should create->attach->stage->mount volume and check if it is writable, then unmount->unstage->detach->delete and check disk is deleted", func() {
79+
It("[NVMe] Should create->attach->stage->mount volume and check if it is writable, then unmount->unstage->detach->delete and check disk is deleted", func() {
8080
testContext := getRandomTestContext()
8181

8282
p, z, _ := testContext.Instance.GetIdentity()
@@ -173,7 +173,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
173173
}()
174174
})
175175

176-
It("Should automatically add a symlink between /dev/* and /dev/by-id if disk is not found", func() {
176+
It("[NVMe] Should automatically add a symlink between /dev/* and /dev/by-id if disk is not found", func() {
177177
testContext := getRandomTestContext()
178178

179179
p, z, _ := testContext.Instance.GetIdentity()
@@ -331,7 +331,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
331331
Entry("on pd-ssd", ssdDiskType),
332332
)
333333

334-
DescribeTable("Should complete publish/unpublish lifecycle with underspecified volume ID and missing volume",
334+
DescribeTable("[NVMe] Should complete publish/unpublish lifecycle with underspecified volume ID and missing volume",
335335
func(diskType string) {
336336
testContext := getRandomTestContext()
337337

@@ -1317,15 +1317,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
13171317
_, err := getRandomTestContext().Client.ListVolumes()
13181318
Expect(err).To(BeNil(), "no error expected when passed valid compute url")
13191319

1320-
zone := "us-central1-c"
1321-
nodeID := fmt.Sprintf("gce-pd-csi-e2e-%s", zone)
1322-
i, err := remote.SetupInstance(getRemoteInstanceConfig(), zone, nodeID, computeService)
1323-
1324-
if err != nil {
1325-
klog.Fatalf("Failed to setup instance %v: %v", nodeID, err)
1326-
}
1327-
1328-
klog.Infof("Creating new driver and client for node %s\n", i.GetName())
1320+
i := getRandomTestContext().Instance
13291321

13301322
// Create new driver and client with valid, empty endpoint
13311323
klog.Infof("Setup driver with empty compute endpoint %s\n", i.GetName())
@@ -1349,7 +1341,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
13491341
Expect(err).To(BeNil(), "no error expected when passed valid compute url")
13501342
})
13511343

1352-
It("Should update readahead if read_ahead_kb passed on mount", func() {
1344+
It("[NVMe] Should update readahead if read_ahead_kb passed on mount", func() {
13531345
testContext := getRandomTestContext()
13541346

13551347
p, z, _ := testContext.Instance.GetIdentity()
@@ -1410,7 +1402,7 @@ var _ = Describe("GCE PD CSI Driver", func() {
14101402
Expect(err).To(BeNil(), "Failed to symlink devicePath")
14111403
devFsPathPieces := strings.Split(devFsPath, "/")
14121404
devName = devFsPathPieces[len(devFsPathPieces)-1]
1413-
1405+
break
14141406
}
14151407
}
14161408
Expect(validated).To(BeTrue(), "could not find device in %v that links to volume %s", devicePaths, volName)

test/e2e/utils/utils.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,13 @@ func ValidateLogicalLinkIsDisk(instance *remote.InstanceInfo, link, diskName str
293293

294294
devFsPath, err := instance.SSH("find", link, "-printf", "'%l'")
295295
if err != nil {
296-
return false, fmt.Errorf("failed to find symbolic link for %s. Output: %v, errror: %v", link, devFsPath, err.Error())
296+
// Skip over if there is no matching symlink.
297+
return false, nil
297298
}
298299
if len(devFsPath) == 0 {
299300
return false, nil
300301
}
302+
301303
if sdx := sdRegex.FindString(devFsPath); len(sdx) != 0 {
302304
fullDevPath := path.Join("/dev/", string(sdx))
303305
scsiIDOut, err := instance.SSH("/lib/udev_containerized/scsi_id", "--page=0x83", "--whitelisted", fmt.Sprintf("--device=%v", fullDevPath))

0 commit comments

Comments
 (0)