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/upgrade-rbd.go.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-11-22 12:24:05 +05:30 committed by mergify[bot]
parent fc7d3fadf5
commit 9bab088ddc

View File

@ -42,7 +42,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
if cephCSINamespace != defaultNs {
err := createNamespace(c, cephCSINamespace)
if err != nil {
e2elog.Failf("failed to create namespace with error %v", err)
e2elog.Failf("failed to create namespace: %v", err)
}
}
@ -51,52 +51,52 @@ var _ = Describe("RBD Upgrade Testing", func() {
var err error
cwd, err = os.Getwd()
if err != nil {
e2elog.Failf("failed to do getwd with error %v", err)
e2elog.Failf("failed to do getwd: %v", err)
}
deployVault(f.ClientSet, deployTimeout)
err = upgradeAndDeployCSI(upgradeVersion, "rbd")
if err != nil {
e2elog.Failf("failed to upgrade and deploy CSI with error %v", err)
e2elog.Failf("failed to upgrade and deploy CSI: %v", err)
}
err = createConfigMap(rbdDirPath, f.ClientSet, f)
if err != nil {
e2elog.Failf("failed to create configmap with error %v", err)
e2elog.Failf("failed to create configmap: %v", err)
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err)
e2elog.Failf("failed to create storageclass: %v", err)
}
// create rbd provisioner secret
key, err := createCephUser(f, keyringRBDProvisionerUsername, rbdProvisionerCaps("", ""))
if err != nil {
e2elog.Failf("failed to create user %s with error %v", keyringRBDProvisionerUsername, err)
e2elog.Failf("failed to create user %s: %v", keyringRBDProvisionerUsername, err)
}
err = createRBDSecret(f, rbdProvisionerSecretName, keyringRBDProvisionerUsername, key)
if err != nil {
e2elog.Failf("failed to create provisioner secret with error %v", err)
e2elog.Failf("failed to create provisioner secret: %v", err)
}
// create rbd plugin secret
key, err = createCephUser(f, keyringRBDNodePluginUsername, rbdNodePluginCaps("", ""))
if err != nil {
e2elog.Failf("failed to create user %s with error %v", keyringRBDNodePluginUsername, err)
e2elog.Failf("failed to create user %s: %v", keyringRBDNodePluginUsername, err)
}
err = createRBDSecret(f, rbdNodePluginSecretName, keyringRBDNodePluginUsername, key)
if err != nil {
e2elog.Failf("failed to create node secret with error %v", err)
e2elog.Failf("failed to create node secret: %v", err)
}
err = createRBDSnapshotClass(f)
if err != nil {
e2elog.Failf("failed to create snapshotclass with error %v", err)
e2elog.Failf("failed to create snapshotclass: %v", err)
}
err = createNodeLabel(f, nodeRegionLabel, regionValue)
if err != nil {
e2elog.Failf("failed to create node label with error %v", err)
e2elog.Failf("failed to create node label: %v", err)
}
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
if err != nil {
e2elog.Failf("failed to create node label with error %v", err)
e2elog.Failf("failed to create node label: %v", err)
}
})
AfterEach(func() {
@ -117,27 +117,27 @@ var _ = Describe("RBD Upgrade Testing", func() {
err := deleteConfigMap(rbdDirPath)
if err != nil {
e2elog.Failf("failed to delete configmap with error %v", err)
e2elog.Failf("failed to delete configmap: %v", err)
}
err = c.CoreV1().
Secrets(cephCSINamespace).
Delete(context.TODO(), rbdProvisionerSecretName, metav1.DeleteOptions{})
if err != nil {
e2elog.Failf("failed to delete provisioner secret with error %v", err)
e2elog.Failf("failed to delete provisioner secret: %v", err)
}
err = c.CoreV1().
Secrets(cephCSINamespace).
Delete(context.TODO(), rbdNodePluginSecretName, metav1.DeleteOptions{})
if err != nil {
e2elog.Failf("failed to delete node secret with error %v", err)
e2elog.Failf("failed to delete node secret: %v", err)
}
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
e2elog.Failf("failed to delete storageclass: %v", err)
}
err = deleteResource(rbdExamplePath + "snapshotclass.yaml")
if err != nil {
e2elog.Failf("failed to delete snapshotclass with error %v", err)
e2elog.Failf("failed to delete snapshotclass: %v", err)
}
deleteVault()
if deployRBD {
@ -145,17 +145,17 @@ var _ = Describe("RBD Upgrade Testing", func() {
if cephCSINamespace != defaultNs {
err = deleteNamespace(c, cephCSINamespace)
if err != nil {
e2elog.Failf("failed to delete namespace with error %v", err)
e2elog.Failf("failed to delete namespace: %v", err)
}
}
}
err = deleteNodeLabel(c, nodeRegionLabel)
if err != nil {
e2elog.Failf("failed to delete node label with error %v", err)
e2elog.Failf("failed to delete node label: %v", err)
}
err = deleteNodeLabel(c, nodeZoneLabel)
if err != nil {
e2elog.Failf("failed to delete node label with error %v", err)
e2elog.Failf("failed to delete node label: %v", err)
}
})
@ -167,14 +167,14 @@ var _ = Describe("RBD Upgrade Testing", func() {
By("checking provisioner deployment is running", func() {
err := waitForDeploymentComplete(rbdDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("timeout waiting for deployment %s with error %v", rbdDeploymentName, err)
e2elog.Failf("timeout waiting for deployment %s: %v", rbdDeploymentName, err)
}
})
By("checking nodeplugin deamonset pods are running", func() {
err := waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("timeout waiting for daemonset %s with error %v", rbdDaemonsetName, err)
e2elog.Failf("timeout waiting for daemonset %s: %v", rbdDaemonsetName, err)
}
})
@ -186,13 +186,13 @@ var _ = Describe("RBD Upgrade Testing", func() {
pvc, err = loadPVC(pvcPath)
if err != nil {
e2elog.Failf("failed to load pvc with error %v", err)
e2elog.Failf("failed to load pvc: %v", err)
}
pvc.Namespace = f.UniqueName
app, err = loadApp(appPath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
e2elog.Failf("failed to load application: %v", err)
}
label[appKey] = appLabel
app.Namespace = f.UniqueName
@ -200,7 +200,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
pvc.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
err = createPVCAndApp("", f, pvc, app, deployTimeout)
if err != nil {
e2elog.Failf("failed to create pvc with error %v", err)
e2elog.Failf("failed to create pvc: %v", err)
}
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -231,7 +231,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
e2elog.Logf("Calculating checksum of %s", filePath)
checkSum, err = calculateSHA512sum(f, app, filePath, &opt)
if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err)
e2elog.Failf("failed to calculate checksum: %v", err)
}
// pvc clone is only supported from v1.16+
@ -249,25 +249,25 @@ var _ = Describe("RBD Upgrade Testing", func() {
}
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("failed to delete application with error %v", err)
e2elog.Failf("failed to delete application: %v", err)
}
deleteRBDPlugin()
err = os.Chdir(cwd)
if err != nil {
e2elog.Failf("failed to change directory with error %v", err)
e2elog.Failf("failed to change directory: %v", err)
}
deployRBDPlugin()
err = waitForDeploymentComplete(rbdDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("timeout waiting for upgraded deployment %s with error %v", rbdDeploymentName, err)
e2elog.Failf("timeout waiting for upgraded deployment %s: %v", rbdDeploymentName, err)
}
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("timeout waiting for upgraded daemonset %s with error %v", rbdDaemonsetName, err)
e2elog.Failf("timeout waiting for upgraded daemonset %s: %v", rbdDaemonsetName, err)
}
// validate if the app gets bound to a pvc created by
@ -275,7 +275,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
app.Labels = label
err = createApp(f.ClientSet, app, deployTimeout)
if err != nil {
e2elog.Failf("failed to create application with error %v", err)
e2elog.Failf("failed to create application: %v", err)
}
})
@ -288,14 +288,14 @@ var _ = Describe("RBD Upgrade Testing", func() {
if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load pvc with error %v", err)
e2elog.Failf("failed to load pvc: %v", err)
}
pvcClone.Namespace = f.UniqueName
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
pvcClone.Spec.DataSource.Name = "rbd-pvc-snapshot"
appClone, err := loadApp(appClonePath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
e2elog.Failf("failed to load application: %v", err)
}
label[appKey] = "validate-snap-clone"
appClone.Namespace = f.UniqueName
@ -303,7 +303,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
appClone.Labels = label
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
if err != nil {
e2elog.Failf("failed to create pvc with error %v", err)
e2elog.Failf("failed to create pvc: %v", err)
}
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -312,7 +312,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
testFilePath := filepath.Join(mountPath, "testClone")
newCheckSum, err := calculateSHA512sum(f, appClone, testFilePath, &opt)
if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err)
e2elog.Failf("failed to calculate checksum: %v", err)
}
if strings.Compare(newCheckSum, checkSum) != 0 {
e2elog.Failf(
@ -325,7 +325,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
// delete cloned pvc and pod
err = deletePVCAndApp("", f, pvcClone, appClone)
if err != nil {
e2elog.Failf("failed to delete pvc and application with error %v", err)
e2elog.Failf("failed to delete pvc and application: %v", err)
}
}
@ -340,14 +340,14 @@ var _ = Describe("RBD Upgrade Testing", func() {
if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
pvcClone, err := loadPVC(pvcSmartClonePath)
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.Namespace = f.UniqueName
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
appClone, err := loadApp(appSmartClonePath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
e2elog.Failf("failed to load application: %v", err)
}
label[appKey] = "validate-clone"
appClone.Namespace = f.UniqueName
@ -355,7 +355,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
appClone.Labels = label
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
if err != nil {
e2elog.Failf("failed to create pvc with error %v", err)
e2elog.Failf("failed to create pvc: %v", err)
}
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -364,7 +364,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
testFilePath := filepath.Join(mountPath, "testClone")
newCheckSum, err := calculateSHA512sum(f, appClone, testFilePath, &opt)
if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err)
e2elog.Failf("failed to calculate checksum: %v", err)
}
if strings.Compare(newCheckSum, checkSum) != 0 {
e2elog.Failf(
@ -377,7 +377,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
// delete cloned pvc and pod
err = deletePVCAndApp("", f, pvcClone, appClone)
if err != nil {
e2elog.Failf("failed to delete pvc and application with error %v", err)
e2elog.Failf("failed to delete pvc and application: %v", err)
}
}
@ -398,23 +398,23 @@ var _ = Describe("RBD Upgrade Testing", func() {
PersistentVolumeClaims(pvc.Namespace).
Get(context.TODO(), pvc.Name, metav1.GetOptions{})
if err != nil {
e2elog.Failf("failed to get pvc with error %v", err)
e2elog.Failf("failed to get pvc: %v", err)
}
// resize PVC
err = expandPVCSize(f.ClientSet, pvc, pvcExpandSize, deployTimeout)
if err != nil {
e2elog.Failf("failed to expand pvc with error %v", err)
e2elog.Failf("failed to expand pvc: %v", err)
}
// wait for application pod to come up after resize
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
if err != nil {
e2elog.Failf("timeout waiting for pod to be in running state with error %v", err)
e2elog.Failf("timeout waiting for pod to be in running state: %v", err)
}
// validate if resize is successful.
err = checkDirSize(app, f, &opt, pvcExpandSize)
if err != nil {
e2elog.Failf("failed to check directory size with error %v", err)
e2elog.Failf("failed to check directory size: %v", err)
}
}
})
@ -422,18 +422,18 @@ var _ = Describe("RBD Upgrade Testing", func() {
By("delete pvc and app", func() {
err := deletePVCAndApp("", f, pvc, app)
if err != nil {
e2elog.Failf("failed to delete pvc and application with error %v", err)
e2elog.Failf("failed to delete pvc and application: %v", err)
}
})
// delete RBD provisioner secret
err := deleteCephUser(f, keyringRBDProvisionerUsername)
if err != nil {
e2elog.Failf("failed to delete user %s with error %v", keyringRBDProvisionerUsername, err)
e2elog.Failf("failed to delete user %s: %v", keyringRBDProvisionerUsername, err)
}
// delete RBD plugin secret
err = deleteCephUser(f, keyringRBDNodePluginUsername)
if err != nil {
e2elog.Failf("failed to delete user %s with error %v", keyringRBDNodePluginUsername, err)
e2elog.Failf("failed to delete user %s: %v", keyringRBDNodePluginUsername, err)
}
})
})