Fix flaky unit test Test_Run_Positive_VolumeMountControllerAttachEnabledRace data race
ref: https://github.com/kubernetes/kubernetes/issues/94568
This commit is contained in:
@@ -48,14 +48,14 @@ import (
|
|||||||
const (
|
const (
|
||||||
// reconcilerLoopSleepDuration is the amount of time the reconciler loop
|
// reconcilerLoopSleepDuration is the amount of time the reconciler loop
|
||||||
// waits between successive executions
|
// waits between successive executions
|
||||||
reconcilerLoopSleepDuration time.Duration = 1 * time.Nanosecond
|
reconcilerLoopSleepDuration = 1 * time.Nanosecond
|
||||||
// waitForAttachTimeout is the maximum amount of time a
|
// waitForAttachTimeout is the maximum amount of time a
|
||||||
// operationexecutor.Mount call will wait for a volume to be attached.
|
// operationexecutor.Mount call will wait for a volume to be attached.
|
||||||
waitForAttachTimeout time.Duration = 1 * time.Second
|
waitForAttachTimeout = 1 * time.Second
|
||||||
nodeName k8stypes.NodeName = k8stypes.NodeName("mynodename")
|
nodeName = k8stypes.NodeName("mynodename")
|
||||||
kubeletPodsDir string = "fake-dir"
|
kubeletPodsDir = "fake-dir"
|
||||||
testOperationBackOffDuration time.Duration = 100 * time.Millisecond
|
testOperationBackOffDuration = 100 * time.Millisecond
|
||||||
reconcilerSyncWaitDuration time.Duration = 10 * time.Second
|
reconcilerSyncWaitDuration = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func hasAddedPods() bool { return true }
|
func hasAddedPods() bool { return true }
|
||||||
@@ -1791,6 +1791,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
|
|||||||
<-stoppedChan
|
<-stoppedChan
|
||||||
|
|
||||||
finished := make(chan interface{})
|
finished := make(chan interface{})
|
||||||
|
fakePlugin.Lock()
|
||||||
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
|
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
|
||||||
// Act:
|
// Act:
|
||||||
// 3. While a volume is being unmounted, add it back to the desired state of world
|
// 3. While a volume is being unmounted, add it back to the desired state of world
|
||||||
@@ -1812,6 +1813,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
|
|||||||
close(finished)
|
close(finished)
|
||||||
return devicePath, nil
|
return devicePath, nil
|
||||||
}
|
}
|
||||||
|
fakePlugin.Unlock()
|
||||||
|
|
||||||
// Start the reconciler again.
|
// Start the reconciler again.
|
||||||
go reconciler.Run(wait.NeverStop)
|
go reconciler.Run(wait.NeverStop)
|
||||||
|
Reference in New Issue
Block a user