Skip to content

Commit 964b59f

Browse files
committed
update test setup to avoid running Datacache setup on machines not supporting LSSDs
1 parent 1566da5 commit 964b59f

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

pkg/gce-pd-csi-driver/cache.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import (
1616
)
1717

1818
const (
19-
cacheSuffix = "csi-fast"
20-
mainLvSuffix = "csi-main"
21-
raidedLocalSsdName = "csi-driver-data-cache"
22-
raidMode = "0"
23-
initialRaidedLocalSsdPath = "/dev/md0"
19+
cacheSuffix = "csi-fast"
20+
mainLvSuffix = "csi-main"
21+
raidedLocalSsdName = "csi-driver-data-cache"
22+
raidMode = "0"
2423
)
2524

2625
func fetchRAIDedLocalSsdPath() (string, error) {
@@ -253,9 +252,13 @@ func GetDataCacheCountFromNodeLabel(ctx context.Context, nodeName string) (int,
253252
}
254253

255254
func FetchRaidedLssdCountForDatacache() (int, error) {
255+
raidedPath, err := fetchRAIDedLocalSsdPath()
256+
if err != nil {
257+
return 0, err
258+
}
256259
args := []string{
257260
"--detail",
258-
initialRaidedLocalSsdPath,
261+
raidedPath,
259262
}
260263
info, err := common.RunCommand("grep", []string{"Raid Devices"}, "mdadm", args...)
261264
if err != nil {
@@ -358,6 +361,7 @@ func cleanupCache(volumeId string, nodeId string) error {
358361
// If volume group doesn't exist then there's nothing to uncache
359362
return nil
360363
}
364+
reduceVolumeGroup(volumeGroupName, true)
361365
mainLvName := getLvName(mainLvSuffix, volumeId)
362366
args := []string{
363367
"-an",
@@ -431,7 +435,7 @@ func reduceVolumeGroup(volumeGroupName string, force bool) {
431435
func RaidLocalSsds(availableLssds []string) error {
432436
args := []string{
433437
"--create",
434-
initialRaidedLocalSsdPath,
438+
raidedLocalSsdName,
435439
"--name",
436440
raidedLocalSsdName,
437441
"-l" + raidMode,

test/e2e/utils/utils.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo, driverConfig DriverC
7171
"--allow-hdha-provisioning",
7272
"--device-in-use-timeout=10s", // Set lower than the usual value to expedite tests
7373
fmt.Sprintf("--fallback-requisite-zones=%s", strings.Join(driverConfig.Zones, ",")),
74-
"--enable-data-cache",
75-
fmt.Sprintf("--node-name=%s", utilcommon.TestNode),
74+
}
75+
76+
if instance.GetLocalSSD() > 0 {
77+
extra_flags = append(extra_flags, "--enable-data-cache")
78+
extra_flags = append(extra_flags, fmt.Sprintf("--node-name=%s", utilcommon.TestNode))
7679
}
7780
extra_flags = append(extra_flags, fmt.Sprintf("--compute-endpoint=%s", driverConfig.ComputeEndpoint))
7881
extra_flags = append(extra_flags, driverConfig.ExtraFlags...)

test/remote/instance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func (i *InstanceInfo) GetNodeID() string {
8080
return common.CreateNodeID(i.cfg.Project, i.cfg.Zone, i.cfg.Name)
8181
}
8282

83+
func (i *InstanceInfo) GetLocalSSD() int64 {
84+
return i.cfg.LocalSSDCount
85+
}
86+
8387
func machineTypeMismatch(curInst *compute.Instance, newInst *compute.Instance) bool {
8488
if !strings.Contains(curInst.MachineType, newInst.MachineType) {
8589
klog.Infof("Machine type mismatch")

0 commit comments

Comments
 (0)