Speed up pkg/volume/csi unit tests

This commit is contained in:
wzshiming 2021-02-04 18:55:29 +08:00 committed by Shiming Zhang
parent 2014d37e51
commit bc3d9252bc
3 changed files with 100 additions and 68 deletions

View File

@ -47,7 +47,10 @@ import (
volumetypes "k8s.io/kubernetes/pkg/volume/util/types" volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
) )
const testWatchTimeout = 10 * time.Second const (
testWatchTimeout = 10 * time.Second
testWatchFailTimeout = 2 * time.Second
)
var ( var (
bFalse = false bFalse = false
@ -121,6 +124,7 @@ func TestAttacherAttach(t *testing.T) {
spec *volume.Spec spec *volume.Spec
injectAttacherError bool injectAttacherError bool
shouldFail bool shouldFail bool
watchTimeout time.Duration
}{ }{
{ {
name: "test ok 1", name: "test ok 1",
@ -139,31 +143,34 @@ func TestAttacherAttach(t *testing.T) {
spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol02"), false), spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol02"), false),
}, },
{ {
name: "mismatch vol", name: "mismatch vol",
nodeName: "node02", nodeName: "node02",
driverName: "driver02", driverName: "driver02",
volumeName: "vol01", volumeName: "vol01",
attachID: getAttachmentName("vol02", "driver02", "node02"), attachID: getAttachmentName("vol02", "driver02", "node02"),
spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol01"), false), spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol01"), false),
shouldFail: true, shouldFail: true,
watchTimeout: testWatchFailTimeout,
}, },
{ {
name: "mismatch driver", name: "mismatch driver",
nodeName: "node02", nodeName: "node02",
driverName: "driver000", driverName: "driver000",
volumeName: "vol02", volumeName: "vol02",
attachID: getAttachmentName("vol02", "driver02", "node02"), attachID: getAttachmentName("vol02", "driver02", "node02"),
spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver01", "vol02"), false), spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver01", "vol02"), false),
shouldFail: true, shouldFail: true,
watchTimeout: testWatchFailTimeout,
}, },
{ {
name: "mismatch node", name: "mismatch node",
nodeName: "node000", nodeName: "node000",
driverName: "driver000", driverName: "driver000",
volumeName: "vol02", volumeName: "vol02",
attachID: getAttachmentName("vol02", "driver02", "node02"), attachID: getAttachmentName("vol02", "driver02", "node02"),
spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol02"), false), spec: volume.NewSpecFromPersistentVolume(makeTestPV("pv01", 10, "driver02", "vol02"), false),
shouldFail: true, shouldFail: true,
watchTimeout: testWatchFailTimeout,
}, },
{ {
name: "attacher error", name: "attacher error",
@ -207,7 +214,7 @@ func TestAttacherAttach(t *testing.T) {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
@ -251,6 +258,7 @@ func TestAttacherAttachWithInline(t *testing.T) {
spec *volume.Spec spec *volume.Spec
injectAttacherError bool injectAttacherError bool
shouldFail bool shouldFail bool
watchTimeout time.Duration
}{ }{
{ {
name: "test ok 1 with PV", name: "test ok 1 with PV",
@ -293,7 +301,7 @@ func TestAttacherAttachWithInline(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
@ -328,6 +336,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
name string name string
driver string driver string
expectVolumeAttachment bool expectVolumeAttachment bool
watchTimeout time.Duration
}{ }{
{ {
name: "CSIDriver not attachable", name: "CSIDriver not attachable",
@ -365,7 +374,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, test.watchTimeout)
spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, test.driver, "test-vol"), false) spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, test.driver, "test-vol"), false)
pluginCanAttach, err := plug.CanAttach(spec) pluginCanAttach, err := plug.CanAttach(spec)
@ -411,9 +420,10 @@ func TestAttacherWaitForVolumeAttachmentWithCSIDriver(t *testing.T) {
// we do not instantiate any VolumeAttachment. So if the plugin does not skip attach, WaitForVolumeAttachment // we do not instantiate any VolumeAttachment. So if the plugin does not skip attach, WaitForVolumeAttachment
// will return an error that volume attachment was not found. // will return an error that volume attachment was not found.
tests := []struct { tests := []struct {
name string name string
driver string driver string
expectError bool expectError bool
watchTimeout time.Duration
}{ }{
{ {
name: "CSIDriver not attachable -> success", name: "CSIDriver not attachable -> success",
@ -457,7 +467,7 @@ func TestAttacherWaitForVolumeAttachmentWithCSIDriver(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, test.watchTimeout)
spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, test.driver, "test-vol"), false) spec := volume.NewSpecFromPersistentVolume(makeTestPV("test-pv", 10, test.driver, "test-vol"), false)
pluginCanAttach, err := plug.CanAttach(spec) pluginCanAttach, err := plug.CanAttach(spec)
@ -488,6 +498,7 @@ func TestAttacherWaitForAttach(t *testing.T) {
spec *volume.Spec spec *volume.Spec
expectedAttachID string expectedAttachID string
expectError bool expectError bool
watchTimeout time.Duration
}{ }{
{ {
name: "successful attach", name: "successful attach",
@ -532,7 +543,7 @@ func TestAttacherWaitForAttach(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, test.watchTimeout)
if test.makeAttachment != nil { if test.makeAttachment != nil {
attachment := test.makeAttachment() attachment := test.makeAttachment()
@ -571,6 +582,7 @@ func TestAttacherWaitForAttachWithInline(t *testing.T) {
spec *volume.Spec spec *volume.Spec
expectedAttachID string expectedAttachID string
expectError bool expectError bool
watchTimeout time.Duration
}{ }{
{ {
name: "successful attach with PV", name: "successful attach with PV",
@ -615,7 +627,7 @@ func TestAttacherWaitForAttachWithInline(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, test.watchTimeout)
if test.makeAttachment != nil { if test.makeAttachment != nil {
attachment := test.makeAttachment() attachment := test.makeAttachment()
@ -653,6 +665,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) {
finalAttachErr *storage.VolumeError finalAttachErr *storage.VolumeError
timeout time.Duration timeout time.Duration
shouldFail bool shouldFail bool
watchTimeout time.Duration
}{ }{
{ {
name: "attach success at get", name: "attach success at get",
@ -706,7 +719,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
t.Logf("running test: %v", tc.name) t.Logf("running test: %v", tc.name)
pvName := fmt.Sprintf("test-pv-%d", i) pvName := fmt.Sprintf("test-pv-%d", i)
@ -763,10 +776,11 @@ func TestAttacherVolumesAreAttached(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
attachedSpecs []attachedSpec attachedSpecs []attachedSpec
watchTimeout time.Duration
}{ }{
{ {
"attach and detach", name: "attach and detach",
[]attachedSpec{ attachedSpecs: []attachedSpec{
{"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true}, {"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true},
{"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), true}, {"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), true},
{"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), false}, {"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), false},
@ -775,23 +789,23 @@ func TestAttacherVolumesAreAttached(t *testing.T) {
}, },
}, },
{ {
"all detached", name: "all detached",
[]attachedSpec{ attachedSpecs: []attachedSpec{
{"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), false}, {"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), false},
{"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), false}, {"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), false},
{"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), false}, {"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), false},
}, },
}, },
{ {
"all attached", name: "all attached",
[]attachedSpec{ attachedSpecs: []attachedSpec{
{"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true}, {"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true},
{"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), true}, {"vol1", volume.NewSpecFromPersistentVolume(makeTestPV("pv1", 20, testDriver, "vol1"), false), true},
}, },
}, },
{ {
"include non-attable", name: "include non-attable",
[]attachedSpec{ attachedSpecs: []attachedSpec{
{"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true}, {"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true},
{"vol1", volume.NewSpecFromVolume(makeTestVol("pv1", testDriver)), false}, {"vol1", volume.NewSpecFromVolume(makeTestVol("pv1", testDriver)), false},
}, },
@ -807,7 +821,7 @@ func TestAttacherVolumesAreAttached(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
nodeName := "fakeNode" nodeName := "fakeNode"
var specs []*volume.Spec var specs []*volume.Spec
@ -856,10 +870,11 @@ func TestAttacherVolumesAreAttachedWithInline(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
attachedSpecs []attachedSpec attachedSpecs []attachedSpec
watchTimeout time.Duration
}{ }{
{ {
"attach and detach with volume sources", name: "attach and detach with volume sources",
[]attachedSpec{ attachedSpecs: []attachedSpec{
{"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true}, {"vol0", volume.NewSpecFromPersistentVolume(makeTestPV("pv0", 10, testDriver, "vol0"), false), true},
{"vol1", volume.NewSpecFromVolume(makeTestVol("pv1", testDriver)), false}, {"vol1", volume.NewSpecFromVolume(makeTestVol("pv1", testDriver)), false},
{"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), true}, {"vol2", volume.NewSpecFromPersistentVolume(makeTestPV("pv2", 10, testDriver, "vol2"), false), true},
@ -878,7 +893,7 @@ func TestAttacherVolumesAreAttachedWithInline(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
nodeName := "fakeNode" nodeName := "fakeNode"
var specs []*volume.Spec var specs []*volume.Spec
@ -920,11 +935,12 @@ func TestAttacherVolumesAreAttachedWithInline(t *testing.T) {
func TestAttacherDetach(t *testing.T) { func TestAttacherDetach(t *testing.T) {
nodeName := "fakeNode" nodeName := "fakeNode"
testCases := []struct { testCases := []struct {
name string name string
volID string volID string
attachID string attachID string
shouldFail bool shouldFail bool
reactor func(action core.Action) (handled bool, ret runtime.Object, err error) reactor func(action core.Action) (handled bool, ret runtime.Object, err error)
watchTimeout time.Duration
}{ }{
{name: "normal test", volID: "vol-001", attachID: getAttachmentName("vol-001", testDriver, nodeName)}, {name: "normal test", volID: "vol-001", attachID: getAttachmentName("vol-001", testDriver, nodeName)},
{name: "normal test 2", volID: "vol-002", attachID: getAttachmentName("vol-002", testDriver, nodeName)}, {name: "normal test 2", volID: "vol-002", attachID: getAttachmentName("vol-002", testDriver, nodeName)},
@ -959,7 +975,7 @@ func TestAttacherDetach(t *testing.T) {
if err0 != nil { if err0 != nil {
t.Fatalf("failed to create new attacher: %v", err0) t.Fatalf("failed to create new attacher: %v", err0)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
pv := makeTestPV("test-pv", 10, testDriver, tc.volID) pv := makeTestPV("test-pv", 10, testDriver, tc.volID)
spec := volume.NewSpecFromPersistentVolume(pv, pv.Spec.PersistentVolumeSource.CSI.ReadOnly) spec := volume.NewSpecFromPersistentVolume(pv, pv.Spec.PersistentVolumeSource.CSI.ReadOnly)
@ -1004,7 +1020,7 @@ func TestAttacherGetDeviceMountPath(t *testing.T) {
if err0 != nil { if err0 != nil {
t.Fatalf("failed to create new attacher: %v", err0) t.Fatalf("failed to create new attacher: %v", err0)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, testWatchTimeout)
pluginDir := csiAttacher.plugin.host.GetPluginDir(plug.GetPluginName()) pluginDir := csiAttacher.plugin.host.GetPluginDir(plug.GetPluginName())
@ -1067,6 +1083,7 @@ func TestAttacherMountDevice(t *testing.T) {
populateDeviceMountPath bool populateDeviceMountPath bool
exitError error exitError error
spec *volume.Spec spec *volume.Spec
watchTimeout time.Duration
}{ }{
{ {
testName: "normal PV", testName: "normal PV",
@ -1187,7 +1204,7 @@ func TestAttacherMountDevice(t *testing.T) {
if err0 != nil { if err0 != nil {
t.Fatalf("failed to create new attacher: %v", err0) t.Fatalf("failed to create new attacher: %v", err0)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet) csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet)
if tc.deviceMountPath != "" { if tc.deviceMountPath != "" {
@ -1309,6 +1326,7 @@ func TestAttacherMountDeviceWithInline(t *testing.T) {
stageUnstageSet bool stageUnstageSet bool
shouldFail bool shouldFail bool
spec *volume.Spec spec *volume.Spec
watchTimeout time.Duration
}{ }{
{ {
testName: "normal PV", testName: "normal PV",
@ -1387,7 +1405,7 @@ func TestAttacherMountDeviceWithInline(t *testing.T) {
if err0 != nil { if err0 != nil {
t.Fatalf("failed to create new attacher: %v", err0) t.Fatalf("failed to create new attacher: %v", err0)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet) csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet)
if tc.deviceMountPath != "" { if tc.deviceMountPath != "" {
@ -1461,6 +1479,7 @@ func TestAttacherUnmountDevice(t *testing.T) {
createPV bool createPV bool
stageUnstageSet bool stageUnstageSet bool
shouldFail bool shouldFail bool
watchTimeout time.Duration
}{ }{
{ {
testName: "normal, json file exists", testName: "normal, json file exists",
@ -1523,7 +1542,7 @@ func TestAttacherUnmountDevice(t *testing.T) {
if err0 != nil { if err0 != nil {
t.Fatalf("failed to create new attacher: %v", err0) t.Fatalf("failed to create new attacher: %v", err0)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, tc.watchTimeout)
csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet) csiAttacher.csiClient = setupClient(t, tc.stageUnstageSet)
if tc.deviceMountPath != "" { if tc.deviceMountPath != "" {
@ -1603,26 +1622,38 @@ func TestAttacherUnmountDevice(t *testing.T) {
} }
} }
func getCsiAttacherFromVolumeAttacher(attacher volume.Attacher) *csiAttacher { func getCsiAttacherFromVolumeAttacher(attacher volume.Attacher, watchTimeout time.Duration) *csiAttacher {
if watchTimeout == 0 {
watchTimeout = testWatchTimeout
}
csiAttacher := attacher.(*csiAttacher) csiAttacher := attacher.(*csiAttacher)
csiAttacher.watchTimeout = testWatchTimeout csiAttacher.watchTimeout = watchTimeout
return csiAttacher return csiAttacher
} }
func getCsiAttacherFromVolumeDetacher(detacher volume.Detacher) *csiAttacher { func getCsiAttacherFromVolumeDetacher(detacher volume.Detacher, watchTimeout time.Duration) *csiAttacher {
if watchTimeout == 0 {
watchTimeout = testWatchTimeout
}
csiAttacher := detacher.(*csiAttacher) csiAttacher := detacher.(*csiAttacher)
csiAttacher.watchTimeout = testWatchTimeout csiAttacher.watchTimeout = watchTimeout
return csiAttacher return csiAttacher
} }
func getCsiAttacherFromDeviceMounter(deviceMounter volume.DeviceMounter) *csiAttacher { func getCsiAttacherFromDeviceMounter(deviceMounter volume.DeviceMounter, watchTimeout time.Duration) *csiAttacher {
if watchTimeout == 0 {
watchTimeout = testWatchTimeout
}
csiAttacher := deviceMounter.(*csiAttacher) csiAttacher := deviceMounter.(*csiAttacher)
csiAttacher.watchTimeout = testWatchTimeout csiAttacher.watchTimeout = watchTimeout
return csiAttacher return csiAttacher
} }
func getCsiAttacherFromDeviceUnmounter(deviceUnmounter volume.DeviceUnmounter) *csiAttacher { func getCsiAttacherFromDeviceUnmounter(deviceUnmounter volume.DeviceUnmounter, watchTimeout time.Duration) *csiAttacher {
if watchTimeout == 0 {
watchTimeout = testWatchTimeout
}
csiAttacher := deviceUnmounter.(*csiAttacher) csiAttacher := deviceUnmounter.(*csiAttacher)
csiAttacher.watchTimeout = testWatchTimeout csiAttacher.watchTimeout = watchTimeout
return csiAttacher return csiAttacher
} }

View File

@ -910,7 +910,7 @@ func TestPluginNewAttacher(t *testing.T) {
t.Fatalf("failed to create new attacher: %v", err) t.Fatalf("failed to create new attacher: %v", err)
} }
csiAttacher := getCsiAttacherFromVolumeAttacher(attacher) csiAttacher := getCsiAttacherFromVolumeAttacher(attacher, testWatchTimeout)
if csiAttacher.plugin == nil { if csiAttacher.plugin == nil {
t.Error("plugin not set for attacher") t.Error("plugin not set for attacher")
} }
@ -931,7 +931,7 @@ func TestPluginNewDetacher(t *testing.T) {
t.Fatalf("failed to create new detacher: %v", err) t.Fatalf("failed to create new detacher: %v", err)
} }
csiDetacher := getCsiAttacherFromVolumeDetacher(detacher) csiDetacher := getCsiAttacherFromVolumeDetacher(detacher, testWatchTimeout)
if csiDetacher.plugin == nil { if csiDetacher.plugin == nil {
t.Error("plugin not set for detacher") t.Error("plugin not set for detacher")
} }

View File

@ -60,6 +60,7 @@ func TestCSI_VolumeAll(t *testing.T) {
shouldFail bool shouldFail bool
disableFSGroupPolicyFeatureGate bool disableFSGroupPolicyFeatureGate bool
driverSpec *storage.CSIDriverSpec driverSpec *storage.CSIDriverSpec
watchTimeout time.Duration
}{ }{
{ {
name: "PersistentVolume", name: "PersistentVolume",
@ -396,7 +397,7 @@ func TestCSI_VolumeAll(t *testing.T) {
} }
if devMounter != nil { if devMounter != nil {
csiDevMounter := getCsiAttacherFromDeviceMounter(devMounter) csiDevMounter := getCsiAttacherFromDeviceMounter(devMounter, test.watchTimeout)
csiDevMounter.csiClient = csiClient csiDevMounter.csiClient = csiClient
devMountPath, err := csiDevMounter.GetDeviceMountPath(volSpec) devMountPath, err := csiDevMounter.GetDeviceMountPath(volSpec)
if err != nil { if err != nil {
@ -559,8 +560,8 @@ func TestCSI_VolumeAll(t *testing.T) {
} }
if devMounter != nil && devUnmounter != nil { if devMounter != nil && devUnmounter != nil {
csiDevMounter := getCsiAttacherFromDeviceMounter(devMounter) csiDevMounter := getCsiAttacherFromDeviceMounter(devMounter, test.watchTimeout)
csiDevUnmounter := getCsiAttacherFromDeviceUnmounter(devUnmounter) csiDevUnmounter := getCsiAttacherFromDeviceUnmounter(devUnmounter, test.watchTimeout)
csiDevUnmounter.csiClient = csiClient csiDevUnmounter.csiClient = csiClient
devMountPath, err := csiDevMounter.GetDeviceMountPath(volSpec) devMountPath, err := csiDevMounter.GetDeviceMountPath(volSpec)
@ -601,7 +602,7 @@ func TestCSI_VolumeAll(t *testing.T) {
if err != nil { if err != nil {
t.Fatal("csiTest.VolumeAll volumePlugin.GetVolumeName failed:", err) t.Fatal("csiTest.VolumeAll volumePlugin.GetVolumeName failed:", err)
} }
csiDetacher := getCsiAttacherFromVolumeDetacher(volDetacher) csiDetacher := getCsiAttacherFromVolumeDetacher(volDetacher, test.watchTimeout)
csiDetacher.csiClient = csiClient csiDetacher.csiClient = csiClient
if err := csiDetacher.Detach(volName, attachDetachVolumeHost.GetNodeName()); err != nil { if err := csiDetacher.Detach(volName, attachDetachVolumeHost.GetNodeName()); err != nil {
t.Fatal("csiTest.VolumeAll detacher.Detach failed:", err) t.Fatal("csiTest.VolumeAll detacher.Detach failed:", err)