mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #20646 from edsantiago/while_ed_was_sleeping
CI: e2e: fix a smattering of test bugs that slipped in
This commit is contained in:
@ -31,31 +31,43 @@ var _ = Describe("Podman create", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman create container based on a remote image", func() {
|
It("podman create container based on a remote image", func() {
|
||||||
session := podmanTest.Podman([]string{"create", "-q", BB_GLIBC, "ls"})
|
session := podmanTest.Podman([]string{"create", BB_GLIBC, "ls"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull " + BB_GLIBC))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
||||||
|
|
||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman container create container based on a remote image", func() {
|
It("podman container create --tls-verify", func() {
|
||||||
containerCreate := podmanTest.Podman([]string{"container", "create", "-q", BB_GLIBC, "ls"})
|
port := "5040"
|
||||||
containerCreate.WaitWithDefaultTimeout()
|
lock := GetPortLock(port)
|
||||||
Expect(containerCreate).Should(ExitCleanly())
|
|
||||||
|
|
||||||
lock := GetPortLock("5000")
|
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", port + ":5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
||||||
Skip("Cannot start docker registry.")
|
Fail("Cannot start docker registry.")
|
||||||
}
|
}
|
||||||
|
|
||||||
create := podmanTest.Podman([]string{"container", "create", "--tls-verify=false", ALPINE})
|
pushedImage := "localhost:" + port + "/pushed" + strings.ToLower(RandomString(5)) + ":" + RandomString(8)
|
||||||
|
push := podmanTest.Podman([]string{"push", "--tls-verify=false", ALPINE, pushedImage})
|
||||||
|
push.WaitWithDefaultTimeout()
|
||||||
|
Expect(push).To(Exit(0))
|
||||||
|
Expect(push.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
||||||
|
|
||||||
|
create := podmanTest.Podman([]string{"container", "create", pushedImage})
|
||||||
create.WaitWithDefaultTimeout()
|
create.WaitWithDefaultTimeout()
|
||||||
Expect(create).Should(ExitCleanly())
|
Expect(create).Should(Exit(125))
|
||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(3))
|
Expect(create.ErrorToString()).To(ContainSubstring("pinging container registry localhost:" + port))
|
||||||
|
Expect(create.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client"))
|
||||||
|
|
||||||
|
create = podmanTest.Podman([]string{"create", "--tls-verify=false", pushedImage, "echo", "got here"})
|
||||||
|
create.WaitWithDefaultTimeout()
|
||||||
|
Expect(create).Should(Exit(0))
|
||||||
|
Expect(create.ErrorToString()).To(ContainSubstring("Trying to pull " + pushedImage))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman create using short options", func() {
|
It("podman create using short options", func() {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -190,7 +189,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(session.OutputToString()).To(ContainSubstring("/etc/hosts"))
|
Expect(session.OutputToString()).To(ContainSubstring("/etc/hosts"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman create pod with name in /etc/hosts", func() {
|
It("podman run --name X --hostname Y, both X and Y in /etc/hosts", func() {
|
||||||
name := "test_container"
|
name := "test_container"
|
||||||
hostname := "test_hostname"
|
hostname := "test_hostname"
|
||||||
session := podmanTest.Podman([]string{"run", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"})
|
session := podmanTest.Podman([]string{"run", "--rm", "--name", name, "--hostname", hostname, ALPINE, "cat", "/etc/hosts"})
|
||||||
@ -201,31 +200,46 @@ var _ = Describe("Podman run", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman run a container based on remote image", func() {
|
It("podman run a container based on remote image", func() {
|
||||||
// Changing session to rsession
|
// Pick any image that is not in our cache
|
||||||
rsession := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"})
|
session := podmanTest.Podman([]string{"run", "-dt", BB_GLIBC, "ls"})
|
||||||
rsession.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(rsession).Should(ExitCleanly())
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull " + BB_GLIBC))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
||||||
|
|
||||||
lock := GetPortLock("5000")
|
})
|
||||||
|
|
||||||
|
It("podman run --tls-verify", func() {
|
||||||
|
// 5000 is marked insecure in registries.conf, so --tls-verify=false
|
||||||
|
// is a NOP. Pick any other port.
|
||||||
|
port := "5050"
|
||||||
|
lock := GetPortLock(port)
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", port + ":5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
||||||
Skip("Cannot start docker registry.")
|
Fail("Cannot start docker registry.")
|
||||||
}
|
}
|
||||||
|
|
||||||
run := podmanTest.Podman([]string{"run", "--tls-verify=false", ALPINE})
|
pushedImage := "localhost:" + port + "/pushed" + strings.ToLower(RandomString(5)) + ":" + RandomString(8)
|
||||||
run.WaitWithDefaultTimeout()
|
push := podmanTest.Podman([]string{"push", "--tls-verify=false", ALPINE, pushedImage})
|
||||||
Expect(run).Should(ExitCleanly())
|
push.WaitWithDefaultTimeout()
|
||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(3))
|
Expect(push).To(Exit(0))
|
||||||
|
Expect(push.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
||||||
|
|
||||||
// Now registries.conf will be consulted where localhost:5000
|
run := podmanTest.Podman([]string{"run", pushedImage, "date"})
|
||||||
// is set to be insecure.
|
|
||||||
run = podmanTest.Podman([]string{"run", ALPINE})
|
|
||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
Expect(run).Should(ExitCleanly())
|
Expect(run).Should(Exit(125))
|
||||||
|
Expect(run.ErrorToString()).To(ContainSubstring("pinging container registry localhost:" + port))
|
||||||
|
Expect(run.ErrorToString()).To(ContainSubstring("http: server gave HTTP response to HTTPS client"))
|
||||||
|
|
||||||
|
run = podmanTest.Podman([]string{"run", "--tls-verify=false", pushedImage, "echo", "got here"})
|
||||||
|
run.WaitWithDefaultTimeout()
|
||||||
|
Expect(run).Should(Exit(0))
|
||||||
|
Expect(run.OutputToString()).To(Equal("got here"))
|
||||||
|
Expect(run.ErrorToString()).To(ContainSubstring("Trying to pull " + pushedImage))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run a container with a --rootfs", func() {
|
It("podman run a container with a --rootfs", func() {
|
||||||
@ -267,14 +281,10 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(stdoutLines).Should(HaveLen(1))
|
Expect(stdoutLines).Should(HaveLen(1))
|
||||||
Expect(stdoutLines[0]).Should(Equal(uniqueString))
|
Expect(stdoutLines[0]).Should(Equal(uniqueString))
|
||||||
|
|
||||||
SkipIfRemote("External overlay only work locally")
|
// The rest of these tests only work locally and not containerized
|
||||||
if os.Getenv("container") != "" {
|
if IsRemote() || os.Getenv("container") != "" {
|
||||||
Skip("Overlay mounts not supported when running in a container")
|
GinkgoWriter.Println("Bypassing subsequent tests due to remote or container environment")
|
||||||
}
|
return
|
||||||
if isRootless() {
|
|
||||||
if _, err := exec.LookPath("fuse-overlayfs"); err != nil {
|
|
||||||
Skip("Fuse-Overlayfs required for rootless overlay mount test")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Test --rootfs with an external overlay
|
// Test --rootfs with an external overlay
|
||||||
// use --rm to remove container and confirm if we did not leak anything
|
// use --rm to remove container and confirm if we did not leak anything
|
||||||
@ -282,12 +292,14 @@ var _ = Describe("Podman run", func() {
|
|||||||
"--rootfs", rootfs + ":O", "cat", testFilePath})
|
"--rootfs", rootfs + ":O", "cat", testFilePath})
|
||||||
osession.WaitWithDefaultTimeout()
|
osession.WaitWithDefaultTimeout()
|
||||||
Expect(osession).Should(ExitCleanly())
|
Expect(osession).Should(ExitCleanly())
|
||||||
|
Expect(osession.OutputToString()).To(Equal(uniqueString))
|
||||||
|
|
||||||
// Test podman start stop with overlay
|
// Test podman start stop with overlay
|
||||||
osession = podmanTest.Podman([]string{"run", "--name", "overlay-foo", "--security-opt", "label=disable",
|
osession = podmanTest.Podman([]string{"run", "--name", "overlay-foo", "--security-opt", "label=disable",
|
||||||
"--rootfs", rootfs + ":O", "echo", "hello"})
|
"--rootfs", rootfs + ":O", "echo", "hello"})
|
||||||
osession.WaitWithDefaultTimeout()
|
osession.WaitWithDefaultTimeout()
|
||||||
Expect(osession).Should(ExitCleanly())
|
Expect(osession).Should(ExitCleanly())
|
||||||
|
Expect(osession.OutputToString()).To(Equal("hello"))
|
||||||
|
|
||||||
osession = podmanTest.Podman([]string{"stop", "overlay-foo"})
|
osession = podmanTest.Podman([]string{"stop", "overlay-foo"})
|
||||||
osession.WaitWithDefaultTimeout()
|
osession.WaitWithDefaultTimeout()
|
||||||
@ -304,11 +316,11 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(osession).Should(ExitCleanly())
|
Expect(osession).Should(ExitCleanly())
|
||||||
|
|
||||||
// Test --rootfs with an external overlay with --uidmap
|
// Test --rootfs with an external overlay with --uidmap
|
||||||
osession = podmanTest.Podman([]string{"run", "--uidmap", "0:1000:1000", "--rm", "--security-opt", "label=disable",
|
osession = podmanTest.Podman([]string{"run", "--uidmap", "0:1234:5678", "--rm", "--security-opt", "label=disable",
|
||||||
"--rootfs", rootfs + ":O", "echo", "hello"})
|
"--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map"})
|
||||||
osession.WaitWithDefaultTimeout()
|
osession.WaitWithDefaultTimeout()
|
||||||
Expect(osession).Should(ExitCleanly())
|
Expect(osession).Should(ExitCleanly())
|
||||||
Expect(osession.OutputToString()).To(Equal("hello"))
|
Expect(osession.OutputToString()).To(Equal("0 1234 5678"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run a container with --init", func() {
|
It("podman run a container with --init", func() {
|
||||||
@ -597,10 +609,12 @@ var _ = Describe("Podman run", func() {
|
|||||||
|
|
||||||
if isRootless() {
|
if isRootless() {
|
||||||
if os.Getenv("SKIP_USERNS") != "" {
|
if os.Getenv("SKIP_USERNS") != "" {
|
||||||
Skip("Skip userns tests.")
|
GinkgoWriter.Println("Bypassing subsequent tests due to $SKIP_USERNS")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if _, err := os.Stat("/proc/self/uid_map"); err != nil {
|
if _, err := os.Stat("/proc/self/uid_map"); err != nil {
|
||||||
Skip("User namespaces not supported.")
|
GinkgoWriter.Println("Bypassing subsequent tests due to no /proc/self/uid_map")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"})
|
session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--cap-add=DAC_OVERRIDE", "--rm", ALPINE, "grep", "CapAmb", "/proc/self/status"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -2092,10 +2106,6 @@ WORKDIR /madethis`, BB)
|
|||||||
|
|
||||||
podmanTest.AddImageToRWStore(ALPINE)
|
podmanTest.AddImageToRWStore(ALPINE)
|
||||||
|
|
||||||
if isRootless() {
|
|
||||||
err := podmanTest.RestoreArtifact(REGISTRY_IMAGE)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
}
|
|
||||||
lock := GetPortLock("5000")
|
lock := GetPortLock("5000")
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
session := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
|
||||||
@ -2103,7 +2113,7 @@ WORKDIR /madethis`, BB)
|
|||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
|
||||||
Skip("Cannot start docker registry.")
|
Fail("Cannot start docker registry.")
|
||||||
}
|
}
|
||||||
|
|
||||||
bitSize := 1024
|
bitSize := 1024
|
||||||
@ -2119,10 +2129,19 @@ WORKDIR /madethis`, BB)
|
|||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
|
// Must fail without --decryption-key
|
||||||
|
// NOTE: --tls-verify=false not needed, because localhost:5000 is in registries.conf
|
||||||
|
session = podmanTest.Podman([]string{"run", imgPath})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(125))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull " + imgPath))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("invalid tar header"))
|
||||||
|
|
||||||
|
// With
|
||||||
session = podmanTest.Podman([]string{"run", "--decryption-key", privateKeyFileName, imgPath})
|
session = podmanTest.Podman([]string{"run", "--decryption-key", privateKeyFileName, imgPath})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull"))
|
Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull " + imgPath))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run --shm-size-systemd", func() {
|
It("podman run --shm-size-systemd", func() {
|
||||||
|
Reference in New Issue
Block a user