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-cephfs.go.

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

View File

@ -46,7 +46,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
if cephCSINamespace != defaultNs { if cephCSINamespace != defaultNs {
err = createNamespace(c, cephCSINamespace) err = createNamespace(c, cephCSINamespace)
if err != nil { if err != nil {
e2elog.Failf("failed to create namespace with error %v", err) e2elog.Failf("failed to create namespace: %v", err)
} }
} }
@ -54,43 +54,43 @@ var _ = Describe("CephFS Upgrade Testing", func() {
// when we are done upgrading. // when we are done upgrading.
cwd, err = os.Getwd() cwd, err = os.Getwd()
if err != nil { if err != nil {
e2elog.Failf("failed to getwd with error %v", err) e2elog.Failf("failed to getwd: %v", err)
} }
err = upgradeAndDeployCSI(upgradeVersion, "cephfs") err = upgradeAndDeployCSI(upgradeVersion, "cephfs")
if err != nil { if err != nil {
e2elog.Failf("failed to upgrade csi with error %v", err) e2elog.Failf("failed to upgrade csi: %v", err)
} }
err = createConfigMap(cephFSDirPath, f.ClientSet, f) err = createConfigMap(cephFSDirPath, f.ClientSet, f)
if err != nil { if err != nil {
e2elog.Failf("failed to create configmap with error %v", err) e2elog.Failf("failed to create configmap: %v", err)
} }
var key string var key string
// create cephFS provisioner secret // create cephFS provisioner secret
key, err = createCephUser(f, keyringCephFSProvisionerUsername, cephFSProvisionerCaps()) key, err = createCephUser(f, keyringCephFSProvisionerUsername, cephFSProvisionerCaps())
if err != nil { if err != nil {
e2elog.Failf("failed to create user %s with error %v", keyringCephFSProvisionerUsername, err) e2elog.Failf("failed to create user %s: %v", keyringCephFSProvisionerUsername, err)
} }
err = createCephfsSecret(f, cephFSProvisionerSecretName, keyringCephFSProvisionerUsername, key) err = createCephfsSecret(f, cephFSProvisionerSecretName, keyringCephFSProvisionerUsername, key)
if err != nil { if err != nil {
e2elog.Failf("failed to create provisioner secret with error %v", err) e2elog.Failf("failed to create provisioner secret: %v", err)
} }
// create cephFS plugin secret // create cephFS plugin secret
key, err = createCephUser(f, keyringCephFSNodePluginUsername, cephFSNodePluginCaps()) key, err = createCephUser(f, keyringCephFSNodePluginUsername, cephFSNodePluginCaps())
if err != nil { if err != nil {
e2elog.Failf("failed to create user %s with error %v", keyringCephFSNodePluginUsername, err) e2elog.Failf("failed to create user %s: %v", keyringCephFSNodePluginUsername, err)
} }
err = createCephfsSecret(f, cephFSNodePluginSecretName, keyringCephFSNodePluginUsername, key) err = createCephfsSecret(f, cephFSNodePluginSecretName, keyringCephFSNodePluginUsername, key)
if err != nil { if err != nil {
e2elog.Failf("failed to create node secret with error %v", err) e2elog.Failf("failed to create node secret: %v", err)
} }
err = createCephFSSnapshotClass(f) err = createCephFSSnapshotClass(f)
if err != nil { if err != nil {
e2elog.Failf("failed to create snapshotclass with error %v", err) e2elog.Failf("failed to create snapshotclass: %v", err)
} }
err = createCephfsStorageClass(f.ClientSet, f, true, nil) err = createCephfsStorageClass(f.ClientSet, f, true, nil)
if err != nil { if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err) e2elog.Failf("failed to create storageclass: %v", err)
} }
}) })
AfterEach(func() { AfterEach(func() {
@ -110,27 +110,27 @@ var _ = Describe("CephFS Upgrade Testing", func() {
} }
err = deleteConfigMap(cephFSDirPath) err = deleteConfigMap(cephFSDirPath)
if err != nil { if err != nil {
e2elog.Failf("failed to delete configmap with error %v", err) e2elog.Failf("failed to delete configmap: %v", err)
} }
err = c.CoreV1(). err = c.CoreV1().
Secrets(cephCSINamespace). Secrets(cephCSINamespace).
Delete(context.TODO(), cephFSProvisionerSecretName, metav1.DeleteOptions{}) Delete(context.TODO(), cephFSProvisionerSecretName, metav1.DeleteOptions{})
if err != nil { 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(). err = c.CoreV1().
Secrets(cephCSINamespace). Secrets(cephCSINamespace).
Delete(context.TODO(), cephFSNodePluginSecretName, metav1.DeleteOptions{}) Delete(context.TODO(), cephFSNodePluginSecretName, metav1.DeleteOptions{})
if err != nil { 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(cephFSExamplePath + "storageclass.yaml") err = deleteResource(cephFSExamplePath + "storageclass.yaml")
if err != nil { if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err) e2elog.Failf("failed to delete storageclass: %v", err)
} }
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml") err = deleteResource(cephFSExamplePath + "snapshotclass.yaml")
if err != nil { if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err) e2elog.Failf("failed to delete storageclass: %v", err)
} }
if deployCephFS { if deployCephFS {
deleteCephfsPlugin() deleteCephfsPlugin()
@ -138,7 +138,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
err = deleteNamespace(c, cephCSINamespace) err = deleteNamespace(c, cephCSINamespace)
if err != nil { if err != nil {
if err != nil { if err != nil {
e2elog.Failf("failed to delete namespace with error %v", err) e2elog.Failf("failed to delete namespace: %v", err)
} }
} }
} }
@ -150,13 +150,13 @@ var _ = Describe("CephFS Upgrade Testing", func() {
By("checking provisioner deployment is running", func() { By("checking provisioner deployment is running", func() {
err = waitForDeploymentComplete(cephFSDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout) err = waitForDeploymentComplete(cephFSDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("timeout waiting for deployment %s with error %v", cephFSDeploymentName, err) e2elog.Failf("timeout waiting for deployment %s: %v", cephFSDeploymentName, err)
} }
}) })
By("checking nodeplugin deamonset pods are running", func() { By("checking nodeplugin deamonset pods are running", func() {
err = waitForDaemonSets(cephFSDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout) err = waitForDaemonSets(cephFSDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("timeout waiting for daemonset %s with error%v", cephFSDeamonSetName, err) e2elog.Failf("timeout waiting for daemonset %s: %v", cephFSDeamonSetName, err)
} }
}) })
@ -169,13 +169,13 @@ var _ = Describe("CephFS Upgrade Testing", func() {
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)
} }
pvc.Namespace = f.UniqueName pvc.Namespace = f.UniqueName
app, err = loadApp(appPath) app, err = loadApp(appPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load application with error %v", err) e2elog.Failf("failed to load application: %v", err)
} }
label[appKey] = appLabel label[appKey] = appLabel
app.Namespace = f.UniqueName app.Namespace = f.UniqueName
@ -184,7 +184,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
pvc.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize) pvc.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
err = createPVCAndApp("", f, pvc, app, deployTimeout) err = createPVCAndApp("", f, pvc, app, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create pvc and application with error %v", err) e2elog.Failf("failed to create pvc and application: %v", err)
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]), LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -212,7 +212,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
e2elog.Logf("Calculating checksum of %s", filePath) e2elog.Logf("Calculating checksum of %s", filePath)
checkSum, err = calculateSHA512sum(f, app, filePath, &opt) checkSum, err = calculateSHA512sum(f, app, filePath, &opt)
if err != nil { 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+ // pvc clone is only supported from v1.16+
@ -230,25 +230,25 @@ var _ = Describe("CephFS Upgrade Testing", func() {
} }
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 application with error %v", err) e2elog.Failf("failed to delete application: %v", err)
} }
deleteCephfsPlugin() deleteCephfsPlugin()
// switch back to current changes. // switch back to current changes.
err = os.Chdir(cwd) err = os.Chdir(cwd)
if err != nil { if err != nil {
e2elog.Failf("failed to d chdir with error %v", err) e2elog.Failf("failed to d chdir: %v", err)
} }
deployCephfsPlugin() deployCephfsPlugin()
err = waitForDeploymentComplete(cephFSDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout) err = waitForDeploymentComplete(cephFSDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("timeout waiting for upgraded deployment %s with error %v", cephFSDeploymentName, err) e2elog.Failf("timeout waiting for upgraded deployment %s: %v", cephFSDeploymentName, err)
} }
err = waitForDaemonSets(cephFSDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout) err = waitForDaemonSets(cephFSDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("timeout waiting for upgraded daemonset %s with error %v", cephFSDeamonSetName, err) e2elog.Failf("timeout waiting for upgraded daemonset %s: %v", cephFSDeamonSetName, err)
} }
app.Labels = label app.Labels = label
@ -256,7 +256,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
// an earlier release. // an earlier release.
err = createApp(f.ClientSet, app, deployTimeout) err = createApp(f.ClientSet, app, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create application with error %v", err) e2elog.Failf("failed to create application: %v", err)
} }
}) })
@ -269,13 +269,13 @@ var _ = Describe("CephFS Upgrade Testing", func() {
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) { if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
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)
} }
pvcClone.Namespace = f.UniqueName pvcClone.Namespace = f.UniqueName
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize) pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
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)
} }
label[appKey] = "validate-snap-cephfs" label[appKey] = "validate-snap-cephfs"
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
@ -283,7 +283,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
appClone.Labels = label appClone.Labels = label
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout) err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create pvc and application with error %v", err) e2elog.Failf("failed to create pvc and application: %v", err)
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]), LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -292,7 +292,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
testFilePath := filepath.Join(mountPath, "testClone") testFilePath := filepath.Join(mountPath, "testClone")
newCheckSum, err = calculateSHA512sum(f, appClone, testFilePath, &opt) newCheckSum, err = calculateSHA512sum(f, appClone, testFilePath, &opt)
if err != nil { 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 { if strings.Compare(newCheckSum, checkSum) != 0 {
@ -332,14 +332,14 @@ var _ = Describe("CephFS Upgrade Testing", func() {
if k8sVersionGreaterEquals(f.ClientSet, 1, 16) { if k8sVersionGreaterEquals(f.ClientSet, 1, 16) {
pvcClone, err = loadPVC(pvcSmartClonePath) pvcClone, err = loadPVC(pvcSmartClonePath)
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
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize) pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
appClone, err = loadApp(appSmartClonePath) appClone, err = loadApp(appSmartClonePath)
if err != nil { 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-cephfs" label[appKey] = "validate-snap-cephfs"
appClone.Namespace = f.UniqueName appClone.Namespace = f.UniqueName
@ -347,7 +347,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
appClone.Labels = label appClone.Labels = label
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout) err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create pvc and application with error %v", err) e2elog.Failf("failed to create pvc and application: %v", err)
} }
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]), LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
@ -356,7 +356,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
testFilePath := filepath.Join(mountPath, "testClone") testFilePath := filepath.Join(mountPath, "testClone")
newCheckSum, err = calculateSHA512sum(f, appClone, testFilePath, &opt) newCheckSum, err = calculateSHA512sum(f, appClone, testFilePath, &opt)
if err != nil { 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 { if strings.Compare(newCheckSum, checkSum) != 0 {
@ -370,7 +370,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
// delete cloned pvc and pod // delete cloned pvc and pod
err = deletePVCAndApp("", f, pvcClone, appClone) err = deletePVCAndApp("", f, pvcClone, appClone)
if err != nil { 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)
} }
} }
@ -390,23 +390,23 @@ var _ = Describe("CephFS Upgrade Testing", func() {
PersistentVolumeClaims(pvc.Namespace). PersistentVolumeClaims(pvc.Namespace).
Get(context.TODO(), pvc.Name, metav1.GetOptions{}) Get(context.TODO(), pvc.Name, metav1.GetOptions{})
if err != nil { if err != nil {
e2elog.Failf("failed to get pvc with error %v", err) e2elog.Failf("failed to get pvc: %v", err)
} }
// resize PVC // resize PVC
err = expandPVCSize(f.ClientSet, pvc, pvcExpandSize, deployTimeout) err = expandPVCSize(f.ClientSet, pvc, pvcExpandSize, deployTimeout)
if err != nil { 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 // wait for application pod to come up after resize
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError) err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
if err != nil { 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. // validate if resize is successful.
err = checkDirSize(app, f, &opt, pvcExpandSize) err = checkDirSize(app, f, &opt, pvcExpandSize)
if err != nil { if err != nil {
e2elog.Failf("failed to check directory size with error %v", err) e2elog.Failf("failed to check directory size: %v", err)
} }
} }
}) })
@ -414,17 +414,17 @@ var _ = Describe("CephFS Upgrade Testing", func() {
By("delete pvc and app") By("delete pvc and app")
err = deletePVCAndApp("", f, pvc, app) err = deletePVCAndApp("", f, pvc, app)
if err != nil { 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 cephFS provisioner secret // delete cephFS provisioner secret
err = deleteCephUser(f, keyringCephFSProvisionerUsername) err = deleteCephUser(f, keyringCephFSProvisionerUsername)
if err != nil { if err != nil {
e2elog.Failf("failed to delete user %s with error %v", keyringCephFSProvisionerUsername, err) e2elog.Failf("failed to delete user %s: %v", keyringCephFSProvisionerUsername, err)
} }
// delete cephFS plugin secret // delete cephFS plugin secret
err = deleteCephUser(f, keyringCephFSNodePluginUsername) err = deleteCephUser(f, keyringCephFSNodePluginUsername)
if err != nil { if err != nil {
e2elog.Failf("failed to delete user %s with error %v", keyringCephFSNodePluginUsername, err) e2elog.Failf("failed to delete user %s: %v", keyringCephFSNodePluginUsername, err)
} }
}) })
}) })