summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2022-07-05 11:36:06 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2022-07-05 11:36:06 +0200
commit2da731a7eac469f857879d5cda5c3cfa45e84f92 (patch)
tree93173200c2cff34ca46c2a98310c9a4d9f2abe8e /test
parentc02f793bab8e79e45f4fa798723b13a806557c44 (diff)
downloadpodman-2da731a7eac469f857879d5cda5c3cfa45e84f92.tar.gz
podman-2da731a7eac469f857879d5cda5c3cfa45e84f92.tar.bz2
podman-2da731a7eac469f857879d5cda5c3cfa45e84f92.zip
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 <gscrivan@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/common_test.go11
1 files changed, 6 insertions, 5 deletions
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())
}