From 45464f03494bf5c7efb09e44cc07e7125c748cb3 Mon Sep 17 00:00:00 2001 From: Tomas Smetana Date: Mon, 28 Jan 2019 15:05:26 +0100 Subject: [PATCH] Kubelet: Fix volumemanager test race --- .../volumemanager/reconciler/reconciler_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go index 0bdd4078d6e..8d2b82c17b3 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler_test.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler_test.go @@ -1226,8 +1226,16 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) { if err != nil { t.Fatalf("AddPodToVolume failed. Expected: Actual: <%v>", err) } - runReconciler(reconciler) + // Start the reconciler to fill ASW. + stopChan, stoppedChan := make(chan struct{}), make(chan struct{}) + go func() { + reconciler.Run(stopChan) + close(stoppedChan) + }() waitForMount(t, fakePlugin, generatedVolumeName, asw) + // Stop the reconciler. + close(stopChan) + <-stoppedChan finished := make(chan interface{}) fakePlugin.UnmountDeviceHook = func(mountPath string) error { @@ -1252,6 +1260,9 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) { return devicePath, nil } + // Start the reconciler again. + go reconciler.Run(wait.NeverStop) + // 2. Delete the volume from DSW (and wait for callbacks) dsw.DeletePodFromVolume(podName, generatedVolumeName)