Преглед изворни кода

testutil: set -500 OOM score for test daemons

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn пре 4 година
родитељ
комит
561b8014c0
2 измењених фајлова са 9 додато и 0 уклоњено
  1. 2 0
      testutil/daemon/daemon.go
  2. 7 0
      testutil/daemon/ops.go

+ 2 - 0
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)

+ 7 - 0
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
+	}
+}