Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip TestWriteCgroupFileHandlesInterrupt on CentOS 7 #4099

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions internal/testutil/testutil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package testutil

import (
"os/exec"
"strconv"
"sync"
"testing"
)

var (
centosVer string
centosVerOnce sync.Once
)

func centosVersion() string {
centosVerOnce.Do(func() {
ver, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
centosVer = string(ver)
})
return centosVer
}

func SkipOnCentOS(t *testing.T, reason string, versions ...int) {
t.Helper()
for _, v := range versions {
if vstr := strconv.Itoa(v); centosVersion() == vstr {
t.Skip(reason + " on CentOS " + vstr)
}
}
}
29 changes: 5 additions & 24 deletions libcontainer/cgroups/devices/systemd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"os"
"os/exec"
"strings"
"sync"
"testing"

"github.com/opencontainers/runc/internal/testutil"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
"github.com/opencontainers/runc/libcontainer/configs"
Expand All @@ -27,7 +27,8 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip("Test requires root.")
}
skipOnCentOS7(t)
// https://github.com/opencontainers/runc/issues/3743.
testutil.SkipOnCentOS(t, "Flaky (#3743)", 7)

podName := "system-runc_test_pod" + t.Name() + ".slice"
podConfig := &configs.Cgroup{
Expand Down Expand Up @@ -118,35 +119,15 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
}
}

var (
centosVer string
centosVerOnce sync.Once
)

func centosVersion() string {
centosVerOnce.Do(func() {
ver, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
centosVer = string(ver)
})
return centosVer
}

func skipOnCentOS7(t *testing.T) {
t.Helper()
// https://github.com/opencontainers/runc/issues/3743
if centosVersion() == "7" {
t.Skip("Flaky on CentOS 7")
}
}

func testSkipDevices(t *testing.T, skipDevices bool, expected []string) {
if !systemd.IsRunningSystemd() {
t.Skip("Test requires systemd.")
}
if os.Geteuid() != 0 {
t.Skip("Test requires root.")
}
skipOnCentOS7(t)
// https://github.com/opencontainers/runc/issues/3743.
testutil.SkipOnCentOS(t, "Flaky (#3743)", 7)

podConfig := &configs.Cgroup{
Parent: "system.slice",
Expand Down
4 changes: 4 additions & 0 deletions libcontainer/cgroups/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import (
"strconv"
"testing"
"time"

"github.com/opencontainers/runc/internal/testutil"
)

func TestWriteCgroupFileHandlesInterrupt(t *testing.T) {
testutil.SkipOnCentOS(t, "Flaky (see #3418)", 7)

const (
memoryCgroupMount = "/sys/fs/cgroup/memory"
memoryLimit = "memory.limit_in_bytes"
Expand Down
Loading