Merge pull request #12871 from jwhonce/issues/12866
Engine.Remote from containers.conf
This commit is contained in:
commit
00a12a0b83
1
Makefile
1
Makefile
|
|
@ -554,6 +554,7 @@ test: localunit localintegration remoteintegration localsystem remotesystem ##
|
||||||
|
|
||||||
.PHONY: ginkgo-run
|
.PHONY: ginkgo-run
|
||||||
ginkgo-run:
|
ginkgo-run:
|
||||||
|
$(GOBIN)/ginkgo version
|
||||||
$(GOBIN)/ginkgo -v $(TESTFLAGS) -tags "$(TAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 -debug test/e2e/. $(HACK)
|
$(GOBIN)/ginkgo -v $(TESTFLAGS) -tags "$(TAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 -debug test/e2e/. $(HACK)
|
||||||
|
|
||||||
.PHONY: ginkgo
|
.PHONY: ginkgo
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,12 @@ func newPodmanConfig() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg, err := config.NewConfig("")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprint(os.Stderr, "Failed to obtain podman configuration: "+err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
var mode entities.EngineMode
|
var mode entities.EngineMode
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin", "windows":
|
case "darwin", "windows":
|
||||||
|
|
@ -64,16 +70,15 @@ func newPodmanConfig() {
|
||||||
} else {
|
} else {
|
||||||
mode = entities.TunnelMode
|
mode = entities.TunnelMode
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "%s is not a supported OS", runtime.GOOS)
|
fmt.Fprintf(os.Stderr, "%s is not a supported OS", runtime.GOOS)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := config.NewConfig("")
|
// If EngineMode==Tunnel has not been set on the command line or environment
|
||||||
if err != nil {
|
// but has been set in containers.conf...
|
||||||
fmt.Fprint(os.Stderr, "Failed to obtain podman configuration: "+err.Error())
|
if mode == entities.ABIMode && cfg.Engine.Remote {
|
||||||
os.Exit(1)
|
mode = entities.TunnelMode
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Network.NetworkConfigDir = cfg.Network.CNIPluginDirs[0]
|
cfg.Network.NetworkConfigDir = cfg.Network.CNIPluginDirs[0]
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@ import (
|
||||||
. "github.com/containers/podman/v4/test/utils"
|
. "github.com/containers/podman/v4/test/utils"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
. "github.com/onsi/gomega/gbytes"
|
||||||
. "github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Podman run", func() {
|
var _ = Describe("Verify podman containers.conf usage", func() {
|
||||||
var (
|
var (
|
||||||
tempdir string
|
tempdir string
|
||||||
err error
|
err error
|
||||||
|
|
@ -43,9 +44,9 @@ var _ = Describe("Podman run", func() {
|
||||||
os.Unsetenv("CONTAINERS_CONF")
|
os.Unsetenv("CONTAINERS_CONF")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run limits test", func() {
|
It("limits test", func() {
|
||||||
SkipIfRootlessCgroupsV1("Setting limits not supported on cgroupv1 for rootless users")
|
SkipIfRootlessCgroupsV1("Setting limits not supported on cgroupv1 for rootless users")
|
||||||
//containers.conf is set to "nofile=500:500"
|
// containers.conf is set to "nofile=500:500"
|
||||||
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
|
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
@ -57,33 +58,36 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("2048"))
|
Expect(session.OutputToString()).To(ContainSubstring("2048"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run with containers.conf having additional env", func() {
|
It("having additional env", func() {
|
||||||
//containers.conf default env includes foo
|
// containers.conf default env includes foo
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "printenv"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "printenv"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("foo=bar"))
|
Expect(session.OutputToString()).To(ContainSubstring("foo=bar"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run with additional devices", func() {
|
It("additional devices", func() {
|
||||||
//containers.conf devices includes notone
|
// containers.conf devices includes notone
|
||||||
session := podmanTest.Podman([]string{"run", "--device", "/dev/null:/dev/bar", ALPINE, "ls", "/dev"})
|
session := podmanTest.Podman([]string{"run", "--device", "/dev/null:/dev/bar", ALPINE, "ls", "/dev"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("bar"))
|
Expect(session.OutputToString()).To(
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("notone"))
|
And(
|
||||||
|
ContainSubstring("bar"),
|
||||||
|
ContainSubstring("notone"),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run shm-size", func() {
|
It("shm-size", func() {
|
||||||
//containers.conf default sets shm-size=201k, which ends up as 200k
|
// containers.conf default sets shm-size=201k, which ends up as 200k
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("size=200k"))
|
Expect(session.OutputToString()).To(ContainSubstring("size=200k"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman Capabilities in containers.conf", func() {
|
It("add capabilities", func() {
|
||||||
SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1")
|
SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1")
|
||||||
cap := podmanTest.Podman([]string{"run", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
cap := podmanTest.Podman([]string{"run", ALPINE, "grep", "CapEff", "/proc/self/status"})
|
||||||
cap.WaitWithDefaultTimeout()
|
cap.WaitWithDefaultTimeout()
|
||||||
Expect(cap).Should(Exit(0))
|
Expect(cap).Should(Exit(0))
|
||||||
|
|
@ -98,17 +102,20 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).ToNot(Equal(cap.OutputToString()))
|
Expect(session.OutputToString()).ToNot(Equal(cap.OutputToString()))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman Regular capabilities", func() {
|
It("regular capabilities", func() {
|
||||||
setup := podmanTest.RunTopContainer("test1")
|
setup := podmanTest.RunTopContainer("test1")
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
result := podmanTest.Podman([]string{"top", "test1", "capeff"})
|
result := podmanTest.Podman([]string{"top", "test1", "capeff"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToString()).To(ContainSubstring("SYS_CHROOT"))
|
Expect(result.Out.Contents()).To(
|
||||||
Expect(result.OutputToString()).To(ContainSubstring("NET_RAW"))
|
And(
|
||||||
|
ContainSubstring("SYS_CHROOT"),
|
||||||
|
ContainSubstring("NET_RAW"),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman drop capabilities", func() {
|
It("drop capabilities", func() {
|
||||||
os.Setenv("CONTAINERS_CONF", "config/containers-caps.conf")
|
os.Setenv("CONTAINERS_CONF", "config/containers-caps.conf")
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
|
|
@ -118,8 +125,11 @@ var _ = Describe("Podman run", func() {
|
||||||
result := podmanTest.Podman([]string{"container", "top", "test1", "capeff"})
|
result := podmanTest.Podman([]string{"container", "top", "test1", "capeff"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToString()).ToNot(ContainSubstring("SYS_CHROOT"))
|
Expect(result.Out.Contents()).ToNot(
|
||||||
Expect(result.OutputToString()).ToNot(ContainSubstring("NET_RAW"))
|
And(
|
||||||
|
ContainSubstring("SYS_CHROOT"),
|
||||||
|
ContainSubstring("NET_RAW"),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
verifyNSHandling := func(nspath, option string) {
|
verifyNSHandling := func(nspath, option string) {
|
||||||
|
|
@ -128,7 +138,7 @@ var _ = Describe("Podman run", func() {
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
}
|
}
|
||||||
//containers.conf default ipcns to default to host
|
// containers.conf default ipcns to default to host
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "ls", "-l", nspath})
|
session := podmanTest.Podman([]string{"run", ALPINE, "ls", "-l", nspath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
@ -137,7 +147,7 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
cmd := exec.Command("ls", "-l", nspath)
|
cmd := exec.Command("ls", "-l", nspath)
|
||||||
res, err := cmd.Output()
|
res, err := cmd.Output()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
fields = strings.Split(string(res), " ")
|
fields = strings.Split(string(res), " ")
|
||||||
hostNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
|
hostNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
|
||||||
Expect(hostNS).To(Equal(ctrNS))
|
Expect(hostNS).To(Equal(ctrNS))
|
||||||
|
|
@ -148,23 +158,23 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(hostNS).ToNot(Equal(ctrNS))
|
Expect(hostNS).ToNot(Equal(ctrNS))
|
||||||
}
|
}
|
||||||
|
|
||||||
It("podman compare netns", func() {
|
It("netns", func() {
|
||||||
verifyNSHandling("/proc/self/ns/net", "--network")
|
verifyNSHandling("/proc/self/ns/net", "--network")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman compare ipcns", func() {
|
It("ipcns", func() {
|
||||||
verifyNSHandling("/proc/self/ns/ipc", "--ipc")
|
verifyNSHandling("/proc/self/ns/ipc", "--ipc")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman compare utsns", func() {
|
It("utsns", func() {
|
||||||
verifyNSHandling("/proc/self/ns/uts", "--uts")
|
verifyNSHandling("/proc/self/ns/uts", "--uts")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman compare pidns", func() {
|
It("pidns", func() {
|
||||||
verifyNSHandling("/proc/self/ns/pid", "--pid")
|
verifyNSHandling("/proc/self/ns/pid", "--pid")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman compare cgroupns", func() {
|
It("cgroupns", func() {
|
||||||
verifyNSHandling("/proc/self/ns/cgroup", "--cgroupns")
|
verifyNSHandling("/proc/self/ns/cgroup", "--cgroupns")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -185,17 +195,17 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid))
|
cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", fmt.Sprintf("CONTAINER_ID_FULL=%s", cid))
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(string(out)).To(ContainSubstring("alpine"))
|
Expect(out).To(ContainSubstring("alpine"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman containers.conf additionalvolumes", func() {
|
It("add volumes", func() {
|
||||||
conffile := filepath.Join(podmanTest.TempDir, "container.conf")
|
conffile := filepath.Join(podmanTest.TempDir, "container.conf")
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[containers]\nvolumes=[\"%s:%s:Z\",]\n", tempdir, tempdir)), 0755)
|
err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[containers]\nvolumes=[\"%s:%s:Z\",]\n", tempdir, tempdir)), 0755)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
os.Setenv("CONTAINERS_CONF", conffile)
|
os.Setenv("CONTAINERS_CONF", conffile)
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
|
|
@ -206,8 +216,8 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf sysctl test", func() {
|
It("sysctl test", func() {
|
||||||
//containers.conf is set to "net.ipv4.ping_group_range=0 1000"
|
// containers.conf is set to "net.ipv4.ping_group_range=0 1000"
|
||||||
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/sys/net/ipv4/ping_group_range"})
|
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/sys/net/ipv4/ping_group_range"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
@ -220,47 +230,49 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).ToNot((ContainSubstring("1000")))
|
Expect(session.OutputToString()).ToNot((ContainSubstring("1000")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf search domain", func() {
|
It("search domain", func() {
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com")))
|
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run add dns server", func() {
|
It("add dns server", func() {
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4")))
|
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run add dns option", func() {
|
It("add dns option", func() {
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug")))
|
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf remove all search domain", func() {
|
It("remove all search domain", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
|
session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
|
Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run use containers.conf search domain", func() {
|
It("add search domain", func() {
|
||||||
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
|
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("foobar.com"))
|
Expect(session.Out.Contents()).To(
|
||||||
|
And(
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4"))
|
ContainSubstring("foobar.com"),
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("debug"))
|
ContainSubstring("1.2.3.4"),
|
||||||
|
ContainSubstring("debug"),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf timezone", func() {
|
It("add timezone", func() {
|
||||||
//containers.conf timezone set to Pacific/Honolulu
|
// containers.conf timezone set to Pacific/Honolulu
|
||||||
session := podmanTest.Podman([]string{"run", "--tz", "", ALPINE, "date", "+'%H %Z'"})
|
session := podmanTest.Podman([]string{"run", "--tz", "", ALPINE, "date", "+'%H %Z'"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
@ -273,8 +285,8 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("EST"))
|
Expect(session.OutputToString()).To(ContainSubstring("EST"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf umask", func() {
|
It("add umask", func() {
|
||||||
//containers.conf umask set to 0002
|
// containers.conf umask set to 0002
|
||||||
if !strings.Contains(podmanTest.OCIRuntime, "crun") {
|
if !strings.Contains(podmanTest.OCIRuntime, "crun") {
|
||||||
Skip("Test only works on crun")
|
Skip("Test only works on crun")
|
||||||
}
|
}
|
||||||
|
|
@ -285,13 +297,13 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).To(Equal("0002"))
|
Expect(session.OutputToString()).To(Equal("0002"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman set network cmd options slirp options to allow host loopback", func() {
|
It("network slirp options to allow host loopback", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns", ALPINE, "ping", "-c1", "10.0.2.2"})
|
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns", ALPINE, "ping", "-c1", "10.0.2.2"})
|
||||||
session.Wait(30)
|
session.Wait(30)
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman-remote test localcontainers.conf versus remote containers.conf", func() {
|
It("podman-remote test localcontainers.conf", func() {
|
||||||
if !IsRemote() {
|
if !IsRemote() {
|
||||||
Skip("this test is only for remote")
|
Skip("this test is only for remote")
|
||||||
}
|
}
|
||||||
|
|
@ -309,34 +321,41 @@ var _ = Describe("Podman run", func() {
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
|
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search")))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("foobar.com"))
|
Expect(session.Out.Contents()).To(
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("1.2.3.4"))
|
And(
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("debug"))
|
ContainSubstring("foobar.com"),
|
||||||
|
ContainSubstring("1.2.3.4"),
|
||||||
|
ContainSubstring("debug"),
|
||||||
|
))
|
||||||
|
|
||||||
// sysctls
|
// sysctls
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/sys/net/ipv4/ping_group_range"})
|
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "cat", "/proc/sys/net/ipv4/ping_group_range"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("1000"))
|
Expect(session.Out.Contents()).To(ContainSubstring("1000"))
|
||||||
|
|
||||||
// shm-size
|
// shm-size
|
||||||
session = podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
|
session = podmanTest.Podman([]string{"run", ALPINE, "grep", "shm", "/proc/self/mounts"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("size=200k"))
|
Expect(session.Out.Contents()).To(ContainSubstring("size=200k"))
|
||||||
|
|
||||||
// ulimits
|
// ulimits
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
|
session = podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("500"))
|
Expect(session.Out.Contents()).To(ContainSubstring("500"))
|
||||||
|
|
||||||
// Configuration that comes from remote client
|
// Configuration that comes from remote client
|
||||||
// Timezone
|
// Timezone
|
||||||
session = podmanTest.Podman([]string{"run", ALPINE, "date", "+'%H %Z'"})
|
session = podmanTest.Podman([]string{"run", ALPINE, "date", "+'%H %Z'"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(Or(ContainSubstring("EST"), ContainSubstring("EDT")))
|
Expect(session.Out.Contents()).To(
|
||||||
|
Or(
|
||||||
|
ContainSubstring("EST"),
|
||||||
|
ContainSubstring("EDT"),
|
||||||
|
))
|
||||||
|
|
||||||
// Umask
|
// Umask
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"})
|
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "sh", "-c", "umask"})
|
||||||
|
|
@ -345,48 +364,48 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).To(Equal("0022"))
|
Expect(session.OutputToString()).To(Equal("0022"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run containers.conf annotations test", func() {
|
It("add annotations", func() {
|
||||||
//containers.conf is set to "run.oci.keep_original_groups=1"
|
// containers.conf is set to "run.oci.keep_original_groups=1"
|
||||||
session := podmanTest.Podman([]string{"create", "--rm", "--name", "test", fedoraMinimal})
|
session := podmanTest.Podman([]string{"create", "--rm", "--name", "test", fedoraMinimal})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .Config.Annotations }}", "test"})
|
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .Config.Annotations }}", "test"})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect.OutputToString()).To(ContainSubstring("run.oci.keep_original_groups:1"))
|
Expect(inspect.Out.Contents()).To(ContainSubstring("run.oci.keep_original_groups:1"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run with --add-host and no-hosts=true fails", func() {
|
It("--add-host and no-hosts=true fails", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", ALPINE, "top"})
|
session := podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", ALPINE, "top"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError())
|
||||||
Expect(session.ErrorToString()).To(ContainSubstring("--no-hosts and --add-host cannot be set together"))
|
Expect(session.Err.Contents()).To(ContainSubstring("--no-hosts and --add-host cannot be set together"))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", "--no-hosts=false", ALPINE, "top"})
|
session = podmanTest.Podman([]string{"run", "-dt", "--add-host", "test1:127.0.0.1", "--no-hosts=false", ALPINE, "top"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run with no-hosts=true /etc/hosts does not include hostname", func() {
|
It("no-hosts=true /etc/hosts does not include hostname", func() {
|
||||||
session := podmanTest.Podman([]string{"run", "--rm", "--name", "test", ALPINE, "cat", "/etc/hosts"})
|
session := podmanTest.Podman([]string{"run", "--rm", "--name", "test", ALPINE, "cat", "/etc/hosts"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(Not(ContainSubstring("test")))
|
Expect(session.Out.Contents()).ToNot(ContainSubstring("test"))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--rm", "--name", "test", "--no-hosts=false", ALPINE, "cat", "/etc/hosts"})
|
session = podmanTest.Podman([]string{"run", "--rm", "--name", "test", "--no-hosts=false", ALPINE, "cat", "/etc/hosts"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("test"))
|
Expect(session.Out.Contents()).To(ContainSubstring("test"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman info seccomp profile path", func() {
|
It("seccomp profile path", func() {
|
||||||
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
||||||
os.Setenv("CONTAINERS_CONF", configPath)
|
os.Setenv("CONTAINERS_CONF", configPath)
|
||||||
|
|
||||||
profile := filepath.Join(podmanTest.TempDir, "seccomp.json")
|
profile := filepath.Join(podmanTest.TempDir, "seccomp.json")
|
||||||
containersConf := []byte(fmt.Sprintf("[containers]\nseccomp_profile=\"%s\"", profile))
|
containersConf := []byte(fmt.Sprintf("[containers]\nseccomp_profile=\"%s\"", profile))
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
|
|
@ -398,7 +417,7 @@ var _ = Describe("Podman run", func() {
|
||||||
Expect(session.OutputToString()).To(Equal(profile))
|
Expect(session.OutputToString()).To(Equal(profile))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman info image_copy_tmp_dir", func() {
|
It("add image_copy_tmp_dir", func() {
|
||||||
session := podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
session := podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
@ -409,7 +428,7 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
containersConf := []byte("[engine]\nimage_copy_tmp_dir=\"/foobar\"")
|
containersConf := []byte("[engine]\nimage_copy_tmp_dir=\"/foobar\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
|
|
@ -422,7 +441,7 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage\"")
|
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
}
|
}
|
||||||
|
|
@ -430,11 +449,11 @@ var _ = Describe("Podman run", func() {
|
||||||
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("containers/storage/tmp"))
|
Expect(session.Out.Contents()).To(ContainSubstring("containers/storage/tmp"))
|
||||||
|
|
||||||
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
|
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
}
|
}
|
||||||
|
|
@ -442,18 +461,20 @@ var _ = Describe("Podman run", func() {
|
||||||
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.ErrorToString()).To(ContainSubstring("invalid image_copy_tmp_dir"))
|
Expect(session.Err.Contents()).To(ContainSubstring("invalid image_copy_tmp_dir"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman system service --help shows (default 20)", func() {
|
// FIXME not sure why this is here
|
||||||
SkipIfRemote("this test is only for local")
|
It("system service --help shows (default 20)", func() {
|
||||||
|
SkipIfRemote("system service is not supported on clients")
|
||||||
|
|
||||||
result := podmanTest.Podman([]string{"system", "service", "--help"})
|
result := podmanTest.Podman([]string{"system", "service", "--help"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToString()).To(ContainSubstring("(default 1234)"))
|
Expect(result.Out.Contents()).To(ContainSubstring("(default 1234)"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman bad infra_image name in containers.conf", func() {
|
It("bad infra_image name", func() {
|
||||||
infra1 := "i.do/not/exist:image"
|
infra1 := "i.do/not/exist:image"
|
||||||
infra2 := "i.still.do/not/exist:image"
|
infra2 := "i.still.do/not/exist:image"
|
||||||
errorString := "initializing source docker://" + infra1
|
errorString := "initializing source docker://" + infra1
|
||||||
|
|
@ -463,7 +484,7 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
containersConf := []byte("[engine]\ninfra_image=\"" + infra1 + "\"")
|
containersConf := []byte("[engine]\ninfra_image=\"" + infra1 + "\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
podmanTest.RestartRemoteService()
|
podmanTest.RestartRemoteService()
|
||||||
|
|
@ -472,27 +493,52 @@ var _ = Describe("Podman run", func() {
|
||||||
result := podmanTest.Podman([]string{"pod", "create", "--infra-image", infra2})
|
result := podmanTest.Podman([]string{"pod", "create", "--infra-image", infra2})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(125))
|
Expect(result).Should(Exit(125))
|
||||||
Expect(result.ErrorToString()).To(ContainSubstring(error2String))
|
Expect(result.Err.Contents()).To(ContainSubstring(error2String))
|
||||||
|
|
||||||
result = podmanTest.Podman([]string{"pod", "create"})
|
result = podmanTest.Podman([]string{"pod", "create"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(125))
|
Expect(result).Should(Exit(125))
|
||||||
Expect(result.ErrorToString()).To(ContainSubstring(errorString))
|
Expect(result.Err.Contents()).To(ContainSubstring(errorString))
|
||||||
|
|
||||||
result = podmanTest.Podman([]string{"create", "--pod", "new:pod1", ALPINE})
|
result = podmanTest.Podman([]string{"create", "--pod", "new:pod1", ALPINE})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(125))
|
Expect(result).Should(Exit(125))
|
||||||
Expect(result.ErrorToString()).To(ContainSubstring(errorString))
|
Expect(result.Err.Contents()).To(ContainSubstring(errorString))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("set .engine.remote=true", func() {
|
||||||
|
SkipIfRemote("only meaningful when running ABI/local")
|
||||||
|
|
||||||
|
// Need to restore CONTAINERS_CONF or AfterEach() will fail
|
||||||
|
if path, found := os.LookupEnv("CONTAINERS_CONF"); found {
|
||||||
|
defer os.Setenv("CONTAINERS_CONF", path)
|
||||||
|
}
|
||||||
|
|
||||||
|
configPath := filepath.Join(podmanTest.TempDir, "containers-engine-remote.conf")
|
||||||
|
os.Setenv("CONTAINERS_CONF", configPath)
|
||||||
|
defer os.Remove(configPath)
|
||||||
|
|
||||||
|
err := ioutil.WriteFile(configPath, []byte("[engine]\nremote=true"), os.ModePerm)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// podmanTest.Podman() cannot be used as it was initialized remote==false
|
||||||
|
cmd := exec.Command(podmanTest.PodmanBinary, "info", "--format", "{{.Host.ServiceIsRemote}}")
|
||||||
|
session, err := Start(cmd, GinkgoWriter, GinkgoWriter)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
description := "Should have failed as there is no running remote API service available."
|
||||||
|
Eventually(session, DefaultWaitTimeout).Should(Exit(125), description)
|
||||||
|
Expect(session.Err).Should(Say("Error: unable to connect to Podman socket"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman containers.conf cgroups=disabled", func() {
|
It("podman containers.conf cgroups=disabled", func() {
|
||||||
if !strings.Contains(podmanTest.OCIRuntime, "crun") {
|
if !strings.Contains(podmanTest.OCIRuntime, "crun") {
|
||||||
Skip("FIXME: requires crun")
|
Skip("FIXME: requires crun")
|
||||||
}
|
}
|
||||||
conffile := filepath.Join(podmanTest.TempDir, "container.conf")
|
|
||||||
|
|
||||||
|
conffile := filepath.Join(podmanTest.TempDir, "container.conf")
|
||||||
err := ioutil.WriteFile(conffile, []byte("[containers]\ncgroups=\"disabled\"\n"), 0755)
|
err := ioutil.WriteFile(conffile, []byte("[containers]\ncgroups=\"disabled\"\n"), 0755)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
result := podmanTest.Podman([]string{"create", ALPINE, "true"})
|
result := podmanTest.Podman([]string{"create", ALPINE, "true"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
@ -500,7 +546,7 @@ var _ = Describe("Podman run", func() {
|
||||||
|
|
||||||
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
|
inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .HostConfig.Cgroups }}", result.OutputToString()})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect.OutputToString()).To(Not(Equal("disabled")))
|
Expect(inspect.OutputToString()).ToNot(Equal("disabled"))
|
||||||
|
|
||||||
os.Setenv("CONTAINERS_CONF", conffile)
|
os.Setenv("CONTAINERS_CONF", conffile)
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
|
|
@ -514,5 +560,4 @@ var _ = Describe("Podman run", func() {
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect.OutputToString()).To(Equal("disabled"))
|
Expect(inspect.OutputToString()).To(Equal("disabled"))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue