Merge pull request #94676 from JornShen/fix_Test_Run_Positive_VolumeMountControllerAttachEnabledRace_data_trace

Fix flaky unit test Test_Run_Positive_VolumeMountControllerAttachEnabledRace data race
This commit is contained in:
Kubernetes Prow Robot 2020-10-27 23:31:56 -07:00 committed by GitHub
commit a9e9cabbea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,14 +48,14 @@ import (
const (
// reconcilerLoopSleepDuration is the amount of time the reconciler loop
// waits between successive executions
reconcilerLoopSleepDuration time.Duration = 1 * time.Nanosecond
reconcilerLoopSleepDuration = 1 * time.Nanosecond
// waitForAttachTimeout is the maximum amount of time a
// operationexecutor.Mount call will wait for a volume to be attached.
waitForAttachTimeout time.Duration = 1 * time.Second
nodeName k8stypes.NodeName = k8stypes.NodeName("mynodename")
kubeletPodsDir string = "fake-dir"
testOperationBackOffDuration time.Duration = 100 * time.Millisecond
reconcilerSyncWaitDuration time.Duration = 10 * time.Second
waitForAttachTimeout = 1 * time.Second
nodeName = k8stypes.NodeName("mynodename")
kubeletPodsDir = "fake-dir"
testOperationBackOffDuration = 100 * time.Millisecond
reconcilerSyncWaitDuration = 10 * time.Second
)
func hasAddedPods() bool { return true }
@ -1791,6 +1791,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
<-stoppedChan
finished := make(chan interface{})
fakePlugin.Lock()
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
// Act:
// 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)
return devicePath, nil
}
fakePlugin.Unlock()
// Start the reconciler again.
go reconciler.Run(wait.NeverStop)