From 50f5becd015ed32f8f56d74d209df487910e95ea Mon Sep 17 00:00:00 2001 From: maistra-bot <57098434+maistra-bot@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:14:53 +0200 Subject: [PATCH] OSSM-2109 Fix flaky IOR unit test (#648) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sleep in ensureNamespaceExists was hardcoded to 100ms, regardless of r.handleEventTimeout. This timeout during unit tests is only 1ms, so the 100ms sleep caused the for loop to only run once. Here we change the duration of the sleep to be 1/100 of r.handleEventTimeout. This change preserves the production sleep time of 100ms, but reduces the sleep time in unit tests to 10μs. This makes ensureNamespaceExists() run the for loop multiple times before giving up, fixing the test's flakiness. Co-authored-by: Marko Lukša --- pilot/pkg/config/kube/ior/route.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pilot/pkg/config/kube/ior/route.go b/pilot/pkg/config/kube/ior/route.go index b10490051a8..8a283873659 100644 --- a/pilot/pkg/config/kube/ior/route.go +++ b/pilot/pkg/config/kube/ior/route.go @@ -278,7 +278,7 @@ func (r *route) ensureNamespaceExists(cfg config.Config) error { default: IORLog.Debugf("Namespace %s not found in SMMR, trying again", cfg.Namespace) } - time.Sleep(100 * time.Millisecond) + time.Sleep(r.handleEventTimeout / 100) } }