test/e2e: use go net.Dial() ov nc

This is simpler as we don't have to rely on an external command. The
retry loop is need as we check for a container porcess connection, and
while we know podman binds the port before returning there is no way to
know whenthe contianer application bound the port so we must retry a
bit.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-03-13 14:59:38 +01:00
parent f8787bb219
commit bcc2063e9e
2 changed files with 19 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ package integration
import (
"fmt"
"net"
"os"
"os/user"
"path/filepath"
@@ -68,8 +69,8 @@ var _ = Describe("Podman pod create", func() {
webserver.WaitWithDefaultTimeout()
Expect(webserver).Should(ExitCleanly())
check := SystemExec("nc", []string{"-z", "localhost", "80"})
Expect(check).Should(ExitWithError(1, ""))
_, err := net.Dial("tcp", "localhost:80")
Expect(err).To(HaveOccurred())
})
It("podman create pod with network portbindings", func() {
@@ -83,7 +84,7 @@ var _ = Describe("Podman pod create", func() {
webserver := podmanTest.Podman([]string{"run", "--pod", pod, "-dt", NGINX_IMAGE})
webserver.WaitWithDefaultTimeout()
Expect(webserver).Should(ExitCleanly())
Expect(ncz(port)).To(BeTrue(), "port %d is up", port)
testPortConnection(port)
})
It("podman create pod with id file with network portbindings", func() {
@@ -97,7 +98,7 @@ var _ = Describe("Podman pod create", func() {
webserver := podmanTest.Podman([]string{"run", "--pod-id-file", file, "-dt", NGINX_IMAGE})
webserver.WaitWithDefaultTimeout()
Expect(webserver).Should(ExitCleanly())
Expect(ncz(port)).To(BeTrue(), "port %d is up", port)
testPortConnection(port)
})
It("podman create pod with no infra but portbindings should fail", func() {