From 84a85f021e15e7dad23efe2b0d0d11d22cbb54f0 Mon Sep 17 00:00:00 2001 From: Justin Alvarez Date: Fri, 12 Jan 2024 13:43:06 -0500 Subject: [PATCH 1/2] fix: allow propagation time for async conditions Signed-off-by: Justin Alvarez --- tests/events.go | 8 +++++++- tests/logs.go | 6 +++++- 2 files changed, 12 insertions(+), 2 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..40a8eed 100644 --- a/tests/logs.go +++ b/tests/logs.go @@ -100,7 +100,11 @@ func Logs(o *option.Option) { 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(output). + WithTimeout(15 * time.Second). + WithPolling(1 * time.Second). + Should(gomega.Equal(newLog)) }) } }) From d86e440d0bb7569fdd0f342ee563f94e0f6de5b5 Mon Sep 17 00:00:00 2001 From: Justin Alvarez Date: Fri, 12 Jan 2024 15:29:25 -0500 Subject: [PATCH 2/2] remove intermediate variable Signed-off-by: Justin Alvarez --- tests/logs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/logs.go b/tests/logs.go index 40a8eed..62d72b5 100644 --- a/tests/logs.go +++ b/tests/logs.go @@ -99,9 +99,8 @@ 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())) // allow propagation time - gomega.Eventually(output). + gomega.Eventually(strings.TrimSpace(string(session.Out.Contents()))). WithTimeout(15 * time.Second). WithPolling(1 * time.Second). Should(gomega.Equal(newLog))