Skip stats test in CGv1 container environments

These tests were originally enabled in a situation where CI provided
false-positive results.  Now that has been corrected, these tests all
fail under a CGv1 container environment with the error:

```
Error: unable to load cgroup at
/machine.slice/libpod-e4f...086.scope/libpod_parent/libpod-fbd...425:
cgroup deleted
```

This commit simply disables the tests under this specific environment.

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich
2021-08-17 12:35:29 -04:00
parent dc70382886
commit 5c837fe5b0
3 changed files with 14 additions and 6 deletions

View File

@ -645,9 +645,13 @@ func isRootless() bool {
return os.Geteuid() != 0 return os.Geteuid() != 0
} }
func isCgroupsV1() bool {
return !CGROUPSV2
}
func SkipIfCgroupV1(reason string) { func SkipIfCgroupV1(reason string) {
checkReason(reason) checkReason(reason)
if !CGROUPSV2 { if isCgroupsV1() {
Skip(reason) Skip(reason)
} }
} }

View File

@ -22,6 +22,9 @@ var _ = Describe("Podman stats", func() {
BeforeEach(func() { BeforeEach(func() {
SkipIfRootlessCgroupsV1("stats not supported on cgroupv1 for rootless users") SkipIfRootlessCgroupsV1("stats not supported on cgroupv1 for rootless users")
if isContainerized() {
SkipIfCgroupV1("stats not supported inside cgroupv1 container environment")
}
var err error var err error
tempdir, err = CreateTempDirInTempDir() tempdir, err = CreateTempDirInTempDir()
if err != nil { if err != nil {

View File

@ -6,7 +6,6 @@ import (
"strings" "strings"
"time" "time"
"github.com/containers/podman/v3/pkg/rootless"
. "github.com/containers/podman/v3/test/utils" . "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -118,11 +117,13 @@ WantedBy=multi-user.target
Expect(len(conData)).To(Equal(1)) Expect(len(conData)).To(Equal(1))
Expect(conData[0].Config.SystemdMode).To(BeTrue()) Expect(conData[0].Config.SystemdMode).To(BeTrue())
if CGROUPSV2 || !rootless.IsRootless() { // stats not supported w/ CGv1 rootless or containerized
stats := podmanTest.Podman([]string{"stats", "--no-stream", ctrName}) if isCgroupsV1() && (isRootless() || isContainerized()) {
stats.WaitWithDefaultTimeout() return
Expect(stats).Should(Exit(0))
} }
stats := podmanTest.Podman([]string{"stats", "--no-stream", ctrName})
stats.WaitWithDefaultTimeout()
Expect(stats).Should(Exit(0))
}) })
It("podman create container with systemd entrypoint triggers systemd mode", func() { It("podman create container with systemd entrypoint triggers systemd mode", func() {