Skip to content

Commit

Permalink
testutil: set -500 OOM score for test daemons
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Oct 16, 2020
1 parent 2b8e68e commit 561b801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testutil/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type Daemon struct {
DefaultAddrPool []string
SubnetSize uint32
DataPathPort uint32
OOMScoreAdjust int
// cached information
CachedInfo types.Info
}
Expand Down Expand Up @@ -206,6 +207,7 @@ func New(t testing.TB, ops ...Option) *Daemon {
}
ops = append(ops, WithRootlessUser("unprivilegeduser"))
}
ops = append(ops, WithOOMScoreAdjust(-500))

d, err := NewDaemon(dest, ops...)
assert.NilError(t, err, "could not create daemon at %q", dest)
Expand Down
7 changes: 7 additions & 0 deletions testutil/daemon/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,10 @@ func WithRootlessUser(username string) Option {
d.rootlessUser = u
}
}

// WithOOMScoreAdjust sets OOM score for the daemon
func WithOOMScoreAdjust(score int) Option {
return func(d *Daemon) {
d.OOMScoreAdjust = score
}
}

0 comments on commit 561b801

Please sign in to comment.