v2 enable remote integration tests

enable remote integration tests

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2020-05-11 12:07:42 -05:00
parent 9fe49335e0
commit 8ec08a426e
51 changed files with 375 additions and 75 deletions

View File

@ -520,6 +520,48 @@ integration_test_temporary_task:
path: "*.log.html"
type: "text/html"
# This task only temporary as we creep up on making
# all tests passing for v2 remote. Once all tests pass, we
# should immediately remove this and re-enable the
# testing matrix.
remote_integration_test_temporary_task:
depends_on:
- "gating"
- "varlink_api"
- "vendor"
- "build_each_commit"
- "build_without_cgo"
only_if: >-
$CIRRUS_CHANGE_MESSAGE !=~ '.*CI:IMG.*' &&
$CIRRUS_CHANGE_MESSAGE !=~ '.*CI:DOCS.*'
env:
ADD_SECOND_PARTITION: 'true'
TEST_REMOTE_CLIENT: 'true'
timeout_in: 60m
networking_script: '${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/networking.sh'
setup_environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}'
integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} | ${LOGFORMAT} integration_test'
on_failure:
failed_branch_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_branch_failure.sh'
always:
package_versions_script: '$SCRIPT_BASE/logcollector.sh packages'
ginkgo_node_logs_script: '$SCRIPT_BASE/logcollector.sh ginkgo'
df_script: '$SCRIPT_BASE/logcollector.sh df'
audit_log_script: '$SCRIPT_BASE/logcollector.sh audit'
journal_script: '$SCRIPT_BASE/logcollector.sh journal'
varlink_script: '$SCRIPT_BASE/logcollector.sh varlink'
podman_system_info_script: '$SCRIPT_BASE/logcollector.sh podman'
html_artifacts:
path: "*.log.html"
type: "text/html"
# This task executes tests under unique environments/conditions
special_testing_rootless_task:
@ -823,6 +865,7 @@ success_task:
- "static_build"
# FIXME remove when all v2 tests pass
- "integration_test_temporary"
- "remote_integration_test_temporary"
env:
CIRRUS_WORKING_DIR: "/usr/src/libpod"

View File

@ -357,14 +357,14 @@ remotesystem:
# varlink server spews copious unhelpful output; ignore it.
rc=0;\
if timeout -v 1 true; then \
SOCK_FILE=$(shell mktemp --dry-run --tmpdir io.podman.XXXXXX);\
export PODMAN_VARLINK_ADDRESS=unix:$$SOCK_FILE; \
./bin/podman varlink --timeout=0 $$PODMAN_VARLINK_ADDRESS &> $(if $(VARLINK_LOG),$(VARLINK_LOG),/dev/null) & \
SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman.XXXXXX);\
export PODMAN_SOCKEY=unix:$$SOCK_FILE; \
./bin/podman system service --timeout=0 $$PODMAN_VARLINK_ADDRESS &> $(if $(VARLINK_LOG),$(VARLINK_LOG),/dev/null) & \
retry=5;\
while [[ $$retry -ge 0 ]]; do\
echo Waiting for varlink server...;\
echo Waiting for server...;\
sleep 1;\
./bin/podman-remote info &>/dev/null && break;\
./bin/podman-remote --remote $(SOCK_FILE) info &>/dev/null && break;\
retry=$$(expr $$retry - 1);\
done;\
env PODMAN=./bin/podman-remote bats test/system/ ;\

View File

