mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 08:56:05 +08:00 
			
		
		
		
	Enable a bunch of remote tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
		@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -42,6 +40,7 @@ var _ = Describe("Podman attach", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman attach to non-running container", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", "-i", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
@ -52,6 +51,7 @@ var _ = Describe("Podman attach", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman container attach to non-running container", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-d", "-i", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
@ -87,6 +87,7 @@ var _ = Describe("Podman attach", func() {
 | 
			
		||||
		Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
 | 
			
		||||
	})
 | 
			
		||||
	It("podman attach to the latest container", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", ALPINE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -40,6 +38,7 @@ var _ = Describe("Podman build", func() {
 | 
			
		||||
	// Let's first do the most simple build possible to make sure stuff is
 | 
			
		||||
	// happy and then clean up after ourselves to make sure that works too.
 | 
			
		||||
	It("podman build and remove basic alpine", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.PodmanNoCache([]string{"build", "build/basicalpine"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
@ -69,6 +68,7 @@ var _ = Describe("Podman build", func() {
 | 
			
		||||
	// Check that builds with different values for the squash options
 | 
			
		||||
	// create the appropriate number of layers, then clean up after.
 | 
			
		||||
	It("podman build basic alpine with squash", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.PodmanNoCache([]string{"build", "-f", "build/squash/Dockerfile.squash-a", "-t", "test-squash-a:latest", "build/squash"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
@ -154,6 +154,7 @@ var _ = Describe("Podman build", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman build basic alpine and print id to external file", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
 | 
			
		||||
		// Switch to temp dir and restore it afterwards
 | 
			
		||||
		cwd, err := os.Getwd()
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,7 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/containers/libpod/v2/libpod/define"
 | 
			
		||||
	"github.com/containers/libpod/v2/pkg/cgroups"
 | 
			
		||||
	"github.com/containers/libpod/v2/pkg/inspect"
 | 
			
		||||
	"github.com/containers/libpod/v2/pkg/rootless"
 | 
			
		||||
	. "github.com/containers/libpod/v2/test/utils"
 | 
			
		||||
@ -599,3 +600,21 @@ func SkipIfNotFedora() {
 | 
			
		||||
func isRootless() bool {
 | 
			
		||||
	return os.Geteuid() != 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SkipIfCgroupV1() {
 | 
			
		||||
	cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
 | 
			
		||||
	Expect(err).To(BeNil())
 | 
			
		||||
 | 
			
		||||
	if !cgroupsv2 {
 | 
			
		||||
		Skip("Skip on systems with cgroup V1 systems")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SkipIfCgroupV2() {
 | 
			
		||||
	cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
 | 
			
		||||
	Expect(err).To(BeNil())
 | 
			
		||||
 | 
			
		||||
	if cgroupsv2 {
 | 
			
		||||
		Skip("Skip on systems with cgroup V2 systems")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
 | 
			
		||||
@ -214,5 +214,3 @@ func (p *PodmanTestIntegration) DelayForService() error {
 | 
			
		||||
 | 
			
		||||
func populateCache(podman *PodmanTestIntegration) {}
 | 
			
		||||
func removeCache()                                {}
 | 
			
		||||
func SkipIfCgroupV1()                             {}
 | 
			
		||||
func SkipIfCgroupV2()                             {}
 | 
			
		||||
 | 
			
		||||
@ -9,32 +9,12 @@ import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/containers/libpod/v2/pkg/cgroups"
 | 
			
		||||
	. "github.com/onsi/ginkgo"
 | 
			
		||||
	. "github.com/onsi/gomega"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func SkipIfRemote() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SkipIfCgroupV1() {
 | 
			
		||||
	cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
 | 
			
		||||
	Expect(err).To(BeNil())
 | 
			
		||||
 | 
			
		||||
	if !cgroupsv2 {
 | 
			
		||||
		Skip("Skip on systems with cgroup V1 systems")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SkipIfCgroupV2() {
 | 
			
		||||
	cgroupsv2, err := cgroups.IsCgroup2UnifiedMode()
 | 
			
		||||
	Expect(err).To(BeNil())
 | 
			
		||||
 | 
			
		||||
	if cgroupsv2 {
 | 
			
		||||
		Skip("Skip on systems with cgroup V2 systems")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SkipIfRootless() {
 | 
			
		||||
	if os.Geteuid() != 0 {
 | 
			
		||||
		Skip("This function is not enabled for rootless podman")
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -125,6 +123,7 @@ var _ = Describe("Podman load", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman load directory", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		outdir := filepath.Join(podmanTest.TempDir, "alpine")
 | 
			
		||||
 | 
			
		||||
		save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE})
 | 
			
		||||
@ -228,6 +227,7 @@ var _ = Describe("Podman load", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman load localhost registry from dir", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		outfile := filepath.Join(podmanTest.TempDir, "load")
 | 
			
		||||
 | 
			
		||||
		setup := podmanTest.PodmanNoCache([]string{"tag", BB, "hello:world"})
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -237,6 +235,7 @@ var _ = Describe("Podman pull", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman pull from docker-archive", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		podmanTest.RestoreArtifact(ALPINE)
 | 
			
		||||
		tarfn := filepath.Join(podmanTest.TempDir, "alp.tar")
 | 
			
		||||
		session := podmanTest.PodmanNoCache([]string{"save", "-o", tarfn, "alpine"})
 | 
			
		||||
@ -255,6 +254,7 @@ var _ = Describe("Podman pull", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman pull from oci-archive", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		podmanTest.RestoreArtifact(ALPINE)
 | 
			
		||||
		tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar")
 | 
			
		||||
		session := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"})
 | 
			
		||||
@ -273,6 +273,7 @@ var _ = Describe("Podman pull", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman pull from local directory", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		podmanTest.RestoreArtifact(ALPINE)
 | 
			
		||||
		dirpath := filepath.Join(podmanTest.TempDir, "alpine")
 | 
			
		||||
		os.MkdirAll(dirpath, os.ModePerm)
 | 
			
		||||
@ -297,6 +298,7 @@ var _ = Describe("Podman pull", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman pull from local OCI directory", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		podmanTest.RestoreArtifact(ALPINE)
 | 
			
		||||
		dirpath := filepath.Join(podmanTest.TempDir, "alpine")
 | 
			
		||||
		os.MkdirAll(dirpath, os.ModePerm)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -160,10 +158,10 @@ var _ = Describe("Podman run", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run a container with --init", func() {
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--init", ALPINE, "ls"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", "--init", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "-l"})
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "test"})
 | 
			
		||||
		result.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(result.ExitCode()).To(Equal(0))
 | 
			
		||||
		conData := result.InspectContainerToJSON()
 | 
			
		||||
@ -172,10 +170,10 @@ var _ = Describe("Podman run", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run a container with --init and --init-path", func() {
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--init", "--init-path", "/usr/libexec/podman/catatonit", ALPINE, "ls"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", "--init", "--init-path", "/usr/libexec/podman/catatonit", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "-l"})
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "test"})
 | 
			
		||||
		result.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(result.ExitCode()).To(Equal(0))
 | 
			
		||||
		conData := result.InspectContainerToJSON()
 | 
			
		||||
@ -184,10 +182,10 @@ var _ = Describe("Podman run", func() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run a container without --init", func() {
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "-l"})
 | 
			
		||||
		result := podmanTest.Podman([]string{"inspect", "test"})
 | 
			
		||||
		result.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(result.ExitCode()).To(Equal(0))
 | 
			
		||||
		conData := result.InspectContainerToJSON()
 | 
			
		||||
@ -259,11 +257,14 @@ var _ = Describe("Podman run", func() {
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		Expect(session.OutputToString()).To(ContainSubstring("00000000a80425fb"))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run user capabilities test with image", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		dockerfile := `FROM busybox
 | 
			
		||||
USER bin`
 | 
			
		||||
		podmanTest.BuildImage(dockerfile, "test", "false")
 | 
			
		||||
		session = podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapBnd", "/proc/self/status"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", "test", "grep", "CapBnd", "/proc/self/status"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		Expect(session.OutputToString()).To(ContainSubstring("00000000a80425fb"))
 | 
			
		||||
@ -510,6 +511,7 @@ USER bin`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run with secrets", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		containersDir := filepath.Join(podmanTest.TempDir, "containers")
 | 
			
		||||
		err := os.MkdirAll(containersDir, 0755)
 | 
			
		||||
		Expect(err).To(BeNil())
 | 
			
		||||
@ -674,6 +676,7 @@ USER bin`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run with built-in volume image", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--rm", redis, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
@ -820,16 +823,22 @@ USER mail`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run --rm should work", func() {
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Equal(0))
 | 
			
		||||
		session = podmanTest.Podman([]string{"wait", "test"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError())
 | 
			
		||||
 | 
			
		||||
		numContainers := podmanTest.NumberOfContainers()
 | 
			
		||||
		Expect(numContainers).To(Equal(0))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run --rm failed container should delete itself", func() {
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "foo"})
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", "--rm", ALPINE, "foo"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError())
 | 
			
		||||
		session = podmanTest.Podman([]string{"wait", "test"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError())
 | 
			
		||||
 | 
			
		||||
@ -841,6 +850,10 @@ USER mail`
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", ALPINE, "foo"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError())
 | 
			
		||||
		// If remote we could have a race condition
 | 
			
		||||
		session = podmanTest.Podman([]string{"wait", "test"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session).To(ExitWithError())
 | 
			
		||||
 | 
			
		||||
		numContainers := podmanTest.NumberOfContainers()
 | 
			
		||||
		Expect(numContainers).To(Equal(1))
 | 
			
		||||
@ -881,7 +894,7 @@ USER mail`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run with restart-policy always restarts containers", func() {
 | 
			
		||||
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		testDir := filepath.Join(podmanTest.RunRoot, "restart-test")
 | 
			
		||||
		err := os.MkdirAll(testDir, 0755)
 | 
			
		||||
		Expect(err).To(BeNil())
 | 
			
		||||
@ -995,14 +1008,12 @@ USER mail`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run should fail with nonexist authfile", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--authfile", "/tmp/nonexist", ALPINE, "ls"})
 | 
			
		||||
		session.WaitWithDefaultTimeout()
 | 
			
		||||
		Expect(session.ExitCode()).To(Not(Equal(0)))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman run --device-cgroup-rule", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		SkipIfRootless()
 | 
			
		||||
		deviceCgroupRule := "c 42:* rwm"
 | 
			
		||||
		session := podmanTest.Podman([]string{"run", "--name", "test", "-d", "--device-cgroup-rule", deviceCgroupRule, ALPINE, "top"})
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
// +build !remote
 | 
			
		||||
 | 
			
		||||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -229,6 +227,7 @@ registries = ['{{.Host}}:{{.Port}}']`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman search attempts HTTP if registry is in registries.insecure and force secure is false", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		if podmanTest.Host.Arch == "ppc64le" {
 | 
			
		||||
			Skip("No registry image for ppc64le")
 | 
			
		||||
		}
 | 
			
		||||
@ -269,6 +268,7 @@ registries = ['{{.Host}}:{{.Port}}']`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman search doesn't attempt HTTP if force secure is true", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		if podmanTest.Host.Arch == "ppc64le" {
 | 
			
		||||
			Skip("No registry image for ppc64le")
 | 
			
		||||
		}
 | 
			
		||||
@ -307,6 +307,7 @@ registries = ['{{.Host}}:{{.Port}}']`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman search doesn't attempt HTTP if registry is not listed as insecure", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		if podmanTest.Host.Arch == "ppc64le" {
 | 
			
		||||
			Skip("No registry image for ppc64le")
 | 
			
		||||
		}
 | 
			
		||||
@ -345,6 +346,7 @@ registries = ['{{.Host}}:{{.Port}}']`
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	It("podman search doesn't attempt HTTP if one registry is not listed as insecure", func() {
 | 
			
		||||
		SkipIfRemote()
 | 
			
		||||
		if podmanTest.Host.Arch == "ppc64le" {
 | 
			
		||||
			Skip("No registry image for ppc64le")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user