Skip to content

Commit

Permalink
Output CGroups information in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
  • Loading branch information
mheon committed Sep 9, 2019
1 parent b624053 commit 063d285
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,11 @@ USER mail`
Skip("Test only works on crun")
}

curCgroups, err := ioutil.ReadFile("/proc/self/cgroup")
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
Expect(err).To(BeNil())
Expect(string(curCgroups)).To(Not(Equal("")))
var curCgroups string = string(curCgroupsBytes)
fmt.Printf("Output:\n%s\n", curCgroups)
Expect(curCgroups).To(Not(Equal("")))

ctrName := "testctr"
container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=disabled", ALPINE, "top"})
Expand All @@ -928,9 +930,11 @@ USER mail`
Expect(pid).To(Not(Equal(0)))
Expect(inspectOut[0].HostConfig.CgroupParent).To(Equal(""))

ctrCgroups, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
Expect(err).To(BeNil())
Expect(string(curCgroups)).To(Equal(string(ctrCgroups)))
var ctrCgroups string = string(ctrCgroupsBytes)
fmt.Printf("Output\n:%s\n", ctrCgroups)
Expect(curCgroups).To(Equal(ctrCgroups))
})

It("podman run with cgroups=default makes cgroups", func() {
Expand All @@ -941,9 +945,11 @@ USER mail`
Skip("Test only works on crun")
}

curCgroups, err := ioutil.ReadFile("/proc/self/cgroup")
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
Expect(err).To(BeNil())
Expect(string(curCgroups)).To(Not(Equal("")))
var curCgroups string = string(curCgroupsBytes)
fmt.Printf("Output:\n%s\n", curCgroups)
Expect(curCgroups).To(Not(Equal("")))

ctrName := "testctr"
container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=default", ALPINE, "top"})
Expand All @@ -957,9 +963,11 @@ USER mail`
Expect(pid).To(Not(Equal(0)))
Expect(inspectOut[0].HostConfig.CgroupParent).To(Not(Equal("")))

ctrCgroups, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
Expect(err).To(BeNil())
Expect(string(curCgroups)).To(Not(Equal(string(ctrCgroups))))
var ctrCgroups string = string(ctrCgroupsBytes)
fmt.Printf("Output\n:%s\n", ctrCgroups)
Expect(curCgroups).To(Not(Equal(ctrCgroups)))
})

It("podman run with cgroups=garbage errors", func() {
Expand Down

0 comments on commit 063d285

Please sign in to comment.