@ -3,6 +3,7 @@ package containers
import (
"context"
"fmt"
"strings"
"github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
@ -120,10 +121,12 @@ func rm(cmd *cobra.Command, args []string) error {
func setExitCode(err error) {
cause := errors.Cause(err)
switch cause {
case define.ErrNoSuchCtr:
switch {
case cause == define.ErrNoSuchCtr:
registry.SetExitCode(1)
case define.ErrCtrStateInvalid:
case strings.Contains(cause.Error(), define.ErrNoSuchImage.Error()):
registry.SetExitCode(1)
case cause == define.ErrCtrStateInvalid:
registry.SetExitCode(2)
}
}

View File

@ -37,7 +37,7 @@ func getContainersByContext(contextWithConnection context.Context, all bool, nam
}
}
if !found {
return nil, errors.Errorf("unable to find container %q", id)
return nil, errors.Wrapf(define.ErrNoSuchCtr, "unable to find container %q", id)
}
}
return cons, nil

View File

@ -217,6 +217,7 @@ var _ = Describe("Podman commit", func() {
})
It("podman commit container check env variables", func() {
Skip(v2remotefail)
s := podmanTest.Podman([]string{"run", "--name", "test1", "-e", "TEST=1=1-01=9.01", "-it", "alpine", "true"})
s.WaitWithDefaultTimeout()
Expect(s.ExitCode()).To(Equal(0))

View File

@ -53,6 +53,7 @@ type PodmanTestIntegration struct {
Host HostOS
Timings []string
TmpDir string
RemoteStartErr error
}
var LockTmpDir string
@ -259,12 +260,12 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
p.PodmanTest.RemotePodmanBinary = podmanRemoteBinary
uuid := stringid.GenerateNonCryptoID()
if !rootless.IsRootless() {
p.VarlinkEndpoint = fmt.Sprintf("unix:/run/podman/io.podman-%s", uuid)
p.RemoteSocket = fmt.Sprintf("unix:/run/podman/podman-%s.sock", uuid)
} else {
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
socket := fmt.Sprintf("io.podman-%s", uuid)
socket := fmt.Sprintf("podman-%s.sock", uuid)
fqpath := filepath.Join(runtimeDir, socket)
p.VarlinkEndpoint = fmt.Sprintf("unix:%s", fqpath)
p.RemoteSocket = fmt.Sprintf("unix:%s", fqpath)
}
}
@ -441,7 +442,7 @@ func (p *PodmanTestIntegration) Cleanup() {
session := p.Podman([]string{"rm", "-fa"})
session.Wait(90)
p.StopVarlink()
p.StopRemoteService()
// Nuke tempdir
if err := os.RemoveAll(p.TempDir); err != nil {
fmt.Printf("%q\n", err)
@ -451,17 +452,6 @@ func (p *PodmanTestIntegration) Cleanup() {
resetRegistriesConfigEnv()
}
// CleanupPod cleans up the temporary store
func (p *PodmanTestIntegration) CleanupPod() {
// Remove all containers
session := p.Podman([]string{"pod", "rm", "-fa"})
session.Wait(90)
// Nuke tempdir
if err := os.RemoveAll(p.TempDir); err != nil {
fmt.Printf("%q\n", err)
}
}
// CleanupVolume cleans up the temporary store
func (p *PodmanTestIntegration) CleanupVolume() {
// Remove all containers

View File

@ -27,4 +27,8 @@ var (
// v2fail is a temporary variable to help us track
// tests that fail in v2
v2fail = "does not pass integration tests with v2 podman"
// v2remotefail is a temporary variable to help us track
// tests that fail in v2 remote
v2remotefail = "does not pass integration tests with v2 podman remote"
)

View File

@ -27,7 +27,7 @@ var _ = Describe("Podman container inspect", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
})

View File

@ -35,6 +35,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create container based on a local image", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
cid := session.OutputToString()
@ -80,6 +81,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create adds annotation", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"create", "--annotation", "HELLO=WORLD", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -94,6 +96,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create --entrypoint command", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"create", "--entrypoint", "/bin/foobar", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -118,6 +121,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create --entrypoint json", func() {
Skip(v2remotefail)
jsonString := `[ "/bin/foo", "-c"]`
session := podmanTest.Podman([]string{"create", "--entrypoint", jsonString, ALPINE})
session.WaitWithDefaultTimeout()
@ -131,6 +135,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create --mount flag with multiple mounts", func() {
Skip(v2remotefail)
vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
err := os.MkdirAll(vol1, 0755)
Expect(err).To(BeNil())
@ -156,6 +161,7 @@ var _ = Describe("Podman create", func() {
if podmanTest.Host.Arch == "ppc64le" {
Skip("skip failing test on ppc64le")
}
Skip(v2remotefail)
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
os.Mkdir(mountPath, 0755)
session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})

View File

@ -118,6 +118,7 @@ var _ = Describe("Podman events", func() {
})
It("podman events format", func() {
Skip(v2remotefail)
info := GetHostDistributionInfo()
if info.Distribution != "fedora" {
Skip("need to verify images have correct packages for journald")

View File

@ -18,6 +18,7 @@ var _ = Describe("Podman exec", func() {
)
BeforeEach(func() {
Skip(v2remotefail)
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)

View File

@ -34,7 +34,6 @@ var _ = Describe("Podman export", func() {
})
It("podman export output flag", func() {
SkipIfRemote()
_, ec, cid := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
@ -50,7 +49,6 @@ var _ = Describe("Podman export", func() {
})
It("podman container export output flag", func() {
SkipIfRemote()
_, ec, cid := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))

View File

@ -83,6 +83,7 @@ var _ = Describe("Podman healthcheck run", func() {
})
It("podman healthcheck that should fail", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "docker.io/libpod/badhealthcheck:latest"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -121,6 +122,7 @@ var _ = Describe("Podman healthcheck run", func() {
})
It("podman healthcheck failed checks in start-period should not change status", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-start-period", "2m", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -142,6 +144,7 @@ var _ = Describe("Podman healthcheck run", func() {
})
It("podman healthcheck failed checks must reach retries before unhealthy ", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -176,6 +179,7 @@ var _ = Describe("Podman healthcheck run", func() {
})
It("podman healthcheck single healthy result changes failed to healthy", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", "--health-retries", "2", "--health-cmd", "ls /foo || exit 1", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -131,6 +131,7 @@ var _ = Describe("Podman images", func() {
})
It("podman images filter by image name", func() {
Skip(v2remotefail)
podmanTest.RestoreAllArtifacts()
session := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE})
session.WaitWithDefaultTimeout()

View File

@ -33,7 +33,6 @@ var _ = Describe("Podman Info", func() {
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
})
It("podman info json output", func() {

View File

@ -75,6 +75,7 @@ var _ = Describe("Podman init", func() {
})
It("podman init latest container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -89,6 +90,7 @@ var _ = Describe("Podman init", func() {
})
It("podman init all three containers, one running", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -119,6 +121,7 @@ var _ = Describe("Podman init", func() {
})
It("podman init running container errors", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -43,7 +43,6 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect bogus container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"inspect", "foobar4321"})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
@ -67,7 +66,6 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container with GO format for ConmonPidFile", func() {
SkipIfRemote()
session, ec, _ := podmanTest.RunLsContainer("test1")
Expect(ec).To(Equal(0))
@ -77,11 +75,10 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container with size", func() {
SkipIfRemote()
_, ec, _ := podmanTest.RunLsContainer("")
_, ec, _ := podmanTest.RunLsContainer("sizetest")
Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"inspect", "--size", "-l"})
result := podmanTest.Podman([]string{"inspect", "--size", "sizetest"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
conData := result.InspectContainerToJSON()
@ -90,7 +87,6 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container and image", func() {
SkipIfRemote()
ls, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
cid := ls.OutputToString()
@ -102,7 +98,6 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container and filter for Image{ID}", func() {
SkipIfRemote()
ls, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
cid := ls.OutputToString()
@ -119,7 +114,6 @@ var _ = Describe("Podman inspect", func() {
})
It("podman inspect container and filter for CreateCommand", func() {
SkipIfRemote()
ls, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
cid := ls.OutputToString()

View File

@ -100,6 +100,7 @@ var _ = Describe("Podman kill", func() {
})
It("podman kill latest container", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -0,0 +1,214 @@
// +build remoteclient
package integration
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
"github.com/containers/libpod/pkg/rootless"
"github.com/onsi/ginkgo"
)
func SkipIfRemote() {
ginkgo.Skip("This function is not enabled for remote podman")
}
func SkipIfRootless() {
if os.Geteuid() != 0 {
ginkgo.Skip("This function is not enabled for rootless podman")
}
}
func SkipIfRootlessV2() {
if os.Geteuid() != 0 {
ginkgo.Skip("This function is not enabled for v2 rootless podman")
}
}
// Podman is the exec call to podman on the filesystem
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
var remoteArgs = []string{"--remote", p.RemoteSocket}
remoteArgs = append(remoteArgs, args...)
podmanSession := p.PodmanBase(remoteArgs, false, false)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files
func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration {
var remoteArgs = []string{"--remote", p.RemoteSocket}
remoteArgs = append(remoteArgs, args...)
podmanSession := p.PodmanAsUserBase(remoteArgs, 0, 0, "", nil, false, false, extraFiles)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanNoCache calls podman with out adding the imagecache
func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration {
var remoteArgs = []string{"--remote", p.RemoteSocket}
remoteArgs = append(remoteArgs, args...)
podmanSession := p.PodmanBase(remoteArgs, false, true)
return &PodmanSessionIntegration{podmanSession}
}
// PodmanNoEvents calls the Podman command without an imagecache and without an
// events backend. It is used mostly for caching and uncaching images.
func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration {
podmanSession := p.PodmanBase(args, true, true)
return &PodmanSessionIntegration{podmanSession}
}
func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf")
os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile)
}
func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
outfile := filepath.Join(p.TempDir, "registries.conf")
os.Setenv("REGISTRIES_CONFIG_PATH", outfile)
ioutil.WriteFile(outfile, b, 0644)
}
func resetRegistriesConfigEnv() {
os.Setenv("REGISTRIES_CONFIG_PATH", "")
}
func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
pti := PodmanTestCreateUtil(tempDir, true)
pti.StartRemoteService()
return pti
}
func (p *PodmanTestIntegration) StartRemoteService() {
if os.Geteuid() == 0 {
os.MkdirAll("/run/podman", 0755)
}
remoteSocket := p.RemoteSocket
args := []string{"system", "service", "--timeout", "0", remoteSocket}
podmanOptions := getRemoteOptions(p, args)
command := exec.Command(p.PodmanBinary, podmanOptions...)
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
command.Start()
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
p.RemoteCommand = command
p.RemoteSession = command.Process
err := p.DelayForService()
p.RemoteStartErr = err
}
func (p *PodmanTestIntegration) StopRemoteService() {
var out bytes.Buffer
var pids []int
remoteSession := p.RemoteSession
if !rootless.IsRootless() {
if err := remoteSession.Kill(); err != nil {
fmt.Fprintf(os.Stderr, "error on remote stop-kill %q", err)
}
if _, err := remoteSession.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "error on remote stop-wait %q", err)
}
} else {
//p.ResetVarlinkAddress()
parentPid := fmt.Sprintf("%d", p.RemoteSession.Pid)
pgrep := exec.Command("pgrep", "-P", parentPid)
fmt.Printf("running: pgrep %s\n", parentPid)
pgrep.Stdout = &out
err := pgrep.Run()
if err != nil {
fmt.Fprint(os.Stderr, "unable to find remote pid")
}
for _, s := range strings.Split(out.String(), "\n") {
if len(s) == 0 {
continue
}
p, err := strconv.Atoi(s)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to convert %s to int", s)
}
if p != 0 {
pids = append(pids, p)
}
}
pids = append(pids, p.RemoteSession.Pid)
for _, pid := range pids {
syscall.Kill(pid, syscall.SIGKILL)
}
}
socket := strings.Split(p.RemoteSocket, ":")[1]
if err := os.Remove(socket); err != nil {
fmt.Println(err)
}
}
//MakeOptions assembles all the podman main options
func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string {
return args
}
//MakeOptions assembles all the podman main options
func getRemoteOptions(p *PodmanTestIntegration, args []string) []string {
podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s",
p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
if os.Getenv("HOOK_OPTION") != "" {
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
}
podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...)
podmanOptions = append(podmanOptions, args...)
return podmanOptions
}
func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
fmt.Printf("Restoring %s...\n", image)
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
p.CrioRoot = p.ImageCacheDir
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
restore.WaitWithDefaultTimeout()
return nil
}
// SeedImages restores all the artifacts into the main store for remote tests
func (p *PodmanTestIntegration) SeedImages() error {
return p.RestoreAllArtifacts()
}
// RestoreArtifact puts the cached image into our test store
func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
fmt.Printf("Restoring %s...\n", image)
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
args := []string{"load", "-q", "-i", destName}
podmanOptions := getRemoteOptions(p, args)
command := exec.Command(p.PodmanBinary, podmanOptions...)
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
command.Start()
command.Wait()
return nil
}
func (p *PodmanTestIntegration) DelayForService() error {
for i := 0; i < 5; i++ {
session := p.Podman([]string{"info"})
session.WaitWithDefaultTimeout()
if session.ExitCode() == 0 {
return nil
} else if i == 4 {
break
}
time.Sleep(2 * time.Second)
}
return errors.New("Service not detected")
}
func populateCache(podman *PodmanTestIntegration) {}
func removeCache() {}

View File

@ -127,7 +127,7 @@ func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
return nil
}
func (p *PodmanTestIntegration) StopVarlink() {}
func (p *PodmanTestIntegration) StopRemoteService() {}
func (p *PodmanTestIntegration) DelayForVarlink() {}
func populateCache(podman *PodmanTestIntegration) {
@ -151,5 +151,5 @@ func (p *PodmanTestIntegration) SeedImages() error {
}
// We don't support running Varlink when local
func (p *PodmanTestIntegration) StartVarlink() {
func (p *PodmanTestIntegration) StartRemoteService() {
}

View File

@ -1,11 +1,10 @@
// +build remoteclient
// +build remoteclientvarlink
package integration
import (
"bytes"
"fmt"
"github.com/containers/libpod/pkg/rootless"
"io/ioutil"
"os"
"os/exec"
@ -15,6 +14,8 @@ import (
"syscall"
"time"
"github.com/containers/libpod/pkg/rootless"
"github.com/onsi/ginkgo"
)
@ -69,24 +70,24 @@ func resetRegistriesConfigEnv() {
}
func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
pti := PodmanTestCreateUtil(tempDir, true)
pti.StartVarlink()
pti.StartRemoteService()
return pti
}
func (p *PodmanTestIntegration) ResetVarlinkAddress() {
os.Unsetenv("PODMAN_VARLINK_ADDRESS")
//os.Unsetenv("PODMAN_VARLINK_ADDRESS")
}
func (p *PodmanTestIntegration) SetVarlinkAddress(addr string) {
os.Setenv("PODMAN_VARLINK_ADDRESS", addr)
//os.Setenv("PODMAN_VARLINK_ADDRESS", addr)
}
func (p *PodmanTestIntegration) StartVarlink() {
if os.Geteuid() == 0 {
os.MkdirAll("/run/podman", 0755)
}
varlinkEndpoint := p.VarlinkEndpoint
p.SetVarlinkAddress(p.VarlinkEndpoint)
varlinkEndpoint := p.RemoteSocket
p.SetVarlinkAddress(p.RemoteSocket)
args := []string{"varlink", "--timeout", "0", varlinkEndpoint}
podmanOptions := getVarlinkOptions(p, args)
@ -94,15 +95,15 @@ func (p *PodmanTestIntegration) StartVarlink() {
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
command.Start()
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
p.VarlinkCommand = command
p.VarlinkSession = command.Process
p.DelayForVarlink()
p.RemoteCommand = command
p.RemoteSession = command.Process
p.DelayForService()
}
func (p *PodmanTestIntegration) StopVarlink() {
var out bytes.Buffer
var pids []int
varlinkSession := p.VarlinkSession
varlinkSession := p.RemoteSession
if !rootless.IsRootless() {
if err := varlinkSession.Kill(); err != nil {
@ -114,7 +115,7 @@ func (p *PodmanTestIntegration) StopVarlink() {
} else {
p.ResetVarlinkAddress()
parentPid := fmt.Sprintf("%d", p.VarlinkSession.Pid)
parentPid := fmt.Sprintf("%d", p.RemoteSession.Pid)
pgrep := exec.Command("pgrep", "-P", parentPid)
fmt.Printf("running: pgrep %s\n", parentPid)
pgrep.Stdout = &out
@ -136,12 +137,12 @@ func (p *PodmanTestIntegration) StopVarlink() {
}
}
pids = append(pids, p.VarlinkSession.Pid)
pids = append(pids, p.RemoteSession.Pid)
for _, pid := range pids {
syscall.Kill(pid, syscall.SIGKILL)
}
}
socket := strings.Split(p.VarlinkEndpoint, ":")[1]
socket := strings.Split(p.RemoteSocket, ":")[1]
if err := os.Remove(socket); err != nil {
fmt.Println(err)
}

View File

@ -19,6 +19,7 @@ var _ = Describe("Podman logs", func() {
)
BeforeEach(func() {
Skip(v2remotefail)
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)

View File

@ -28,6 +28,7 @@ var _ = Describe("Podman manifest", func() {
)
BeforeEach(func() {
Skip(v2remotefail)
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)

View File

@ -132,6 +132,7 @@ var _ = Describe("Podman pause", func() {
})
It("podman remove a paused container by id without force", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -174,6 +175,7 @@ var _ = Describe("Podman pause", func() {
})
It("podman stop a paused container by id", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -270,6 +272,7 @@ var _ = Describe("Podman pause", func() {
})
It("Pause a bunch of running containers", func() {
Skip(v2remotefail)
for i := 0; i < 3; i++ {
name := fmt.Sprintf("test%d", i)
run := podmanTest.Podman([]string{"run", "-dt", "--name", name, nginx})
@ -297,6 +300,7 @@ var _ = Describe("Podman pause", func() {
})
It("Unpause a bunch of running containers", func() {
Skip(v2remotefail)
for i := 0; i < 3; i++ {
name := fmt.Sprintf("test%d", i)
run := podmanTest.Podman([]string{"run", "-dt", "--name", name, nginx})

View File

@ -28,7 +28,7 @@ var _ = Describe("Podman pod create", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -84,6 +84,7 @@ var _ = Describe("Podman pod create", func() {
})
It("podman create pod without network portbindings", func() {
Skip(v2remotefail)
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name})
session.WaitWithDefaultTimeout()
@ -99,6 +100,7 @@ var _ = Describe("Podman pod create", func() {
})
It("podman create pod with network portbindings", func() {
Skip(v2remotefail)
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--name", name, "-p", "8080:80"})
session.WaitWithDefaultTimeout()

View File

@ -29,7 +29,7 @@ var _ = Describe("Podman pod create", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -26,7 +26,7 @@ var _ = Describe("Podman pod inspect", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -27,7 +27,7 @@ var _ = Describe("Podman pod kill", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -100,6 +100,7 @@ var _ = Describe("Podman pod kill", func() {
})
It("podman pod kill latest pod", func() {
SkipIfRemote()
_, ec, podid := podmanTest.CreatePod("")
Expect(ec).To(Equal(0))

View File

@ -29,7 +29,7 @@ var _ = Describe("Podman pod pause", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -29,7 +29,7 @@ var _ = Describe("Podman pod create", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -26,7 +26,7 @@ var _ = Describe("Podman pod prune", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -28,7 +28,7 @@ var _ = Describe("Podman ps", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -83,6 +83,7 @@ var _ = Describe("Podman ps", func() {
})
It("podman pod ps latest", func() {
SkipIfRemote()
_, ec, podid1 := podmanTest.CreatePod("")
Expect(ec).To(Equal(0))

View File

@ -26,7 +26,7 @@ var _ = Describe("Podman pod restart", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -134,6 +134,7 @@ var _ = Describe("Podman pod restart", func() {
})
It("podman pod restart latest pod", func() {
SkipIfRemote()
_, ec, _ := podmanTest.CreatePod("foobar99")
Expect(ec).To(Equal(0))

View File

@ -29,7 +29,7 @@ var _ = Describe("Podman pod rm", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -60,6 +60,7 @@ var _ = Describe("Podman pod rm", func() {
})
It("podman pod rm latest pod", func() {
SkipIfRemote()
_, ec, podid := podmanTest.CreatePod("")
Expect(ec).To(Equal(0))

View File

@ -26,7 +26,7 @@ var _ = Describe("Podman pod start", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -103,6 +103,7 @@ var _ = Describe("Podman pod start", func() {
})
It("podman pod start latest pod", func() {
SkipIfRemote()
_, ec, _ := podmanTest.CreatePod("foobar99")
Expect(ec).To(Equal(0))

View File

@ -35,7 +35,7 @@ var _ = Describe("Podman pod stats", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -26,7 +26,7 @@ var _ = Describe("Podman pod stop", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
@ -144,6 +144,7 @@ var _ = Describe("Podman pod stop", func() {
})
It("podman pod stop latest pod", func() {
SkipIfRemote()
_, ec, _ := podmanTest.CreatePod("foobar99")
Expect(ec).To(Equal(0))

View File

@ -30,7 +30,7 @@ var _ = Describe("Podman top", func() {
})
AfterEach(func() {
podmanTest.CleanupPod()
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)

View File

@ -161,6 +161,7 @@ var _ = Describe("Podman prune", func() {
})
It("podman system prune pods", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -193,6 +194,7 @@ var _ = Describe("Podman prune", func() {
})
It("podman system prune - pod,container stopped", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -224,7 +226,7 @@ var _ = Describe("Podman prune", func() {
})
It("podman system prune with running, exited pod and volume prune set true", func() {
Skip(v2remotefail)
// Start and stop a pod to get it in exited state.
session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout()
@ -299,6 +301,7 @@ var _ = Describe("Podman prune", func() {
})
It("podman system prune - with dangling images true", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"pod", "create"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -101,6 +101,7 @@ var _ = Describe("Podman ps", func() {
})
It("podman ps latest flag", func() {
SkipIfRemote()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))

View File

@ -122,6 +122,7 @@ var _ = Describe("Podman restart", func() {
})
It("Podman restart the latest container", func() {
SkipIfRemote()
_, exitCode, _ := podmanTest.RunLsContainer("test1")
Expect(exitCode).To(Equal(0))

View File

@ -43,6 +43,7 @@ var _ = Describe("Podman rm", func() {
})
It("podman rm refuse to remove a running container", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -123,6 +124,7 @@ var _ = Describe("Podman rm", func() {
})
It("podman rm the latest container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"create", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -75,6 +75,7 @@ var _ = Describe("Podman rmi", func() {
})
It("podman rmi tagged image", func() {
Skip(v2remotefail)
setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
@ -91,6 +92,7 @@ var _ = Describe("Podman rmi", func() {
})
It("podman rmi image with tags by ID cannot be done without force", func() {
Skip(v2remotefail)
setup := podmanTest.PodmanNoCache([]string{"images", "-q", ALPINE})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))

View File

@ -62,6 +62,7 @@ var _ = Describe("Podman run exit", func() {
})
It("podman run exit 50", func() {
Skip(v2remotefail)
result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(50))

View File

@ -68,6 +68,7 @@ var _ = Describe("Podman save", func() {
})
It("podman save bogus image", func() {
Skip(v2remotefail)
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "FOOBAR"})

View File

@ -40,6 +40,7 @@ var _ = Describe("Podman start", func() {
})
It("podman start single container by id", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -50,6 +51,7 @@ var _ = Describe("Podman start", func() {
})
It("podman container start single container by id", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -61,6 +63,7 @@ var _ = Describe("Podman start", func() {
})
It("podman container start single container by short id", func() {
Skip(v2remotefail)
session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -120,6 +123,7 @@ var _ = Describe("Podman start", func() {
})
It("podman failed to start with --rm should delete the container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"create", "-it", "--rm", ALPINE, "foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -132,6 +136,7 @@ var _ = Describe("Podman start", func() {
})
It("podman failed to start without --rm should NOT delete the container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"create", "-it", ALPINE, "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

View File

@ -184,6 +184,7 @@ var _ = Describe("Podman stop", func() {
})
It("podman stop latest containers", func() {
SkipIfRemote()
session := podmanTest.RunTopContainer("test1")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -197,6 +198,7 @@ var _ = Describe("Podman stop", func() {
})
It("podman stop all containers with one stopped", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("test1")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@ -216,6 +218,7 @@ var _ = Describe("Podman stop", func() {
})
It("podman stop all containers with one created", func() {
Skip(v2remotefail)
session := podmanTest.RunTopContainer("test1")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -34,6 +34,7 @@ var _ = Describe("podman system reset", func() {
})
It("podman system reset", func() {
Skip(v2remotefail)
// system reset will not remove additional store images, so need to grab length
session := podmanTest.Podman([]string{"rmi", "--force", "--all"})
@ -63,7 +64,7 @@ var _ = Describe("podman system reset", func() {
// If remote then the varlink service should have exited
// On local tests this is a noop
podmanTest.StartVarlink()
podmanTest.StartRemoteService()
session = podmanTest.Podman([]string{"images", "-n"})
session.WaitWithDefaultTimeout()

View File

@ -40,6 +40,7 @@ var _ = Describe("Podman untag", func() {
})
It("podman untag all", func() {
Skip(v2remotefail)
session := podmanTest.PodmanNoCache([]string{"untag", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

View File

@ -71,7 +71,7 @@ func (p *EndpointTestIntegration) startVarlink(useImageCache bool) {
os.MkdirAll("/run/podman", 0755)
}
varlinkEndpoint := p.VarlinkEndpoint
//p.SetVarlinkAddress(p.VarlinkEndpoint)
//p.SetVarlinkAddress(p.RemoteSocket)
args := []string{"varlink", "--timeout", "0", varlinkEndpoint}
podmanOptions := getVarlinkOptions(p, args)

View File

@ -39,9 +39,9 @@ type PodmanTest struct {
TempDir string
RemoteTest bool
RemotePodmanBinary string
VarlinkSession *os.Process
VarlinkEndpoint string
VarlinkCommand *exec.Cmd
RemoteSession *os.Process
RemoteSocket string
RemoteCommand *exec.Cmd
ImageCacheDir string
ImageCacheFS string
}
@ -71,9 +71,10 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
podmanBinary := p.PodmanBinary
if p.RemoteTest {
podmanBinary = p.RemotePodmanBinary
env = append(env, fmt.Sprintf("PODMAN_VARLINK_ADDRESS=%s", p.VarlinkEndpoint))
}
if p.RemoteTest {
podmanOptions = append([]string{"--remote", p.RemoteSocket}, podmanOptions...)
}
if env == nil {
fmt.Printf("Running: %s %s\n", podmanBinary, strings.Join(podmanOptions, " "))
} else {