Merge pull request #5321 from thaJeztah/fix_oom_score_test
fix TestSetOOMScoreBoundaries and replace missing busybox image in CI
This commit is contained in:
commit
ceb08756a4
@ -32,7 +32,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testImage = "mirror.gcr.io/library/busybox:latest"
|
testImage = "mirror.gcr.io/library/busybox:1.32.0"
|
||||||
shortCommand = withProcessArgs("true")
|
shortCommand = withProcessArgs("true")
|
||||||
longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done")
|
longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done")
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,8 @@ func SetOOMScore(pid, score int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOOMScoreAdj gets the oom score for a process
|
// GetOOMScoreAdj gets the oom score for a process. It returns 0 (zero) if either
|
||||||
|
// no oom score is set, or a sore is set to 0.
|
||||||
func GetOOMScoreAdj(pid int) (int, error) {
|
func GetOOMScoreAdj(pid int) (int, error) {
|
||||||
path := fmt.Sprintf("/proc/%d/oom_score_adj", pid)
|
path := fmt.Sprintf("/proc/%d/oom_score_adj", pid)
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
|
@ -71,9 +71,11 @@ func TestSetOOMScoreBoundaries(t *testing.T) {
|
|||||||
|
|
||||||
score, err := GetOOMScoreAdj(os.Getpid())
|
score, err := GetOOMScoreAdj(os.Getpid())
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
if score == 0 || score == OOMScoreAdjMin {
|
if score == OOMScoreAdjMin {
|
||||||
// we won't be able to set the score lower than the parent process,
|
// We won't be able to set the score lower than the parent process. This
|
||||||
// so only test if parent process does not have a oom-score-adj
|
// could also be tested if the parent process does not have a oom-score-adj
|
||||||
|
// set, but GetOOMScoreAdj does not distinguish between "not set" and
|
||||||
|
// "score is set, but zero".
|
||||||
_, adjustment, err = adjustOom(OOMScoreAdjMin)
|
_, adjustment, err = adjustOom(OOMScoreAdjMin)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(adjustment, OOMScoreAdjMin))
|
assert.Check(t, is.Equal(adjustment, OOMScoreAdjMin))
|
||||||
|
Loading…
Reference in New Issue
Block a user