From e8dd22ad377ca6025c3344edd99dfc2bd0c86a3e Mon Sep 17 00:00:00 2001 From: Samuel Karp Date: Wed, 23 Oct 2024 11:20:42 -0700 Subject: [PATCH] wip: generate: add test for oom score adj The generator should not clear an existing OOMScoreAdj if no adjustment is performed. Signed-off-by: Samuel Karp --- .../generate/generate_suite_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/runtime-tools/generate/generate_suite_test.go b/pkg/runtime-tools/generate/generate_suite_test.go index 20158d5..9a665fe 100644 --- a/pkg/runtime-tools/generate/generate_suite_test.go +++ b/pkg/runtime-tools/generate/generate_suite_test.go @@ -158,6 +158,26 @@ var _ = Describe("Adjustment", func() { }) }) + When("existing oom score adj", func() { + It("does not adjust Spec", func() { + var ( + spec = makeSpec() + expectedSpec = makeSpec() + adjust = &api.ContainerAdjustment{} + ) + oomScoreAdj := 123 + spec.Process.OOMScoreAdj = &oomScoreAdj + expectedSpec.Process.OOMScoreAdj = &oomScoreAdj + + rg := &rgen.Generator{Config: spec} + xg := xgen.SpecGenerator(rg) + + Expect(xg).ToNot(BeNil()) + Expect(xg.Adjust(adjust)).To(Succeed()) + Expect(spec).To(Equal(expectedSpec)) + }) + }) + When("has CPU shares", func() { It("adjusts Spec correctly", func() { var (