Skip to content

Commit

Permalink
test/e2e: wait for socket
Browse files Browse the repository at this point in the history
Do not use podman info/version as they are expensive and clutter the log
for no reason. Just checking if we can connect to the socket should be
good enough and much faster.

Fix the non existing error checking, so that we actually see an useful
error when this does not work.

Also change the interval, why wait 2s for a retry lets take 100ms steps
instead.

Fixes containers#19010

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 authored and ashley-cui committed Jul 13, 2023
1 parent a3a6285 commit 2581352
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type PodmanTestIntegration struct {
Host HostOS
Timings []string
TmpDir string
RemoteStartErr error
}

var LockTmpDir string
Expand Down
21 changes: 11 additions & 10 deletions test/e2e/libpod_suite_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package integration
import (
"errors"
"fmt"
"net"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -94,7 +95,8 @@ func (p *PodmanTestIntegration) StartRemoteService() {
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
p.RemoteCommand = command
p.RemoteSession = command.Process
p.RemoteStartErr = p.DelayForService()
err = p.DelayForService()
Expect(err).ToNot(HaveOccurred())
}

func (p *PodmanTestIntegration) StopRemoteService() {
Expand Down Expand Up @@ -145,16 +147,15 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
}

func (p *PodmanTestIntegration) DelayForService() error {
var session *PodmanSessionIntegration
for i := 0; i < 5; i++ {
session = p.Podman([]string{"info"})
session.WaitWithDefaultTimeout()
if session.ExitCode() == 0 {
var err error
var conn net.Conn
for i := 0; i < 100; i++ {
conn, err = net.Dial("unix", strings.TrimPrefix(p.RemoteSocket, "unix:"))
if err == nil {
conn.Close()
return nil
} else if i == 4 {
break
}
time.Sleep(2 * time.Second)
time.Sleep(100 * time.Millisecond)
}
return fmt.Errorf("service not detected, exit code(%d)", session.ExitCode())
return fmt.Errorf("service socket not detected, timeout after 10 seconds: %w", err)
}

0 comments on commit 2581352

Please sign in to comment.