Skip to content

Commit 2f67370

Browse files
authored
Merge pull request #4099 from kolyshkin/skip-centos-7
Skip TestWriteCgroupFileHandlesInterrupt on CentOS 7
2 parents 1f9d9a3 + b2539a7 commit 2f67370

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

internal/testutil/testutil.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package testutil
2+
3+
import (
4+
"os/exec"
5+
"strconv"
6+
"sync"
7+
"testing"
8+
)
9+
10+
var (
11+
centosVer string
12+
centosVerOnce sync.Once
13+
)
14+
15+
func centosVersion() string {
16+
centosVerOnce.Do(func() {
17+
ver, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
18+
centosVer = string(ver)
19+
})
20+
return centosVer
21+
}
22+
23+
func SkipOnCentOS(t *testing.T, reason string, versions ...int) {
24+
t.Helper()
25+
for _, v := range versions {
26+
if vstr := strconv.Itoa(v); centosVersion() == vstr {
27+
t.Skip(reason + " on CentOS " + vstr)
28+
}
29+
}
30+
}

libcontainer/cgroups/devices/systemd_test.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"os"
77
"os/exec"
88
"strings"
9-
"sync"
109
"testing"
1110

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

3233
podName := "system-runc_test_pod" + t.Name() + ".slice"
3334
podConfig := &configs.Cgroup{
@@ -118,35 +119,15 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
118119
}
119120
}
120121

121-
var (
122-
centosVer string
123-
centosVerOnce sync.Once
124-
)
125-
126-
func centosVersion() string {
127-
centosVerOnce.Do(func() {
128-
ver, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
129-
centosVer = string(ver)
130-
})
131-
return centosVer
132-
}
133-
134-
func skipOnCentOS7(t *testing.T) {
135-
t.Helper()
136-
// https://github.com/opencontainers/runc/issues/3743
137-
if centosVersion() == "7" {
138-
t.Skip("Flaky on CentOS 7")
139-
}
140-
}
141-
142122
func testSkipDevices(t *testing.T, skipDevices bool, expected []string) {
143123
if !systemd.IsRunningSystemd() {
144124
t.Skip("Test requires systemd.")
145125
}
146126
if os.Geteuid() != 0 {
147127
t.Skip("Test requires root.")
148128
}
149-
skipOnCentOS7(t)
129+
// https://github.com/opencontainers/runc/issues/3743.
130+
testutil.SkipOnCentOS(t, "Flaky (#3743)", 7)
150131

151132
podConfig := &configs.Cgroup{
152133
Parent: "system.slice",

libcontainer/cgroups/file_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import (
88
"strconv"
99
"testing"
1010
"time"
11+
12+
"github.com/opencontainers/runc/internal/testutil"
1113
)
1214

1315
func TestWriteCgroupFileHandlesInterrupt(t *testing.T) {
16+
testutil.SkipOnCentOS(t, "Flaky (see #3418)", 7)
17+
1418
const (
1519
memoryCgroupMount = "/sys/fs/cgroup/memory"
1620
memoryLimit = "memory.limit_in_bytes"

0 commit comments

Comments
 (0)