From 2550051f3b00d3236d34c06744aeab0e84d3c690 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 2 Apr 2020 15:30:01 +0200 Subject: [PATCH] mock tests: add timeout The for loop that waited for the signal to delete pod had no timeout, so if something went wrong, it would wait for the entire test suite to time out. --- test/e2e/storage/csi_mock_volume.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/storage/csi_mock_volume.go b/test/e2e/storage/csi_mock_volume.go index bd90d65e79e..22f29beed37 100644 --- a/test/e2e/storage/csi_mock_volume.go +++ b/test/e2e/storage/csi_mock_volume.go @@ -57,6 +57,9 @@ const ( // how long to wait for Resizing Condition on PVC to appear csiResizingConditionWait = 2 * time.Minute + // Time for starting a pod with a volume. + csiPodRunningTimeout = 5 * time.Minute + // How log to wait for kubelet to unstage a volume after a pod is deleted csiUnstageWaitTimeout = 1 * time.Minute @@ -690,7 +693,12 @@ var _ = utils.SIGDescribe("CSI mock volume", func() { ginkgo.By("Waiting for expected CSI calls") // Watch for all calls up to deletePod = true + ctx, cancel := context.WithTimeout(context.Background(), csiPodRunningTimeout) + defer cancel() for { + if ctx.Err() != nil { + framework.Failf("timed out waiting for the CSI call that indicates that the pod can be deleted: %v", test.expectedCalls) + } time.Sleep(1 * time.Second) _, index, err := compareCSICalls(trackedCalls, test.expectedCalls, m.cs, f.Namespace.Name, driverPodName, driverContainerName) framework.ExpectNoError(err, "while waiting for initial CSI calls")