From e2466bca28b62b89999e55332eda2fa3cdbd95bc Mon Sep 17 00:00:00 2001 From: kubevirt-bot Date: Mon, 18 Jan 2021 13:20:45 +0100 Subject: [PATCH] Compare logs while ignoring differences in spaces. (#1570) Some OpenShift versions seem to not add spaces between different components of the message, become more resilient for this scenario. Signed-off-by: Maya Rashish Co-authored-by: Maya Rashish --- tests/cloner_test.go | 4 ++-- tests/import_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/cloner_test.go b/tests/cloner_test.go index 449ab168bc..0050decd1c 100644 --- a/tests/cloner_test.go +++ b/tests/cloner_test.go @@ -844,11 +844,11 @@ var _ = Describe("all clone tests", func() { f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume) By("Verify Quota was exceeded in logs") - matchString := fmt.Sprintf("\"namespace\": \"%s\", \"error\": \"pods \\\"cdi-upload-target-dv\\\" is forbidden: exceeded quota: test-quota, requested", targetNs.Name) + matchString := strings.Trim(fmt.Sprintf("\"namespace\": \"%s\", \"error\": \"pods \\\"cdi-upload-target-dv\\\" is forbidden: exceeded quota: test-quota, requested", targetNs.Name), " ") Eventually(func() string { log, err := RunKubectlCommand(f, "logs", f.ControllerPod.Name, "-n", f.CdiInstallNs) Expect(err).NotTo(HaveOccurred()) - return log + return strings.Trim(log, " ") }, controllerSkipPVCCompleteTimeout, assertionPollInterval).Should(ContainSubstring(matchString)) }) }) diff --git a/tests/import_test.go b/tests/import_test.go index 4304b89658..528cb3196c 100644 --- a/tests/import_test.go +++ b/tests/import_test.go @@ -490,11 +490,11 @@ var _ = Describe("Namespace with quota", func() { f.ForceBindIfWaitForFirstConsumer(pvc) By("Verify Quota was exceeded in logs") - matchString := fmt.Sprintf(`"name": "import-image-to-pvc", "namespace": "%s", "error": "pods \"importer-import-image-to-pvc\" is forbidden: exceeded quota: test-quota`, f.Namespace.Name) + matchString := strings.Trim(fmt.Sprintf(`"name": "import-image-to-pvc", "namespace": "%s", "error": "pods \"importer-import-image-to-pvc\" is forbidden: exceeded quota: test-quota`, f.Namespace.Name), " ") Eventually(func() string { log, err := tests.RunKubectlCommand(f, "logs", f.ControllerPod.Name, "-n", f.CdiInstallNs) Expect(err).NotTo(HaveOccurred()) - return log + return strings.Trim(log, " ") }, controllerSkipPVCCompleteTimeout, assertionPollInterval).Should(ContainSubstring(matchString)) }) @@ -519,11 +519,11 @@ var _ = Describe("Namespace with quota", func() { f.ForceBindIfWaitForFirstConsumer(pvc) By("Verify Quota was exceeded in logs") - matchString := fmt.Sprintf(`"name": "import-image-to-pvc", "namespace": "%s", "error": "pods \"importer-import-image-to-pvc\" is forbidden: exceeded quota: test-quota`, f.Namespace.Name) + matchString := strings.Trim(fmt.Sprintf(`"name": "import-image-to-pvc", "namespace": "%s", "error": "pods \"importer-import-image-to-pvc\" is forbidden: exceeded quota: test-quota`, f.Namespace.Name), " ") Eventually(func() string { log, err := tests.RunKubectlCommand(f, "logs", f.ControllerPod.Name, "-n", f.CdiInstallNs) Expect(err).NotTo(HaveOccurred()) - return log + return strings.Trim(log, " ") }, controllerSkipPVCCompleteTimeout, assertionPollInterval).Should(ContainSubstring(matchString)) err = f.UpdateQuotaInNs(int64(2), int64(512*1024*1024), int64(2), int64(512*1024*1024))