e2e: reformat error message with consistent formatting

To make the error return consistent across e2e tests we have decided
to remove with error presence from the logs and this commit
does that for e2e/utils.go.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-11-22 12:18:18 +05:30 committed by mergify[bot]
parent 5647d4da24
commit 14389c7b40

View File

@ -526,21 +526,21 @@ func writeDataAndCalChecksum(app *v1.Pod, opt *metav1.ListOptions, f *framework.
// write data in PVC // write data in PVC
err := writeDataInPod(app, opt, f) err := writeDataInPod(app, opt, f)
if err != nil { if err != nil {
e2elog.Logf("failed to write data in the pod with error %v", err) e2elog.Logf("failed to write data in the pod: %v", err)
return "", err return "", err
} }
checkSum, err := calculateSHA512sum(f, app, filePath, opt) checkSum, err := calculateSHA512sum(f, app, filePath, opt)
if err != nil { if err != nil {
e2elog.Logf("failed to calculate checksum with error %v", err) e2elog.Logf("failed to calculate checksum: %v", err)
return checkSum, err return checkSum, err
} }
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout) err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to delete pod with error %v", err) e2elog.Failf("failed to delete pod: %v", err)
} }
return checkSum, nil return checkSum, nil
@ -558,18 +558,18 @@ func validatePVCClone(
chErrs := make([]error, totalCount) chErrs := make([]error, totalCount)
pvc, err := loadPVC(sourcePvcPath) pvc, err := loadPVC(sourcePvcPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load PVC with error %v", err) e2elog.Failf("failed to load PVC: %v", err)
} }
label := make(map[string]string) label := make(map[string]string)
pvc.Namespace = f.UniqueName pvc.Namespace = f.UniqueName
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create PVC with error %v", err) e2elog.Failf("failed to create PVC: %v", err)
} }
app, err := loadApp(sourceAppPath) app, err := loadApp(sourceAppPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load app with error %v", err) e2elog.Failf("failed to load app: %v", err)
} }
label[appKey] = appLabel label[appKey] = appLabel
app.Namespace = f.UniqueName app.Namespace = f.UniqueName
@ -589,20 +589,20 @@ func validatePVCClone(
if *pvc.Spec.VolumeMode == v1.PersistentVolumeFilesystem { if *pvc.Spec.VolumeMode == v1.PersistentVolumeFilesystem {
checkSum, err = writeDataAndCalChecksum(app, &opt, f) checkSum, err = writeDataAndCalChecksum(app, &opt, f)
if err != nil { if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err) e2elog.Failf("failed to calculate checksum: %v", err)
} }
} }
// validate created backend rbd images // validate created backend rbd images
validateRBDImageCount(f, 1, defaultRBDPool) validateRBDImageCount(f, 1, defaultRBDPool)
pvcClone, err := loadPVC(clonePvcPath) pvcClone, err := loadPVC(clonePvcPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load PVC with error %v", err) e2elog.Failf("failed to load PVC: %v", err)
} }
pvcClone.Spec.DataSource.Name = pvc.Name pvcClone.Spec.DataSource.Name = pvc.Name
pvcClone.Namespace = f.UniqueName pvcClone.Namespace = f.UniqueName
appClone, err := loadApp(clonePvcAppPath) appClone, err := loadApp(clonePvcAppPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load application with error %v", err) e2elog.Failf("failed to load application: %v", err)
} }
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
wg.Add(totalCount) wg.Add(totalCount)
@ -690,7 +690,7 @@ func validatePVCClone(
// delete parent pvc // delete parent pvc
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to delete PVC with error %v", err) e2elog.Failf("failed to delete PVC: %v", err)
} }
totalCloneCount = totalCount + totalCount totalCloneCount = totalCount + totalCount
@ -765,7 +765,7 @@ func validatePVCSnapshot(
chErrs := make([]error, totalCount) chErrs := make([]error, totalCount)
err := createRBDSnapshotClass(f) err := createRBDSnapshotClass(f)
if err != nil { if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err) e2elog.Failf("failed to create storageclass: %v", err)
} }
defer func() { defer func() {
err = deleteRBDSnapshotClass() err = deleteRBDSnapshotClass()
@ -776,17 +776,17 @@ func validatePVCSnapshot(
pvc, err := loadPVC(pvcPath) pvc, err := loadPVC(pvcPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load PVC with error %v", err) e2elog.Failf("failed to load PVC: %v", err)
} }
label := make(map[string]string) label := make(map[string]string)
pvc.Namespace = f.UniqueName pvc.Namespace = f.UniqueName
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create PVC with error %v", err) e2elog.Failf("failed to create PVC: %v", err)
} }
app, err := loadApp(appPath) app, err := loadApp(appPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load app with error %v", err) e2elog.Failf("failed to load app: %v", err)
} }
// write data in PVC // write data in PVC
label[appKey] = appLabel label[appKey] = appLabel
@ -798,7 +798,7 @@ func validatePVCSnapshot(
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
checkSum, err := writeDataAndCalChecksum(app, &opt, f) checkSum, err := writeDataAndCalChecksum(app, &opt, f)
if err != nil { if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err) e2elog.Failf("failed to calculate checksum: %v", err)
} }
validateRBDImageCount(f, 1, defaultRBDPool) validateRBDImageCount(f, 1, defaultRBDPool)
snap := getSnapshot(snapshotPath) snap := getSnapshot(snapshotPath)
@ -816,7 +816,7 @@ func validatePVCSnapshot(
content, sErr := getVolumeSnapshotContent(s.Namespace, s.Name) content, sErr := getVolumeSnapshotContent(s.Namespace, s.Name)
if sErr != nil { if sErr != nil {
wgErrs[n] = fmt.Errorf( wgErrs[n] = fmt.Errorf(
"failed to get snapshotcontent for %s in namespace %s with error: %w", "failed to get snapshotcontent for %s in namespace %s: %w",
s.Name, s.Name,
s.Namespace, s.Namespace,
sErr) sErr)
@ -850,11 +850,11 @@ func validatePVCSnapshot(
validateRBDImageCount(f, totalCount+1, defaultRBDPool) validateRBDImageCount(f, totalCount+1, defaultRBDPool)
pvcClone, err := loadPVC(pvcClonePath) pvcClone, err := loadPVC(pvcClonePath)
if err != nil { if err != nil {
e2elog.Failf("failed to load PVC with error %v", err) e2elog.Failf("failed to load PVC: %v", err)
} }
appClone, err := loadApp(appClonePath) appClone, err := loadApp(appClonePath)
if err != nil { if err != nil {
e2elog.Failf("failed to load application with error %v", err) e2elog.Failf("failed to load application: %v", err)
} }
pvcClone.Namespace = f.UniqueName pvcClone.Namespace = f.UniqueName
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
@ -902,7 +902,7 @@ func validatePVCSnapshot(
checkSumClone, chErrs[n] = calculateSHA512sum(f, &a, filePath, &opt) checkSumClone, chErrs[n] = calculateSHA512sum(f, &a, filePath, &opt)
e2elog.Logf("checksum value for the clone is %s with pod name %s", checkSumClone, name) e2elog.Logf("checksum value for the clone is %s with pod name %s", checkSumClone, name)
if chErrs[n] != nil { if chErrs[n] != nil {
e2elog.Logf("failed to calculte checksum for clone with error %s", chErrs[n]) e2elog.Logf("failed to calculte checksum for clone: %s", chErrs[n])
} }
if checkSumClone != checkSum { if checkSumClone != checkSum {
e2elog.Logf( e2elog.Logf(
@ -998,7 +998,7 @@ func validatePVCSnapshot(
// delete parent pvc // delete parent pvc
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to delete PVC with error %v", err) e2elog.Failf("failed to delete PVC: %v", err)
} }
// total images in cluster is total snaps+ total clones // total images in cluster is total snaps+ total clones
@ -1016,7 +1016,7 @@ func validatePVCSnapshot(
content, err = getVolumeSnapshotContent(s.Namespace, s.Name) content, err = getVolumeSnapshotContent(s.Namespace, s.Name)
if err != nil { if err != nil {
wgErrs[n] = fmt.Errorf( wgErrs[n] = fmt.Errorf(
"failed to get snapshotcontent for %s in namespace %s with error: %w", "failed to get snapshotcontent for %s in namespace %s: %w",
s.Name, s.Name,
s.Namespace, s.Namespace,
err) err)
@ -1221,7 +1221,7 @@ func validateController(
func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool { func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool {
v, err := c.Discovery().ServerVersion() v, err := c.Discovery().ServerVersion()
if err != nil { if err != nil {
e2elog.Failf("failed to get server version with error %v", err) e2elog.Failf("failed to get server version: %v", err)
// Failf() marks the case as failure, and returns from the // Failf() marks the case as failure, and returns from the
// Go-routine that runs the case. This function will not have a // Go-routine that runs the case. This function will not have a
// return value. // return value.