summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-16 15:05:28 -0400
committerGitHub <noreply@github.com>2021-09-16 15:05:28 -0400
commit2a30b60666001b7039aaf5318ffeaa0374433f27 (patch)
tree421afa18f2bdb6c03d2be3872b6135efdf8282da /test/e2e
parentfcb22e82b518bd8de31bc152b78d2cbc6ab09964 (diff)
parent29edeaa892df2f533f997adb0736f09a6f8e0965 (diff)
downloadpodman-2a30b60666001b7039aaf5318ffeaa0374433f27.tar.gz
podman-2a30b60666001b7039aaf5318ffeaa0374433f27.tar.bz2
podman-2a30b60666001b7039aaf5318ffeaa0374433f27.zip
Merge pull request #11598 from mheon/34_backportsreleasenotes
Backports and release notes for v3.4.0-RC1
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/pod_create_test.go44
-rw-r--r--test/e2e/run_cgroup_parent_test.go32
-rw-r--r--test/e2e/run_exit_test.go7
-rw-r--r--test/e2e/run_test.go83
4 files changed, 69 insertions, 97 deletions
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index 7297bfc6e..ed686b470 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -9,9 +9,7 @@ import (
"strconv"
"strings"
- "github.com/containers/common/pkg/sysinfo"
"github.com/containers/podman/v3/pkg/rootless"
- "github.com/containers/podman/v3/pkg/util"
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -535,48 +533,6 @@ ENTRYPOINT ["sleep","99999"]
Expect(create).Should(Exit(0))
})
- It("podman pod create --cpus", func() {
- podName := "testPod"
- numCPU := float64(sysinfo.NumCPU())
- period, quota := util.CoresToPeriodAndQuota(numCPU)
- numCPUStr := strconv.Itoa(int(numCPU))
- podCreate := podmanTest.Podman([]string{"pod", "create", "--cpus", numCPUStr, "--name", podName})
- podCreate.WaitWithDefaultTimeout()
- Expect(podCreate).Should(Exit(0))
-
- contCreate := podmanTest.Podman([]string{"container", "create", "--pod", podName, "alpine"})
- contCreate.WaitWithDefaultTimeout()
- Expect(podCreate).Should(Exit(0))
-
- podInspect := podmanTest.Podman([]string{"pod", "inspect", podName})
- podInspect.WaitWithDefaultTimeout()
- Expect(podInspect).Should(Exit(0))
- podJSON := podInspect.InspectPodToJSON()
- Expect(podJSON.CPUPeriod).To(Equal(period))
- Expect(podJSON.CPUQuota).To(Equal(quota))
- })
-
- It("podman pod create --cpuset-cpus", func() {
- podName := "testPod"
- ctrName := "testCtr"
- numCPU := float64(sysinfo.NumCPU()) - 1
- numCPUStr := strconv.Itoa(int(numCPU))
- in := "0-" + numCPUStr
- podCreate := podmanTest.Podman([]string{"pod", "create", "--cpuset-cpus", in, "--name", podName})
- podCreate.WaitWithDefaultTimeout()
- Expect(podCreate).Should(Exit(0))
-
- contCreate := podmanTest.Podman([]string{"container", "create", "--name", ctrName, "--pod", podName, "alpine"})
- contCreate.WaitWithDefaultTimeout()
- Expect(podCreate).Should(Exit(0))
-
- podInspect := podmanTest.Podman([]string{"pod", "inspect", podName})
- podInspect.WaitWithDefaultTimeout()
- Expect(podInspect).Should(Exit(0))
- podJSON := podInspect.InspectPodToJSON()
- Expect(podJSON.CPUSetCPUs).To(Equal(in))
- })
-
It("podman pod create --pid", func() {
podName := "pidPod"
ns := "ns:/proc/self/ns/"
diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go
index 82b6c3057..e0e1d4b1d 100644
--- a/test/e2e/run_cgroup_parent_test.go
+++ b/test/e2e/run_cgroup_parent_test.go
@@ -13,6 +13,8 @@ import (
. "github.com/onsi/gomega/gexec"
)
+const cgroupRoot = "/sys/fs/cgroup"
+
var _ = Describe("Podman run with --cgroup-parent", func() {
var (
tempdir string
@@ -64,7 +66,6 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
})
Specify("always honor --cgroup-parent", func() {
- Skip("https://github.com/containers/podman/issues/11165")
SkipIfCgroupV1("test not supported in cgroups v1")
if Containerized() || podmanTest.CgroupManager == "cgroupfs" {
Skip("Requires Systemd cgroup manager support")
@@ -78,36 +79,31 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
Expect(run).Should(Exit(0))
cid := run.OutputToString()
- exec := podmanTest.Podman([]string{"exec", cid, "cat", "/proc/self/cgroup"})
+ exec := podmanTest.Podman([]string{"exec", cid, "cat", "/proc/1/cgroup"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
containerCgroup := strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n")
- content, err := ioutil.ReadFile(filepath.Join("/sys/fs/cgroup", containerCgroup, "cgroup.procs"))
- Expect(err).To(BeNil())
-
// Move the container process to a sub cgroup
- subCgroupPath := filepath.Join(filepath.Join("/sys/fs/cgroup", containerCgroup, "old-container"))
-
- err = os.MkdirAll(subCgroupPath, 0755)
+ content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
Expect(err).To(BeNil())
-
- err = ioutil.WriteFile(filepath.Join(subCgroupPath, "cgroup.procs"), content, 0644)
+ oldSubCgroupPath := filepath.Join(filepath.Join(cgroupRoot, containerCgroup, "old-container"))
+ err = os.MkdirAll(oldSubCgroupPath, 0755)
+ Expect(err).To(BeNil())
+ err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
Expect(err).To(BeNil())
- cgroup := filepath.Dir(containerCgroup)
+ newCgroup := fmt.Sprintf("%s/new-container", containerCgroup)
+ err = os.MkdirAll(filepath.Join(cgroupRoot, newCgroup), 0755)
+ Expect(err).To(BeNil())
- run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "-d", fmt.Sprintf("--cgroup-parent=%s", cgroup), fedoraMinimal, "sleep", "100"})
+ run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
+ cgroupEffective := strings.TrimRight(strings.Replace(run.OutputToString(), "0::", "", -1), "\n")
- exec = podmanTest.Podman([]string{"exec", cid, "cat", "/proc/self/cgroup"})
- exec.WaitWithDefaultTimeout()
- Expect(exec).Should(Exit(0))
- cgroupEffective := filepath.Dir(strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n"))
-
- Expect(cgroupEffective).To(Equal(cgroup))
+ Expect(newCgroup).To(Equal(filepath.Dir(cgroupEffective)))
})
Specify("valid --cgroup-parent using slice", func() {
diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go
index e86718577..6c39e5a1f 100644
--- a/test/e2e/run_exit_test.go
+++ b/test/e2e/run_exit_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "fmt"
"os"
"github.com/containers/podman/v3/libpod/define"
@@ -63,4 +64,10 @@ var _ = Describe("Podman run exit", func() {
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(50))
})
+
+ It("podman run exit 125", func() {
+ result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)})
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
+ })
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 846da283d..ec4b0d997 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -11,6 +11,7 @@ import (
"syscall"
"time"
+ "github.com/containers/podman/v3/pkg/cgroups"
. "github.com/containers/podman/v3/test/utils"
"github.com/containers/storage/pkg/stringid"
"github.com/mrunalp/fileutils"
@@ -1295,63 +1296,75 @@ USER mail`, BB)
SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users")
SkipIfRemote("--cgroups=split cannot be used in remote mode")
- container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"})
- container.WaitWithDefaultTimeout()
- Expect(container).Should(Exit(0))
- lines := container.OutputToStringArray()
-
- cgroup := ""
- for _, line := range lines {
- parts := strings.SplitN(line, ":", 3)
- if !CGROUPSV2 {
- // ignore unified on cgroup v1.
- // both runc and crun do not set it.
- // crun does not set named hierarchies.
- if parts[1] == "" || strings.Contains(parts[1], "name=") {
+ checkLines := func(lines []string) {
+ cgroup := ""
+ for _, line := range lines {
+ parts := strings.SplitN(line, ":", 3)
+ if len(parts) < 2 {
continue
}
+ if !CGROUPSV2 {
+ // ignore unified on cgroup v1.
+ // both runc and crun do not set it.
+ // crun does not set named hierarchies.
+ if parts[1] == "" || strings.Contains(parts[1], "name=") {
+ continue
+ }
+ }
+ if parts[2] == "/" {
+ continue
+ }
+ if cgroup == "" {
+ cgroup = parts[2]
+ continue
+ }
+ Expect(cgroup).To(Equal(parts[2]))
}
- if parts[2] == "/" {
- continue
- }
- if cgroup == "" {
- cgroup = parts[2]
- continue
- }
- Expect(cgroup).To(Equal(parts[2]))
}
+
+ container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"})
+ container.WaitWithDefaultTimeout()
+ Expect(container).Should(Exit(0))
+ checkLines(container.OutputToStringArray())
+
+ // check that --cgroups=split is honored also when a container runs in a pod
+ container = podmanTest.Podman([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"})
+ container.WaitWithDefaultTimeout()
+ Expect(container).Should(Exit(0))
+ checkLines(container.OutputToStringArray())
})
It("podman run with cgroups=disabled runs without cgroups", func() {
- SkipIfRootless("FIXME: I believe this should work but need to fix this test")
SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users")
// Only works on crun
if !strings.Contains(podmanTest.OCIRuntime, "crun") {
Skip("Test only works on crun")
}
+ ownsCgroup, err := cgroups.UserOwnsCurrentSystemdCgroup()
+ Expect(err).ShouldNot(HaveOccurred())
+ if !ownsCgroup {
+ // Podman moves itself to a new cgroup if it doesn't own the current cgroup
+ Skip("Test only works when Podman owns the current cgroup")
+ }
+
+ trim := func(i string) string {
+ return strings.TrimSuffix(i, "\n")
+ }
+
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
Expect(err).ShouldNot(HaveOccurred())
- var curCgroups = string(curCgroupsBytes)
+ curCgroups := trim(string(curCgroupsBytes))
fmt.Printf("Output:\n%s\n", curCgroups)
Expect(curCgroups).ToNot(Equal(""))
- ctrName := "testctr"
- container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=disabled", ALPINE, "top"})
+ container := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroups=disabled", ALPINE, "cat", "/proc/self/cgroup"})
container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(0))
- // Get PID and get cgroups of that PID
- inspectOut := podmanTest.InspectContainer(ctrName)
- Expect(len(inspectOut)).To(Equal(1))
- pid := inspectOut[0].State.Pid
- Expect(pid).ToNot(Equal(0))
- Expect(inspectOut[0].HostConfig.CgroupParent).To(Equal(""))
-
- ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
- Expect(err).ShouldNot(HaveOccurred())
- var ctrCgroups = string(ctrCgroupsBytes)
+ ctrCgroups := trim(container.OutputToString())
fmt.Printf("Output\n:%s\n", ctrCgroups)
+
Expect(ctrCgroups).To(Equal(curCgroups))
})