e2e: validate the error return instead of object for consitency

If loadPVC() fails, it return error and we expect the PVC object
to be nil too. In many places we check on the error and exit.
However in few places we are looking at PVC object.
This commit make the condition check on `err` instead of `PVC`
object for consistency.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2020-10-20 15:25:09 +05:30 committed by mergify[bot]
parent dc4da25a30
commit b4452f0787
5 changed files with 8 additions and 8 deletions

View File

@ -335,7 +335,7 @@ var _ = Describe("cephfs", func() {
By("create PVC, delete backing subvolume and check pv deletion", func() {
pvc, err := loadPVC(pvcPath)
if pvc == nil {
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
pvc.Namespace = f.UniqueName

View File

@ -65,13 +65,13 @@ func resizePVCAndValidateSize(pvcPath, appPath string, f *framework.Framework) e
size := "1Gi"
expandSize := "10Gi"
pvc, err := loadPVC(pvcPath)
if pvc == nil {
if err != nil {
return err
}
pvc.Namespace = f.UniqueName
resizePvc, err := loadPVC(pvcPath)
if resizePvc == nil {
if err != nil {
return err
}
resizePvc.Namespace = f.UniqueName

View File

@ -142,7 +142,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
label := make(map[string]string)
pvc, err = loadPVC(pvcPath)
if pvc == nil {
if err != nil {
e2elog.Failf("failed to load pvc with error %v", err)
}
pvc.Namespace = f.UniqueName

View File

@ -160,7 +160,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
data := "check data persists"
pvc, err = loadPVC(pvcPath)
if pvc == nil {
if err != nil {
e2elog.Failf("failed to load pvc with error %v", err)
}
pvc.Namespace = f.UniqueName

View File

@ -188,7 +188,7 @@ func deletePVCAndApp(name string, f *framework.Framework, pvc *v1.PersistentVolu
func createPVCAndAppBinding(pvcPath, appPath string, f *framework.Framework, pvcTimeout int) (*v1.PersistentVolumeClaim, *v1.Pod, error) {
pvc, err := loadPVC(pvcPath)
if pvc == nil {
if err != nil {
return nil, nil, err
}
pvc.Namespace = f.UniqueName
@ -356,7 +356,7 @@ func writeDataInPod(app *v1.Pod, f *framework.Framework) error {
func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error {
data := "checking data persist"
pvc, err := loadPVC(pvcPath)
if pvc == nil {
if err != nil {
return err
}
@ -450,7 +450,7 @@ func pvcDeleteWhenPoolNotFound(pvcPath string, cephfs bool, f *framework.Framewo
func checkMountOptions(pvcPath, appPath string, f *framework.Framework, mountFlags []string) error {
pvc, err := loadPVC(pvcPath)
if pvc == nil {
if err != nil {
return err
}