From 2da731a7eac469f857879d5cda5c3cfa45e84f92 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 5 Jul 2022 11:36:06 +0200 Subject: test: reduce sleep interval there is no need to use such long sleep intervals for such cheap operations like opening a connection or stat'ing a file. Also make WaitForService() honor defaultWaitTimeout. Signed-off-by: Giuseppe Scrivano --- test/e2e/common_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/e2e/common_test.go') diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index e882b6be3..fc7a18afb 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -1064,13 +1064,13 @@ func digShort(container, lookupName string, matchNames []string, p *PodmanTestIn // WaitForFile to be created in defaultWaitTimeout seconds, returns false if file not created func WaitForFile(path string) (err error) { until := time.Now().Add(time.Duration(defaultWaitTimeout) * time.Second) - for i := 1; time.Now().Before(until); i++ { + for time.Now().Before(until) { _, err = os.Stat(path) switch { case err == nil: return nil case errors.Is(err, os.ErrNotExist): - time.Sleep(time.Duration(i) * time.Second) + time.Sleep(10 * time.Millisecond) default: return err } @@ -1078,11 +1078,12 @@ func WaitForFile(path string) (err error) { return err } -// WaitForService blocks, waiting for some service listening on given host:port +// WaitForService blocks for defaultWaitTimeout seconds, waiting for some service listening on given host:port func WaitForService(address url.URL) { // Wait for podman to be ready var err error - for i := 1; i <= 5; i++ { + until := time.Now().Add(time.Duration(defaultWaitTimeout) * time.Second) + for time.Now().Before(until) { var conn net.Conn conn, err = net.Dial("tcp", address.Host) if err == nil { @@ -1091,7 +1092,7 @@ func WaitForService(address url.URL) { } // Podman not available yet... - time.Sleep(time.Duration(i) * time.Second) + time.Sleep(10 * time.Millisecond) } Expect(err).ShouldNot(HaveOccurred()) } -- cgit v1.2.3-54-g00ecf