Skip to content

Commit ceb0875

Browse files
Merge pull request #5321 from thaJeztah/fix_oom_score_test
fix TestSetOOMScoreBoundaries and replace missing busybox image in CI
2 parents 1645db3 + 3d20fa9 commit ceb0875

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

integration/client/client_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
)
3333

3434
var (
35-
testImage = "mirror.gcr.io/library/busybox:latest"
35+
testImage = "mirror.gcr.io/library/busybox:1.32.0"
3636
shortCommand = withProcessArgs("true")
3737
longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done")
3838
)

sys/oom_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ func SetOOMScore(pid, score int) error {
6565
return nil
6666
}
6767

68-
// GetOOMScoreAdj gets the oom score for a process
68+
// GetOOMScoreAdj gets the oom score for a process. It returns 0 (zero) if either
69+
// no oom score is set, or a sore is set to 0.
6970
func GetOOMScoreAdj(pid int) (int, error) {
7071
path := fmt.Sprintf("/proc/%d/oom_score_adj", pid)
7172
data, err := ioutil.ReadFile(path)

sys/oom_linux_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ func TestSetOOMScoreBoundaries(t *testing.T) {
7171

7272
score, err := GetOOMScoreAdj(os.Getpid())
7373
assert.NilError(t, err)
74-
if score == 0 || score == OOMScoreAdjMin {
75-
// we won't be able to set the score lower than the parent process,
76-
// so only test if parent process does not have a oom-score-adj
74+
if score == OOMScoreAdjMin {
75+
// We won't be able to set the score lower than the parent process. This
76+
// could also be tested if the parent process does not have a oom-score-adj
77+
// set, but GetOOMScoreAdj does not distinguish between "not set" and
78+
// "score is set, but zero".
7779
_, adjustment, err = adjustOom(OOMScoreAdjMin)
7880
assert.NilError(t, err)
7981
assert.Check(t, is.Equal(adjustment, OOMScoreAdjMin))

0 commit comments

Comments
 (0)