diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-07-05 11:09:51 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-07-05 11:12:30 +0200 |
commit | c02f793bab8e79e45f4fa798723b13a806557c44 (patch) | |
tree | 9d5969b5bdc5c5862994235e67d7901b5e959bea /test/e2e | |
parent | a406b950e4f8cf64bdd2c1e03a8480d4b5f97226 (diff) | |
download | podman-c02f793bab8e79e45f4fa798723b13a806557c44.tar.gz podman-c02f793bab8e79e45f4fa798723b13a806557c44.tar.bz2 podman-c02f793bab8e79e45f4fa798723b13a806557c44.zip |
test: return immediately on connect
if the connection is successfull then return immediately instead of doing
all the iterations. It also solves a problem where connections are
leaked since there are multiple Dial but only one Close.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/common_test.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 261db8a9a..e882b6be3 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -1081,15 +1081,17 @@ func WaitForFile(path string) (err error) { // WaitForService blocks, waiting for some service listening on given host:port func WaitForService(address url.URL) { // Wait for podman to be ready - var conn net.Conn var err error for i := 1; i <= 5; i++ { + var conn net.Conn conn, err = net.Dial("tcp", address.Host) - if err != nil { - // Podman not available yet... - time.Sleep(time.Duration(i) * time.Second) + if err == nil { + conn.Close() + break } + + // Podman not available yet... + time.Sleep(time.Duration(i) * time.Second) } Expect(err).ShouldNot(HaveOccurred()) - conn.Close() } |