From 561b8014c022bede412aee47e89cc11b648316ac Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 5 Oct 2020 20:04:52 +0200 Subject: [PATCH] testutil: set -500 OOM score for test daemons Signed-off-by: Sebastiaan van Stijn --- testutil/daemon/daemon.go | 2 ++ testutil/daemon/ops.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go index 135962669e..3b9f039c8a 100644 --- a/testutil/daemon/daemon.go +++ b/testutil/daemon/daemon.go @@ -88,6 +88,7 @@ type Daemon struct { DefaultAddrPool []string SubnetSize uint32 DataPathPort uint32 + OOMScoreAdjust int // cached information CachedInfo types.Info } @@ -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) diff --git a/testutil/daemon/ops.go b/testutil/daemon/ops.go index 66d169d1de..c977dcef44 100644 --- a/testutil/daemon/ops.go +++ b/testutil/daemon/ops.go @@ -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 + } +}