From 8aeb41a875c62a0aedfe7042861c424d42ab7bb1 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 12 Jan 2024 16:27:58 -0500 Subject: [PATCH] fix: allow propagation time for async conditions (#111) Issue #, if available: Seen several tests fail (especially on Windows) because of these types of checks. See: https://github.com/runfinch/finch/actions/runs/7493150724/job/20398226027 and https://github.com/runfinch/finch/actions/runs/7493200344/job/20398390738 *Description of changes:* - Adds a timeout and polling to these checks. This should have no impact when the condition is achieved quickly, but allow it to take up to 15 seconds at the worst case *Testing done:* - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: Justin Alvarez --- tests/events.go | 8 +++++++- tests/logs.go | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/events.go b/tests/events.go index ec79249..847a680 100644 --- a/tests/events.go +++ b/tests/events.go @@ -4,6 +4,8 @@ package tests import ( + "time" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -26,7 +28,11 @@ func Events(o *option.Option) { defer session.Kill() gomega.Expect(session.Out.Contents()).Should(gomega.BeEmpty()) command.Run(o, "pull", defaultImage) - gomega.Expect(session.Out.Contents()).Should(gomega.ContainSubstring(defaultImage)) + // allow propagation time + gomega.Eventually(session.Out.Contents()). + WithTimeout(15 * time.Second). + WithPolling(1 * time.Second). + Should(gomega.ContainSubstring(defaultImage)) }) }) } diff --git a/tests/logs.go b/tests/logs.go index e05b568..62d72b5 100644 --- a/tests/logs.go +++ b/tests/logs.go @@ -99,8 +99,11 @@ func Logs(o *option.Option) { defer session.Kill() gomega.Expect(session.Out.Contents()).Should(gomega.BeEmpty()) command.Run(o, "exec", testContainerName, "sh", "-c", fmt.Sprintf("echo %s >> /proc/1/fd/1", newLog)) - output := strings.TrimSpace(string(session.Out.Contents())) - gomega.Expect(output).Should(gomega.Equal(newLog)) + // allow propagation time + gomega.Eventually(strings.TrimSpace(string(session.Out.Contents()))). + WithTimeout(15 * time.Second). + WithPolling(1 * time.Second). + Should(gomega.Equal(newLog)) }) } })