Skip to content

Commit

Permalink
Compare logs while ignoring differences in spaces. (#1570)
Browse files Browse the repository at this point in the history
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 <mrashish@redhat.com>

Co-authored-by: Maya Rashish <mrashish@redhat.com>
  • Loading branch information
kubevirt-bot and maya-r committed Jan 18, 2021
1 parent 9103419 commit e2466bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/cloner_test.go
Expand Up @@ -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))
})
})
Expand Down
8 changes: 4 additions & 4 deletions tests/import_test.go
Expand Up @@ -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))
})

Expand All @@ -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))
Expand Down

0 comments on commit e2466bc

Please sign in to comment.