From c9004e704d6be7e08277791537370f76c5816692 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 13 Feb 2020 16:20:24 +0100 Subject: [PATCH] e2e/storage: check result of WaitForPersistentVolumeDeleted When deleting fails, the tests should be considered as failed, too. Ignoring the error caused a wrong return code in the CSI mock driver to go unnoticed (see https://github.com/kubernetes-csi/csi-test/pull/250). The v3.1.0 release of the CSI mock driver fixes that. --- test/e2e/storage/csi_mock_volume.go | 2 +- test/e2e/storage/pv_protection.go | 6 ++++-- .../testing-manifests/storage-csi/mock/csi-mock-driver.yaml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/e2e/storage/csi_mock_volume.go b/test/e2e/storage/csi_mock_volume.go index 1ed09acd6a3..830342e1d56 100644 --- a/test/e2e/storage/csi_mock_volume.go +++ b/test/e2e/storage/csi_mock_volume.go @@ -188,7 +188,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() { claim, err := cs.CoreV1().PersistentVolumeClaims(claim.Namespace).Get(context.TODO(), claim.Name, metav1.GetOptions{}) if err == nil { cs.CoreV1().PersistentVolumeClaims(claim.Namespace).Delete(context.TODO(), claim.Name, metav1.DeleteOptions{}) - e2epv.WaitForPersistentVolumeDeleted(cs, claim.Spec.VolumeName, framework.Poll, 2*time.Minute) + errs = append(errs, e2epv.WaitForPersistentVolumeDeleted(cs, claim.Spec.VolumeName, framework.Poll, 2*time.Minute)) } } diff --git a/test/e2e/storage/pv_protection.go b/test/e2e/storage/pv_protection.go index f3826133127..c87735ec73d 100644 --- a/test/e2e/storage/pv_protection.go +++ b/test/e2e/storage/pv_protection.go @@ -100,7 +100,8 @@ var _ = utils.SIGDescribe("PV Protection", func() { ginkgo.By("Deleting the PV") err = client.CoreV1().PersistentVolumes().Delete(context.TODO(), pv.Name, *metav1.NewDeleteOptions(0)) framework.ExpectNoError(err, "Error deleting PV") - e2epv.WaitForPersistentVolumeDeleted(client, pv.Name, framework.Poll, e2epv.PVDeletingTimeout) + err = e2epv.WaitForPersistentVolumeDeleted(client, pv.Name, framework.Poll, e2epv.PVDeletingTimeout) + framework.ExpectNoError(err, "waiting for PV to be deleted") }) ginkgo.It("Verify that PV bound to a PVC is not removed immediately", func() { @@ -127,6 +128,7 @@ var _ = utils.SIGDescribe("PV Protection", func() { framework.ExpectNoError(err, "Error deleting PVC") ginkgo.By("Checking that the PV is automatically removed from the system because it's no longer bound to a PVC") - e2epv.WaitForPersistentVolumeDeleted(client, pv.Name, framework.Poll, e2epv.PVDeletingTimeout) + err = e2epv.WaitForPersistentVolumeDeleted(client, pv.Name, framework.Poll, e2epv.PVDeletingTimeout) + framework.ExpectNoError(err, "waiting for PV to be deleted") }) }) diff --git a/test/e2e/testing-manifests/storage-csi/mock/csi-mock-driver.yaml b/test/e2e/testing-manifests/storage-csi/mock/csi-mock-driver.yaml index 4d21f5bb420..3a1a87a12ed 100644 --- a/test/e2e/testing-manifests/storage-csi/mock/csi-mock-driver.yaml +++ b/test/e2e/testing-manifests/storage-csi/mock/csi-mock-driver.yaml @@ -45,7 +45,7 @@ spec: - mountPath: /registration name: registration-dir - name: mock - image: quay.io/k8scsi/mock-driver:v2.1.0 + image: quay.io/k8scsi/mock-driver:v3.1.0 args: - "--name=mock.storage.k8s.io" - "--permissive-target-path" # because of https://github.com/kubernetes/kubernetes/issues/75535