Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky unit test Test_Run_Positive_VolumeMountControllerAttachEnabledRace data race #94676

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/kubelet/volumemanager/reconciler/reconciler_test.go
Expand Up @@ -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 }
Expand Down Expand Up @@ -1791,6 +1791,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
<-stoppedChan

finished := make(chan interface{})
fakePlugin.Lock()
JornShen marked this conversation as resolved.
Show resolved Hide resolved
fakePlugin.UnmountDeviceHook = func(mountPath string) error {
// Act:
// 3. While a volume is being unmounted, add it back to the desired state of world
Expand All @@ -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)
Expand Down