Merge pull request #19182 from Luap99/slow-remote-version

test/e2e: wait for socket
This commit is contained in:
OpenShift Merge Robot
2023-07-10 13:16:51 -04:00
committed by GitHub
3 changed files with 23 additions and 34 deletions

View File

@ -13,7 +13,6 @@ import (
"github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/domain/entities/types" "github.com/containers/podman/v4/pkg/domain/entities/types"
"github.com/containers/podman/v4/version" "github.com/containers/podman/v4/version"
"github.com/sirupsen/logrus"
) )
func VersionHandler(w http.ResponseWriter, r *http.Request) { func VersionHandler(w http.ResponseWriter, r *http.Request) {
@ -45,29 +44,19 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
"MinAPIVersion": version.APIVersion[version.Libpod][version.MinimalAPI].String(), "MinAPIVersion": version.APIVersion[version.Libpod][version.MinimalAPI].String(),
"Os": goRuntime.GOOS, "Os": goRuntime.GOOS,
}, },
}} }, {
if conmon, oci, err := runtime.DefaultOCIRuntime().RuntimeInfo(); err != nil {
logrus.Warnf("Failed to retrieve Conmon and OCI Information: %q", err.Error())
} else {
additional := []types.ComponentVersion{
{
Name: "Conmon", Name: "Conmon",
Version: conmon.Version, Version: info.Host.Conmon.Version,
Details: map[string]string{ Details: map[string]string{
"Package": conmon.Package, "Package": info.Host.Conmon.Package,
}, },
}, }, {
{ Name: fmt.Sprintf("OCI Runtime (%s)", info.Host.OCIRuntime.Name),
Name: fmt.Sprintf("OCI Runtime (%s)", oci.Name), Version: info.Host.OCIRuntime.Version,
Version: oci.Version,
Details: map[string]string{ Details: map[string]string{
"Package": oci.Package, "Package": info.Host.OCIRuntime.Package,
}, },
}, }}
}
components = append(components, additional...)
}
apiVersion := version.APIVersion[version.Compat][version.CurrentAPI] apiVersion := version.APIVersion[version.Compat][version.CurrentAPI]
minVersion := version.APIVersion[version.Compat][version.MinimalAPI] minVersion := version.APIVersion[version.Compat][version.MinimalAPI]

View File

@ -57,7 +57,6 @@ type PodmanTestIntegration struct {
CgroupManager string CgroupManager string
Host HostOS Host HostOS
TmpDir string TmpDir string
RemoteStartErr error
} }
var LockTmpDir string var LockTmpDir string

View File

@ -6,6 +6,7 @@ package integration
import ( import (
"errors" "errors"
"fmt" "fmt"
"net"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -94,7 +95,8 @@ func (p *PodmanTestIntegration) StartRemoteService() {
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
p.RemoteCommand = command p.RemoteCommand = command
p.RemoteSession = command.Process p.RemoteSession = command.Process
p.RemoteStartErr = p.DelayForService() err = p.DelayForService()
Expect(err).ToNot(HaveOccurred())
} }
func (p *PodmanTestIntegration) StopRemoteService() { func (p *PodmanTestIntegration) StopRemoteService() {
@ -145,16 +147,15 @@ func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
} }
func (p *PodmanTestIntegration) DelayForService() error { func (p *PodmanTestIntegration) DelayForService() error {
var session *PodmanSessionIntegration var err error
for i := 0; i < 5; i++ { var conn net.Conn
session = p.Podman([]string{"info"}) for i := 0; i < 100; i++ {
session.WaitWithDefaultTimeout() conn, err = net.Dial("unix", strings.TrimPrefix(p.RemoteSocket, "unix:"))
if session.ExitCode() == 0 { if err == nil {
conn.Close()
return nil 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)
} }