From f0edf671ace63980107bb95fa0802b5b67b26e1e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Aug 2026 01:01:01 +0200 Subject: [PATCH 1/3] pkg/runtime-tools/generate: rewrite tests without ginkgo Signed-off-by: Sebastiaan van Stijn --- .../generate/generate_suite_test.go | 791 +++++++----------- 1 file changed, 283 insertions(+), 508 deletions(-) diff --git a/pkg/runtime-tools/generate/generate_suite_test.go b/pkg/runtime-tools/generate/generate_suite_test.go index fbae7938..4e8ade6e 100644 --- a/pkg/runtime-tools/generate/generate_suite_test.go +++ b/pkg/runtime-tools/generate/generate_suite_test.go @@ -19,472 +19,297 @@ package generate_test import ( "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - rspec "github.com/opencontainers/runtime-spec/specs-go" + "github.com/stretchr/testify/require" "github.com/containerd/nri/pkg/api" xgen "github.com/containerd/nri/pkg/runtime-tools/generate" "github.com/containerd/nri/pkg/runtime-tools/internal/ocigen" ) -func TestGenerate(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Generate Suite") -} - -var _ = Describe("Adjustment", func() { - When("nil", func() { - It("does not modify the Spec", func() { - var ( - spec = makeSpec() - adjust *api.ContainerAdjustment - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec())) - }) - }) - - When("empty", func() { - It("does not modify the Spec", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{}, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec())) - }) - }) - - When("has args", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Args: []string{ - "arg0", - "arg1", - "arg2", - }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withArgs("arg0", "arg1", "arg2")))) - }) - }) - - When("has rlimits", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Rlimits: []*api.POSIXRlimit{{ - Type: "nofile", - Hard: 456, - Soft: 123, - }}, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withRlimit("nofile", 456, 123)))) - }) - }) - - When("has memory limit", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Memory: &api.LinuxMemory{ - Limit: api.Int64(11111), - }, - }, - }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withMemoryLimit(11111), withMemorySwap(11111)))) - }) - }) - - When("has oom score adj", func() { - It("adjusts Spec correctly", func() { - var ( - oomScoreAdj = 123 - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - OomScoreAdj: &api.OptionalInt{ - Value: int64(oomScoreAdj), +func TestAdjustment(t *testing.T) { + oomScoreAdj := 123 + + tests := []struct { + doc string + adjust *api.ContainerAdjustment + prepare func(*rspec.Spec) + expected func() *rspec.Spec + }{ + { + doc: "nil", + expected: func() *rspec.Spec { return makeSpec() }, + }, + { + doc: "empty", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{}, + }, + expected: func() *rspec.Spec { return makeSpec() }, + }, + { + doc: "args", + adjust: &api.ContainerAdjustment{ + Args: []string{"arg0", "arg1", "arg2"}, + }, + expected: func() *rspec.Spec { + return makeSpec(withArgs("arg0", "arg1", "arg2")) + }, + }, + { + doc: "rlimits", + adjust: &api.ContainerAdjustment{ + Rlimits: []*api.POSIXRlimit{{ + Type: "nofile", + Hard: 456, + Soft: 123, + }}, + }, + expected: func() *rspec.Spec { + return makeSpec(withRlimit("nofile", 456, 123)) + }, + }, + { + doc: "memory limit", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Memory: &api.LinuxMemory{ + Limit: api.Int64(11111), }, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withOomScoreAdj(&oomScoreAdj)))) - }) - }) - - When("unset oom score adj", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - OomScoreAdj: nil, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withMemoryLimit(11111), withMemorySwap(11111)) + }, + }, + { + doc: "oom score adj", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + OomScoreAdj: &api.OptionalInt{Value: int64(oomScoreAdj)}, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withOomScoreAdj(&oomScoreAdj)) + }, + }, + { + doc: "unset oom score adj", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{}, + }, + expected: func() *rspec.Spec { + return makeSpec(withOomScoreAdj(nil)) + }, + }, + { + doc: "existing oom score adj", + adjust: &api.ContainerAdjustment{}, + prepare: func(spec *rspec.Spec) { + spec.Process.OOMScoreAdj = &oomScoreAdj + }, + expected: func() *rspec.Spec { + return makeSpec(withOomScoreAdj(&oomScoreAdj)) + }, + }, + { + doc: "CPU shares", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{Shares: api.UInt64(11111)}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withOomScoreAdj(nil)))) - }) - }) - - 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 - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - 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 ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(11111), - }, - }, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withCPUShares(11111)) + }, + }, + { + doc: "CPU quota", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{Quota: api.Int64(11111)}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withCPUShares(11111)))) - }) - }) - - When("has CPU quota", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Quota: api.Int64(11111), - }, - }, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withCPUQuota(11111)) + }, + }, + { + doc: "CPU period", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{Period: api.UInt64(11111)}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withCPUQuota(11111)))) - }) - }) - - When("has CPU period", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Period: api.UInt64(11111), - }, - }, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withCPUPeriod(11111)) + }, + }, + { + doc: "cpuset CPUs", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{Cpus: "5,6"}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withCPUPeriod(11111)))) - }) - }) - - When("has cpuset CPUs", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Cpus: "5,6", - }, - }, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withCPUSetCPUs("5,6")) + }, + }, + { + doc: "cpuset mems", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{Mems: "5,6"}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withCPUSetCPUs("5,6")))) - }) - }) - - When("has cpuset mems", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Mems: "5,6", - }, - }, + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withCPUSetMems("5,6")) + }, + }, + { + doc: "pids limit", + adjust: &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Pids: &api.LinuxPids{Limit: 123}, }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withCPUSetMems("5,6")))) - }) - }) + }, + }, + expected: func() *rspec.Spec { + return makeSpec(withPidsLimit(123)) + }, + }, + } - When("has pids limit", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Pids: &api.LinuxPids{ - Limit: 123, - }, - }, - }, - } - ) + for _, tc := range tests { + t.Run(tc.doc, func(t *testing.T) { + spec := makeSpec() + if tc.prepare != nil { + tc.prepare(spec) + } xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec(withPidsLimit(123)))) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(tc.adjust)) + require.Equal(t, tc.expected(), spec) }) - }) - - When("has mounts", func() { - It("it sorts the Spec mount slice", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Mounts: []*api.Mount{ - { - Destination: "/a/b/c/d/e", - Source: "/host/e", - }, - { - Destination: "/a/b/c", - Source: "/host/c", - }, - { - Destination: "/a/b", - Source: "/host/b", - }, - { - Destination: "/a", - Source: "/host/a", - }, - }, - } - ) + } - xg := xgen.SpecGenerator(ocigen.New(spec)) + t.Run("mounts", func(t *testing.T) { + spec := makeSpec() + adjust := &api.ContainerAdjustment{ + Mounts: []*api.Mount{ + {Destination: "/a/b/c/d/e", Source: "/host/e"}, + {Destination: "/a/b/c", Source: "/host/c"}, + {Destination: "/a/b", Source: "/host/b"}, + {Destination: "/a", Source: "/host/a"}, + }, + } - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec).To(Equal(makeSpec( - withMounts([]rspec.Mount{ - { - Destination: "/a", - Source: "/host/a", - }, - { - Destination: "/a/b", - Source: "/host/b", - }, - { - Destination: "/a/b/c", - Source: "/host/c", - }, - { - Destination: "/a/b/c/d/e", - Source: "/host/e", - }, - }), - ))) - }) + xg := xgen.SpecGenerator(ocigen.New(spec)) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(adjust)) + require.Equal(t, makeSpec(withMounts([]rspec.Mount{ + {Destination: "/a", Source: "/host/a"}, + {Destination: "/a/b", Source: "/host/b"}, + {Destination: "/a/b/c", Source: "/host/c"}, + {Destination: "/a/b/c/d/e", Source: "/host/e"}, + })), spec) }) - When("has a seccomp policy adjustment", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - seccomp = rspec.LinuxSeccomp{ - DefaultAction: rspec.ActAllow, - ListenerPath: "/run/meshuggah-rocks.sock", - Architectures: []rspec.Arch{}, - Flags: []rspec.LinuxSeccompFlag{}, - Syscalls: []rspec.LinuxSyscall{{ - Names: []string{"sched_getaffinity"}, - Action: rspec.ActNotify, - Args: []rspec.LinuxSeccompArg{}, - }}, - } - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - SeccompPolicy: api.FromOCILinuxSeccomp(&seccomp), - }, - } - ) - - xg := xgen.SpecGenerator(ocigen.New(spec)) + t.Run("seccomp policy", func(t *testing.T) { + spec := makeSpec() + seccomp := rspec.LinuxSeccomp{ + DefaultAction: rspec.ActAllow, + ListenerPath: "/run/meshuggah-rocks.sock", + Architectures: []rspec.Arch{}, + Flags: []rspec.LinuxSeccompFlag{}, + Syscalls: []rspec.LinuxSyscall{{ + Names: []string{"sched_getaffinity"}, + Action: rspec.ActNotify, + Args: []rspec.LinuxSeccompArg{}, + }}, + } + adjust := &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + SeccompPolicy: api.FromOCILinuxSeccomp(&seccomp), + }, + } - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(*spec.Linux.Seccomp).To(Equal(seccomp)) - }) + xg := xgen.SpecGenerator(ocigen.New(spec)) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(adjust)) + require.Equal(t, seccomp, *spec.Linux.Seccomp) }) - When("has a sysctl adjustment", func() { - It("adjusts Spec correctly", func() { - var ( - spec = makeSpec() - adjust = &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Sysctl: map[string]string{ - "net.ipv4.ip_forward": "1", - api.MarkForRemoval("delete.me"): "", - }, - }, - } - ) - spec.Linux.Sysctl = map[string]string{ - "delete.me": "foobar", - } - - xg := xgen.SpecGenerator(ocigen.New(spec)) - - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec.Linux.Sysctl).To(Equal(map[string]string{ - "net.ipv4.ip_forward": "1", - })) + t.Run("sysctl", func(t *testing.T) { + spec := makeSpec() + spec.Linux.Sysctl = map[string]string{"delete.me": "foobar"} + adjust := &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Sysctl: map[string]string{ + "net.ipv4.ip_forward": "1", + api.MarkForRemoval("delete.me"): "", + }, + }, + } - }) + xg := xgen.SpecGenerator(ocigen.New(spec)) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(adjust)) + require.Equal(t, map[string]string{"net.ipv4.ip_forward": "1"}, spec.Linux.Sysctl) }) - When("has a RDT adjustment", func() { - It("adjusts Spec correctly", func() { - spec := makeSpec() - adjust := &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Rdt: &api.LinuxRdt{ - ClosId: api.String("foo"), - Schemata: api.RepeatedString([]string{"L2:0=ff", "L3:0=f"}), - EnableMonitoring: api.Bool(true), - }, + t.Run("RDT", func(t *testing.T) { + spec := makeSpec() + adjust := &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Rdt: &api.LinuxRdt{ + ClosId: api.String("foo"), + Schemata: api.RepeatedString([]string{"L2:0=ff", "L3:0=f"}), + EnableMonitoring: api.Bool(true), }, - } - - xg := xgen.SpecGenerator(ocigen.New(spec)) + }, + } - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec.Linux.IntelRdt).To(Equal(&rspec.LinuxIntelRdt{ - ClosID: "foo", - Schemata: []string{"L2:0=ff", "L3:0=f"}, - EnableMonitoring: true, - })) - }) + xg := xgen.SpecGenerator(ocigen.New(spec)) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(adjust)) + require.Equal(t, &rspec.LinuxIntelRdt{ + ClosID: "foo", + Schemata: []string{"L2:0=ff", "L3:0=f"}, + EnableMonitoring: true, + }, spec.Linux.IntelRdt) }) - When("has a RDT remove adjustment", func() { - It("removes the IntelRdt config", func() { - spec := makeSpec() - spec.Linux.IntelRdt = &rspec.LinuxIntelRdt{ClosID: "bar"} - adjust := &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Rdt: &api.LinuxRdt{ - Remove: true, - }, - }, - } - xg := xgen.SpecGenerator(ocigen.New(spec)) + t.Run("remove RDT", func(t *testing.T) { + spec := makeSpec() + spec.Linux.IntelRdt = &rspec.LinuxIntelRdt{ClosID: "bar"} + adjust := &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Rdt: &api.LinuxRdt{Remove: true}, + }, + } - Expect(xg).ToNot(BeNil()) - Expect(xg.Adjust(adjust)).To(Succeed()) - Expect(spec.Linux.IntelRdt).To(BeNil()) - }) + xg := xgen.SpecGenerator(ocigen.New(spec)) + require.NotNil(t, xg) + require.NoError(t, xg.Adjust(adjust)) + require.Nil(t, spec.Linux.IntelRdt) }) -}) +} type specOption func(*rspec.Spec) @@ -537,78 +362,36 @@ func withOomScoreAdj(v *int) specOption { } func withCPUShares(v uint64) specOption { - return func(spec *rspec.Spec) { - if spec.Linux == nil { - spec.Linux = &rspec.Linux{} - } - if spec.Linux.Resources == nil { - spec.Linux.Resources = &rspec.LinuxResources{} - } - if spec.Linux.Resources.CPU == nil { - spec.Linux.Resources.CPU = &rspec.LinuxCPU{} - } - spec.Linux.Resources.CPU.Shares = &v - } + return func(spec *rspec.Spec) { ensureCPU(spec).Shares = &v } } func withCPUQuota(v int64) specOption { - return func(spec *rspec.Spec) { - if spec.Linux == nil { - spec.Linux = &rspec.Linux{} - } - if spec.Linux.Resources == nil { - spec.Linux.Resources = &rspec.LinuxResources{} - } - if spec.Linux.Resources.CPU == nil { - spec.Linux.Resources.CPU = &rspec.LinuxCPU{} - } - spec.Linux.Resources.CPU.Quota = &v - } + return func(spec *rspec.Spec) { ensureCPU(spec).Quota = &v } } func withCPUPeriod(v uint64) specOption { - return func(spec *rspec.Spec) { - if spec.Linux == nil { - spec.Linux = &rspec.Linux{} - } - if spec.Linux.Resources == nil { - spec.Linux.Resources = &rspec.LinuxResources{} - } - if spec.Linux.Resources.CPU == nil { - spec.Linux.Resources.CPU = &rspec.LinuxCPU{} - } - spec.Linux.Resources.CPU.Period = &v - } + return func(spec *rspec.Spec) { ensureCPU(spec).Period = &v } } func withCPUSetCPUs(v string) specOption { - return func(spec *rspec.Spec) { - if spec.Linux == nil { - spec.Linux = &rspec.Linux{} - } - if spec.Linux.Resources == nil { - spec.Linux.Resources = &rspec.LinuxResources{} - } - if spec.Linux.Resources.CPU == nil { - spec.Linux.Resources.CPU = &rspec.LinuxCPU{} - } - spec.Linux.Resources.CPU.Cpus = v - } + return func(spec *rspec.Spec) { ensureCPU(spec).Cpus = v } } func withCPUSetMems(v string) specOption { - return func(spec *rspec.Spec) { - if spec.Linux == nil { - spec.Linux = &rspec.Linux{} - } - if spec.Linux.Resources == nil { - spec.Linux.Resources = &rspec.LinuxResources{} - } - if spec.Linux.Resources.CPU == nil { - spec.Linux.Resources.CPU = &rspec.LinuxCPU{} - } - spec.Linux.Resources.CPU.Mems = v + return func(spec *rspec.Spec) { ensureCPU(spec).Mems = v } +} + +func ensureCPU(spec *rspec.Spec) *rspec.LinuxCPU { + if spec.Linux == nil { + spec.Linux = &rspec.Linux{} + } + if spec.Linux.Resources == nil { + spec.Linux.Resources = &rspec.LinuxResources{} } + if spec.Linux.Resources.CPU == nil { + spec.Linux.Resources.CPU = &rspec.LinuxCPU{} + } + return spec.Linux.Resources.CPU } func withPidsLimit(v int64) specOption { @@ -619,16 +402,12 @@ func withPidsLimit(v int64) specOption { if spec.Linux.Resources == nil { spec.Linux.Resources = &rspec.LinuxResources{} } - spec.Linux.Resources.Pids = &rspec.LinuxPids{ - Limit: &v, - } + spec.Linux.Resources.Pids = &rspec.LinuxPids{Limit: &v} } } func withMounts(mounts []rspec.Mount) specOption { - return func(spec *rspec.Spec) { - spec.Mounts = append(spec.Mounts, mounts...) - } + return func(spec *rspec.Spec) { spec.Mounts = append(spec.Mounts, mounts...) } } func withRlimit(typ string, hard, soft uint64) specOption { @@ -650,31 +429,27 @@ func makeSpec(options ...specOption) *rspec.Spec { Linux: &rspec.Linux{ Resources: &rspec.LinuxResources{ Memory: &rspec.LinuxMemory{ - Limit: Int64(12345), + Limit: ptr(int64(12345)), }, CPU: &rspec.LinuxCPU{ - Shares: Uint64(45678), - Quota: Int64(87654), - Period: Uint64(54321), + Shares: ptr(uint64(45678)), + Quota: ptr(int64(87654)), + Period: ptr(uint64(54321)), Cpus: "0-111", Mems: "0-4", }, Pids: &rspec.LinuxPids{ - Limit: func(v int64) *int64 { return &v }(1), + Limit: ptr(int64(1)), }, }, }, } - for _, o := range options { - o(spec) + for _, option := range options { + option(spec) } return spec } -func Int64(v int64) *int64 { - return &v -} - -func Uint64(v uint64) *uint64 { +func ptr[T any](v T) *T { return &v } From 5e53b31afb6eeb828ca16fb33c6776f36c1832ab Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Aug 2026 01:22:57 +0200 Subject: [PATCH 2/3] pkg/adaptation: rewrite tests without ginkgo Signed-off-by: Sebastiaan van Stijn --- pkg/adaptation/adaptation_suite_test.go | 2274 +++++++++++------------ pkg/adaptation/suite_test.go | 61 +- 2 files changed, 1083 insertions(+), 1252 deletions(-) diff --git a/pkg/adaptation/adaptation_suite_test.go b/pkg/adaptation/adaptation_suite_test.go index b8ebde7c..59253e8c 100644 --- a/pkg/adaptation/adaptation_suite_test.go +++ b/pkg/adaptation/adaptation_suite_test.go @@ -24,59 +24,53 @@ import ( "slices" "strconv" "strings" + "testing" "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - rspec "github.com/opencontainers/runtime-spec/specs-go" nri "github.com/containerd/nri/pkg/adaptation" "github.com/containerd/nri/pkg/api" - "github.com/containerd/nri/pkg/plugin" + nriplugin "github.com/containerd/nri/pkg/plugin" validator "github.com/containerd/nri/plugins/default-validator/builtin" ) -var _ = Describe("Configuration", func() { - var ( - s = &Suite{} - ) +func TestConfiguration(t *testing.T) { + s := &Suite{} - AfterEach(func() { - s.Cleanup() - }) + t.Run("no (extra) options given", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) + } - When("no (extra) options given", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) + t.Run("should allow startup", func(t *testing.T) { + setup(t) + require.NoError(t, s.runtime.Start(s.dir)) }) - It("should allow startup", func() { - Expect(s.runtime.Start(s.dir)).To(Succeed()) - }) + t.Run("should allow external plugins to connect", func(t *testing.T) { + setup(t) - It("should allow external plugins to connect", func() { var ( runtime = s.runtime plugin = s.plugins[0] timeout = time.After(startupTimeout) ) - Expect(runtime.Start(s.dir)).To(Succeed()) - Expect(plugin.Start(s.dir)).To(Succeed()) - Expect(plugin.Wait(PluginSynchronized, timeout)).To(Succeed()) + require.NoError(t, runtime.Start(s.dir)) + require.NoError(t, plugin.Start(s.dir)) + require.NoError(t, plugin.Wait(PluginSynchronized, timeout)) }) }) - When("external connections are explicitly disabled", func() { - var () - - BeforeEach(func() { - s.Prepare( + t.Run("external connections are explicitly disabled", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDisabledExternalConnections(), @@ -84,21 +78,23 @@ var _ = Describe("Configuration", func() { }, &mockPlugin{idx: "00", name: "test"}, ) - }) + } + + t.Run("should prevent plugins from connecting", func(t *testing.T) { + setup(t) - It("should prevent plugins from connecting", func() { var ( runtime = s.runtime plugin = s.plugins[0] ) - Expect(runtime.Start(s.dir)).To(Succeed()) - Expect(plugin.Start(s.dir)).ToNot(Succeed()) + require.NoError(t, runtime.Start(s.dir)) + require.Error(t, plugin.Start(s.dir)) }) }) -}) +} -var _ = Describe("Adaptation", func() { - When("SyncFn is nil", func() { +func TestAdaptation(t *testing.T) { + t.Run("SyncFn is nil", func(t *testing.T) { var ( syncFn func(ctx context.Context, cb nri.SyncCB) error updateFn = func(_ context.Context, _ []*nri.ContainerUpdate) ([]*nri.ContainerUpdate, error) { @@ -106,13 +102,13 @@ var _ = Describe("Adaptation", func() { } ) - It("should prevent Adaptation creation with an error", func() { + t.Run("should prevent Adaptation creation with an error", func(t *testing.T) { var ( - dir = GinkgoT().TempDir() + dir = t.TempDir() etc = filepath.Join(dir, "etc", "nri") ) - Expect(os.MkdirAll(etc, 0o755)).To(Succeed()) + require.NoError(t, os.MkdirAll(etc, 0o755)) r, err := nri.New("mockRuntime", "0.0.1", syncFn, updateFn, nri.WithPluginPath(filepath.Join(dir, "opt", "nri", "plugins")), @@ -120,12 +116,12 @@ var _ = Describe("Adaptation", func() { nri.WithSocketPath(filepath.Join(dir, "nri.sock")), ) - Expect(r).To(BeNil()) - Expect(err).ToNot(BeNil()) + require.Nil(t, r) + require.NotNil(t, err) }) }) - When("UpdateFn is nil", func() { + t.Run("UpdateFn is nil", func(t *testing.T) { var ( updateFn func(ctx context.Context, updates []*nri.ContainerUpdate) ([]*nri.ContainerUpdate, error) syncFn = func(_ context.Context, _ nri.SyncCB) error { @@ -133,13 +129,13 @@ var _ = Describe("Adaptation", func() { } ) - It("should prevent Adaptation creation with an error", func() { + t.Run("should prevent Adaptation creation with an error", func(t *testing.T) { var ( - dir = GinkgoT().TempDir() + dir = t.TempDir() etc = filepath.Join(dir, "etc", "nri") ) - Expect(os.MkdirAll(etc, 0o755)).To(Succeed()) + require.NoError(t, os.MkdirAll(etc, 0o755)) r, err := nri.New("mockRuntime", "0.0.1", syncFn, updateFn, nri.WithPluginPath(filepath.Join(dir, "opt", "nri", "plugins")), @@ -147,19 +143,17 @@ var _ = Describe("Adaptation", func() { nri.WithSocketPath(filepath.Join(dir, "nri.sock")), ) - Expect(r).To(BeNil()) - Expect(err).ToNot(BeNil()) + require.Nil(t, r) + require.NotNil(t, err) }) }) -}) +} -var _ = Describe("Plugin connection", func() { - var ( - s = &Suite{} - ) +func TestPluginConnection(t *testing.T) { + s := &Suite{} - BeforeEach(func() { - s.Prepare( + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ pods: map[string]*api.PodSandbox{ "pod0": { @@ -195,13 +189,11 @@ var _ = Describe("Plugin connection", func() { idx: "00", }, ) - }) + } - AfterEach(func() { - s.Cleanup() - }) + t.Run("should reject plugins with an invalid name", func(t *testing.T) { + setup(t) - It("should reject plugins with an invalid name", func() { var ( validPlugin = &mockPlugin{ name: "abcd-0123+EFGH_4567.ijkl", @@ -215,25 +207,23 @@ var _ = Describe("Plugin connection", func() { s.Startup() - Expect(validPlugin.Start(s.dir)).To(Succeed()) - Expect(invalidPlugin.Start(s.dir)).ToNot(Succeed()) + require.NoError(t, validPlugin.Start(s.dir)) + require.Error(t, invalidPlugin.Start(s.dir)) }) - It("should configure the plugin", func() { - var ( - plugin = s.plugins[0] - ) + t.Run("should configure the plugin", func(t *testing.T) { + setup(t) + + plugin := s.plugins[0] s.Startup() - Expect(plugin.Events()).Should( - ContainElement( - PluginConfigured, - ), - ) + require.Contains(t, plugin.Events(), PluginConfigured) }) - It("should synchronize the plugin after configuration", func() { + t.Run("should synchronize the plugin after configuration", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime plugin = s.plugins[0] @@ -241,24 +231,20 @@ var _ = Describe("Plugin connection", func() { s.Startup() - Expect(plugin.Events()).Should( - ConsistOf( - PluginConfigured, - PluginSynchronized, - ), - ) + require.ElementsMatch(t, []*Event{ + PluginConfigured, + PluginSynchronized, + }, plugin.Events()) - Expect(protoEqual(plugin.pods["pod0"], runtime.pods["pod0"])).Should(BeTrue(), - protoDiff(plugin.pods["pod0"], runtime.pods["pod0"])) - Expect(protoEqual(plugin.pods["pod1"], runtime.pods["pod1"])).Should(BeTrue(), - protoDiff(plugin.pods["pod1"], runtime.pods["pod1"])) - Expect(protoEqual(plugin.ctrs["ctr0"], runtime.ctrs["ctr0"])).Should(BeTrue(), - protoDiff(plugin.ctrs["ctr0"], runtime.ctrs["ctr0"])) - Expect(protoEqual(plugin.ctrs["ctr1"], runtime.ctrs["ctr1"])).Should(BeTrue(), - protoDiff(plugin.ctrs["ctr1"], runtime.ctrs["ctr1"])) + require.True(t, protoEqual(plugin.pods["pod0"], runtime.pods["pod0"]), protoDiff(plugin.pods["pod0"], runtime.pods["pod0"])) + require.True(t, protoEqual(plugin.pods["pod1"], runtime.pods["pod1"]), protoDiff(plugin.pods["pod1"], runtime.pods["pod1"])) + require.True(t, protoEqual(plugin.ctrs["ctr0"], runtime.ctrs["ctr0"]), protoDiff(plugin.ctrs["ctr0"], runtime.ctrs["ctr0"])) + require.True(t, protoEqual(plugin.ctrs["ctr1"], runtime.ctrs["ctr1"]), protoDiff(plugin.ctrs["ctr1"], runtime.ctrs["ctr1"])) }) - It("close plugins on failed synchronization", func() { + t.Run("close plugins on failed synchronization", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime plugin0 = s.plugins[0] @@ -268,35 +254,29 @@ var _ = Describe("Plugin connection", func() { s.Startup() - Expect(plugin0.Events()).Should( - ConsistOf( - PluginConfigured, - PluginSynchronized, - ), - ) + require.ElementsMatch(t, []*Event{ + PluginConfigured, + PluginSynchronized, + }, plugin0.Events()) runtime.failSync = true s.StartPlugins(plugin1) - Expect(plugin1.Wait(PluginDisconnected, timeout)).To(Succeed()) + require.NoError(t, plugin1.Wait(PluginDisconnected, timeout)) }) -}) +} -var _ = Describe("Pod and container requests and events", func() { - var ( - s = &Suite{} - ) +func TestPodAndContainerRequestsAndEvents(t *testing.T) { + s := &Suite{} - AfterEach(func() { - s.Cleanup() - }) + t.Run("there are no plugins", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{}) + } - When("there are no plugins", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}) - }) + t.Run("should always succeed", func(t *testing.T) { + setup(t) - It("should always succeed", func() { var ( ctx = context.Background() pod0 = &api.PodSandbox{ @@ -327,18 +307,15 @@ var _ = Describe("Pod and container requests and events", func() { s.Startup() - Expect(s.runtime.startStopPodAndContainer(ctx, pod0, ctr0)).To(Succeed()) - Expect(s.runtime.startStopPodAndContainer(ctx, pod1, ctr1)).To(Succeed()) + require.NoError(t, s.runtime.startStopPodAndContainer(ctx, pod0, ctr0)) + require.NoError(t, s.runtime.startStopPodAndContainer(ctx, pod1, ctr1)) }) }) - When("when there are plugins", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) - - DescribeTable("should honor plugins' event subscriptions", - func(subscriptions ...string) { + t.Run("when there are plugins", func(t *testing.T) { + runTable := func(subscriptions ...string) func(t *testing.T) { + return func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) var ( runtime = s.runtime plugin = s.plugins[0] @@ -362,62 +339,58 @@ var _ = Describe("Pod and container requests and events", func() { s.Startup() - Expect(runtime.startStopPodAndContainer(ctx, pod, ctr)).To(Succeed()) + require.NoError(t, runtime.startStopPodAndContainer(ctx, pod, ctr)) for _, events := range subscriptions { for _, event := range strings.Split(events, ",") { match := &Event{Type: EventType(event)} - Expect(plugin.EventQ().Has(match)).To(BeTrue()) + require.True(t, plugin.EventQ().Has(match)) } } - }, - Entry("with RunPodSandbox", "RunPodSandbox"), - Entry("with UpdatePodSandbox", "UpdatePodSandbox"), - Entry("with PostUpdatePodSandbox", "PostUpdatePodSandbox"), - Entry("with StopPodSandbox", "StopPodSandbox"), - Entry("with RemovePodSandbox", "RemovePodSandbox"), - - Entry("with CreateContainer", "CreateContainer"), - Entry("with PostCreateContainer", "PostCreateContainer"), - Entry("with StartContainer", "StartContainer"), - Entry("with PostStartContainer", "PostStartContainer"), - Entry("with UpdateContainer", "UpdateContainer"), - Entry("with PostUpdateContainer", "PostUpdateContainer"), - Entry("with StopContainer", "StopContainer"), - Entry("with RemoveContainer", "RemoveContainer"), - - Entry("with all pod events", "RunPodSandbox,StopPodSandbox,RemovePodSandbox"), - Entry("with all container requests", "CreateContainer,UpdateContainer,StopContainer"), - Entry("with all container requests and events", + } + } + t.Run("should honor plugins' event subscriptions", func(t *testing.T) { + t.Run("with RunPodSandbox", runTable("RunPodSandbox")) + t.Run("with UpdatePodSandbox", runTable("UpdatePodSandbox")) + t.Run("with PostUpdatePodSandbox", runTable("PostUpdatePodSandbox")) + t.Run("with StopPodSandbox", runTable("StopPodSandbox")) + t.Run("with RemovePodSandbox", runTable("RemovePodSandbox")) + t.Run("with CreateContainer", runTable("CreateContainer")) + t.Run("with PostCreateContainer", runTable("PostCreateContainer")) + t.Run("with StartContainer", runTable("StartContainer")) + t.Run("with PostStartContainer", runTable("PostStartContainer")) + t.Run("with UpdateContainer", runTable("UpdateContainer")) + t.Run("with PostUpdateContainer", runTable("PostUpdateContainer")) + t.Run("with StopContainer", runTable("StopContainer")) + t.Run("with RemoveContainer", runTable("RemoveContainer")) + t.Run("with all pod events", runTable("RunPodSandbox,StopPodSandbox,RemovePodSandbox")) + t.Run("with all container requests", runTable("CreateContainer,UpdateContainer,StopContainer")) + t.Run("with all container requests and events", runTable( "CreateContainer,PostCreateContainer", "StartContainer,PostStartContainer", "UpdateContainer,PostUpdateContainer", "StopContainer", "RemoveContainer", - ), - Entry("with all pod and container requests and events", + )) + t.Run("with all pod and container requests and events", runTable( "RunPodSandbox,UpdatePodSandbox,PostUpdatePodSandbox,StopPodSandbox,RemovePodSandbox", "CreateContainer,PostCreateContainer", "StartContainer,PostStartContainer", "UpdateContainer,PostUpdateContainer", "StopContainer", "RemoveContainer", - ), - ) - }) - - When("when there are multiple plugins", func() { - BeforeEach(func() { - s.Prepare( - &mockRuntime{}, - &mockPlugin{idx: "20", name: "test"}, - &mockPlugin{idx: "99", name: "foo"}, - &mockPlugin{idx: "00", name: "bar"}, - ) - + )) }) + }) - DescribeTable("should honor plugins' event subscriptions", - func(subscriptions ...string) { + t.Run("when there are multiple plugins", func(t *testing.T) { + runTable := func(subscriptions ...string) func(t *testing.T) { + return func(t *testing.T) { + s.Prepare(t, + &mockRuntime{}, + &mockPlugin{idx: "20", name: "test"}, + &mockPlugin{idx: "99", name: "foo"}, + &mockPlugin{idx: "00", name: "bar"}, + ) var ( runtime = s.runtime plugins = s.plugins @@ -450,42 +423,38 @@ var _ = Describe("Pod and container requests and events", func() { s.Startup() - Expect(runtime.startStopPodAndContainer(ctx, pod, ctr)).To(Succeed()) - Expect(order).Should( - ConsistOf( - plugins[2], - plugins[0], - plugins[1], - ), - ) - }, - - Entry("with StartContainer", "StartContainer"), - Entry("with all container CRI requests", - "CreateContainer,StartContainer,UpdateContainer,StopContainer,RemoveContainer"), - Entry("with all container requests and events", + require.NoError(t, runtime.startStopPodAndContainer(ctx, pod, ctr)) + require.ElementsMatch(t, []*mockPlugin{ + plugins[2], + plugins[0], + plugins[1], + }, order) + } + } + t.Run("should honor plugins' event subscriptions", func(t *testing.T) { + t.Run("with StartContainer", runTable("StartContainer")) + t.Run("with all container CRI requests", runTable("CreateContainer,StartContainer,UpdateContainer,StopContainer,RemoveContainer")) + t.Run("with all container requests and events", runTable( "CreateContainer,PostCreateContainer", "StartContainer,PostStartContainer", "UpdateContainer,PostUpdateContainer", "StopContainer", "RemoveContainer", - ), - Entry("with all pod and container requests and events", + )) + t.Run("with all pod and container requests and events", runTable( "RunPodSandbox,UpdatePodSandbox,PostUpdatePodSandbox,StopPodSandbox,RemovePodSandbox", "CreateContainer,PostCreateContainer", "StartContainer,PostStartContainer", "UpdateContainer,PostUpdateContainer", "StopContainer", "RemoveContainer", - ), - ) + )) + }) }) -}) +} -var _ = Describe("Plugin container creation adjustments", func() { - var ( - s = &Suite{} - ) +func TestPluginContainerCreationAdjustments(t *testing.T) { + s := &Suite{} adjust := func(subject string, p *mockPlugin, _ *api.PodSandbox, c *api.Container, overwrite bool) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { plugin := p.idx + "-" + p.name @@ -661,17 +630,10 @@ var _ = Describe("Plugin container creation adjustments", func() { return a, nil, nil } - AfterEach(func() { - s.Cleanup() - }) - - When("there is a single plugin", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) - - DescribeTable("should be successfully collected without conflicts", - func(subject string, expected *api.ContainerAdjustment) { + t.Run("there is a single plugin", func(t *testing.T) { + runTable := func(subject string, expected *api.ContainerAdjustment) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) var ( runtime = s.runtime plugin = s.plugins[0] @@ -738,303 +700,248 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) - Expect(protoEqual(reply.Adjust.Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Adjust, expected)) - }, - - Entry("adjust annotations", "annotation", - &api.ContainerAdjustment{ - Annotations: map[string]string{ - "key": "00-test", - }, - }, - ), - Entry("adjust mounts", "mount", - &api.ContainerAdjustment{ - Mounts: []*api.Mount{ + require.Nil(t, err) + require.True(t, protoEqual(reply.Adjust.Strip(), expected), protoDiff(reply.Adjust, expected)) + } + } + t.Run("should be successfully collected without conflicts", func(t *testing.T) { + t.Run("adjust annotations", runTable("annotation", &api.ContainerAdjustment{ + Annotations: map[string]string{ + "key": "00-test", + }, + })) + t.Run("adjust mounts", runTable("mount", &api.ContainerAdjustment{ + Mounts: []*api.Mount{ + { + Source: "/dev/00-test", + Destination: "/mnt/test", + }, + }, + })) + t.Run("remove a mount", runTable("remove mount", &api.ContainerAdjustment{ + Mounts: []*api.Mount{ + { + Destination: api.MarkForRemoval("/remove/test/destination"), + }, + }, + })) + t.Run("adjust environment", runTable("environment", &api.ContainerAdjustment{ + Env: []*api.KeyValue{ + { + Key: "key", + Value: "00-test", + }, + }, + })) + t.Run("adjust arguments", runTable("arguments", &api.ContainerAdjustment{ + Args: []string{ + "echo", + "updated", + "argument", + "list", + }, + })) + t.Run("adjust hooks", runTable("hooks", &api.ContainerAdjustment{ + Hooks: &api.Hooks{ + Prestart: []*api.Hook{ { - Source: "/dev/00-test", - Destination: "/mnt/test", + Path: "/bin/00-test", }, }, }, - ), - Entry("remove a mount", "remove mount", - &api.ContainerAdjustment{ - Mounts: []*api.Mount{ + })) + t.Run("adjust devices", runTable("device", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Devices: []*api.LinuxDevice{ { - Destination: api.MarkForRemoval("/remove/test/destination"), + Path: "/dev/test", + Type: "c", + Major: 313, + Minor: 100, }, }, }, - ), - Entry("adjust environment", "environment", - &api.ContainerAdjustment{ - Env: []*api.KeyValue{ + })) + t.Run("adjust namespace", runTable("namespace", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Namespaces: []*api.LinuxNamespace{ { - Key: "key", - Value: "00-test", - }, - }, - }, - ), - Entry("adjust arguments", "arguments", - &api.ContainerAdjustment{ - Args: []string{ - "echo", - "updated", - "argument", - "list", - }, - }, - ), - Entry("adjust hooks", "hooks", - &api.ContainerAdjustment{ - Hooks: &api.Hooks{ - Prestart: []*api.Hook{ - { - Path: "/bin/00-test", - }, + Type: "cgroup", + Path: "/var/run/cgroupns/replaced", }, }, }, - ), - Entry("adjust devices", "device", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Devices: []*api.LinuxDevice{ - { - Path: "/dev/test", - Type: "c", - Major: 313, - Minor: 100, - }, - }, + })) + t.Run("adjust rlimits", runTable("rlimit", &api.ContainerAdjustment{ + Rlimits: []*api.POSIXRlimit{{Type: "nofile", Soft: 123, Hard: 456}}, + })) + t.Run("adjust CDI Devices", runTable("CDI-device", &api.ContainerAdjustment{ + CDIDevices: []*api.CDIDevice{ + { + Name: "vendor0.com/dev=dev0", }, }, - ), - Entry("adjust namespace", "namespace", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Namespaces: []*api.LinuxNamespace{ - { - Type: "cgroup", - Path: "/var/run/cgroupns/replaced", - }, - }, + })) + t.Run("adjust I/O priority", runTable("I/O priority", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + IoPriority: &api.LinuxIOPriority{ + Class: api.IOPrioClass_IOPRIO_CLASS_RT, + Priority: 5, }, }, - ), - Entry("adjust rlimits", "rlimit", - &api.ContainerAdjustment{ - Rlimits: []*api.POSIXRlimit{{Type: "nofile", Soft: 123, Hard: 456}}, - }, - ), - Entry("adjust CDI Devices", "CDI-device", - &api.ContainerAdjustment{ - CDIDevices: []*api.CDIDevice{ - { - Name: "vendor0.com/dev=dev0", + })) + t.Run("adjust linux net devices", runTable("linux net device", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + NetDevices: map[string]*api.LinuxNetDevice{ + "hostIf": { + Name: "containerIf", }, }, }, - ), - - Entry("adjust I/O priority", "I/O priority", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - IoPriority: &api.LinuxIOPriority{ - Class: api.IOPrioClass_IOPRIO_CLASS_RT, - Priority: 5, + })) + t.Run("adjust linux scheduler", runTable("linux scheduler", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Scheduler: &api.LinuxScheduler{ + Policy: api.LinuxSchedulerPolicy_SCHED_FIFO, + Priority: 10, + Flags: []api.LinuxSchedulerFlag{ + api.LinuxSchedulerFlag_SCHED_FLAG_RESET_ON_FORK, }, }, }, - ), - - Entry("adjust linux net devices", "linux net device", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - NetDevices: map[string]*api.LinuxNetDevice{ - "hostIf": { - Name: "containerIf", - }, - }, + })) + t.Run("adjust linux sysctl settings", runTable("linux sysctl", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Sysctl: map[string]string{ + "net.core.somaxconn": "256", }, }, - ), - - Entry("adjust linux scheduler", "linux scheduler", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Scheduler: &api.LinuxScheduler{ - Policy: api.LinuxSchedulerPolicy_SCHED_FIFO, - Priority: 10, - Flags: []api.LinuxSchedulerFlag{ - api.LinuxSchedulerFlag_SCHED_FLAG_RESET_ON_FORK, - }, + })) + t.Run("adjust linux memory policy", runTable("linux memory policy", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + MemoryPolicy: &api.LinuxMemoryPolicy{ + Mode: api.MpolMode_MPOL_INTERLEAVE, + Nodes: "0,1", + Flags: []api.MpolFlag{ + api.MpolFlag_MPOL_F_STATIC_NODES, }, }, }, - ), - - Entry("adjust linux sysctl settings", "linux sysctl", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Sysctl: map[string]string{ - "net.core.somaxconn": "256", + })) + t.Run("adjust CPU resources", runTable("resources/cpu", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(123), + Quota: api.Int64(456), + Period: api.UInt64(789), + RealtimeRuntime: api.Int64(321), + RealtimePeriod: api.UInt64(654), + Cpus: "0-1", + Mems: "2-3", }, }, }, - ), - - Entry("adjust linux memory policy", "linux memory policy", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - MemoryPolicy: &api.LinuxMemoryPolicy{ - Mode: api.MpolMode_MPOL_INTERLEAVE, - Nodes: "0,1", - Flags: []api.MpolFlag{ - api.MpolFlag_MPOL_F_STATIC_NODES, - }, + })) + t.Run("adjust memory resources", runTable("resources/mem", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Memory: &api.LinuxMemory{ + Limit: api.Int64(1234000), + Reservation: api.Int64(4000), + Swap: api.Int64(34000), + Kernel: api.Int64(30000), + KernelTcp: api.Int64(2000), + Swappiness: api.UInt64(987), + DisableOomKiller: api.Bool(true), + UseHierarchy: api.Bool(true), }, }, }, - ), - - Entry("adjust CPU resources", "resources/cpu", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(123), - Quota: api.Int64(456), - Period: api.UInt64(789), - RealtimeRuntime: api.Int64(321), - RealtimePeriod: api.UInt64(654), - Cpus: "0-1", - Mems: "2-3", - }, - }, + })) + t.Run("adjust class-based resources", runTable("resources/classes", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + RdtClass: api.String("00-test"), + BlockioClass: api.String("00-test"), }, }, - ), - Entry("adjust memory resources", "resources/mem", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Memory: &api.LinuxMemory{ - Limit: api.Int64(1234000), - Reservation: api.Int64(4000), - Swap: api.Int64(34000), - Kernel: api.Int64(30000), - KernelTcp: api.Int64(2000), - Swappiness: api.UInt64(987), - DisableOomKiller: api.Bool(true), - UseHierarchy: api.Bool(true), + })) + t.Run("adjust hugepage limits", runTable("resources/hugepagelimits", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + HugepageLimits: []*api.HugepageLimit{ + { + PageSize: "1M", + Limit: 4096, }, - }, - }, - }, - ), - Entry("adjust class-based resources", "resources/classes", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - RdtClass: api.String("00-test"), - BlockioClass: api.String("00-test"), - }, - }, - }, - ), - Entry("adjust hugepage limits", "resources/hugepagelimits", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - HugepageLimits: []*api.HugepageLimit{ - { - PageSize: "1M", - Limit: 4096, - }, - { - PageSize: "4M", - Limit: 1024, - }, + { + PageSize: "4M", + Limit: 1024, }, }, }, }, - ), - Entry("adjust cgroupv2 unified resources", "resources/unified", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Resources: &api.LinuxResources{ - Unified: map[string]string{ - "resource.1": "value1", - "resource.2": "value2", - }, + })) + t.Run("adjust cgroupv2 unified resources", runTable("resources/unified", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Resources: &api.LinuxResources{ + Unified: map[string]string{ + "resource.1": "value1", + "resource.2": "value2", }, }, }, - ), - Entry("adjust cgroups path", "cgroupspath", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - CgroupsPath: "/00-test", - }, - }, - ), - Entry("adjust seccomp policy", "seccomp", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - SeccompPolicy: func() *api.LinuxSeccomp { - seccomp := rspec.LinuxSeccomp{ - DefaultAction: rspec.ActAllow, - ListenerPath: "/run/meshuggah-rocks.sock", - Architectures: []rspec.Arch{}, - Flags: []rspec.LinuxSeccompFlag{}, - Syscalls: []rspec.LinuxSyscall{{ - Names: []string{"sched_getaffinity"}, - Action: rspec.ActNotify, - Args: []rspec.LinuxSeccompArg{}, - }}, - } - return api.FromOCILinuxSeccomp(&seccomp) - }(), - }, + })) + t.Run("adjust cgroups path", runTable("cgroupspath", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + CgroupsPath: "/00-test", + }, + })) + t.Run("adjust seccomp policy", runTable("seccomp", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + SeccompPolicy: func() *api.LinuxSeccomp { + seccomp := rspec.LinuxSeccomp{ + DefaultAction: rspec.ActAllow, + ListenerPath: "/run/meshuggah-rocks.sock", + Architectures: []rspec.Arch{}, + Flags: []rspec.LinuxSeccompFlag{}, + Syscalls: []rspec.LinuxSyscall{{ + Names: []string{"sched_getaffinity"}, + Action: rspec.ActNotify, + Args: []rspec.LinuxSeccompArg{}, + }}, + } + return api.FromOCILinuxSeccomp(&seccomp) + }(), }, - ), - Entry("adjust RDT", "rdt", - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Rdt: &api.LinuxRdt{ - ClosId: api.String("test"), - Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}), - EnableMonitoring: api.Bool(true), - }, + })) + t.Run("adjust RDT", runTable("rdt", &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Rdt: &api.LinuxRdt{ + ClosId: api.String("test"), + Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}), + EnableMonitoring: api.Bool(true), }, }, - ), - ) - }) - - When("there are multiple plugins", func() { - BeforeEach(func() { - s.Prepare( - &mockRuntime{}, - &mockPlugin{idx: "10", name: "foo"}, - &mockPlugin{idx: "00", name: "bar"}, - ) + })) }) + }) - DescribeTable("should be successfully combined if there are no conflicts", - func(subject string, remove, shouldFail bool, expected *api.ContainerAdjustment) { + t.Run("there are multiple plugins", func(t *testing.T) { + runTable := func(subject string, remove, shouldFail bool, expected *api.ContainerAdjustment) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, + &mockRuntime{}, + &mockPlugin{idx: "10", name: "foo"}, + &mockPlugin{idx: "00", name: "bar"}, + ) var ( runtime = s.runtime plugins = s.plugins @@ -1089,141 +996,116 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr, } reply, err := runtime.CreateContainer(ctx, ctrReq) if shouldFail { - Expect(err).ToNot(BeNil()) + require.NotNil(t, err) } else { - Expect(err).To(BeNil()) - Expect(protoEqual(reply.Adjust.Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Adjust, expected)) + require.Nil(t, err) + require.True(t, protoEqual(reply.Adjust.Strip(), expected), protoDiff(reply.Adjust, expected)) } - }, - - Entry("adjust annotations (conflicts)", "annotation", false, true, nil), - Entry("adjust annotations", "annotation", true, false, - &api.ContainerAdjustment{ - Annotations: map[string]string{ - "-key": "", - "key": "10-foo", - }, - }, - ), - Entry("adjust mounts (conflicts)", "mount", false, true, nil), - Entry("adjust mounts", "mount", true, false, - &api.ContainerAdjustment{ - Mounts: []*api.Mount{ + } + } + t.Run("should be successfully combined if there are no conflicts", func(t *testing.T) { + t.Run("adjust annotations (conflicts)", runTable("annotation", false, true, nil)) + t.Run("adjust annotations", runTable("annotation", true, false, &api.ContainerAdjustment{ + Annotations: map[string]string{ + "-key": "", + "key": "10-foo", + }, + })) + t.Run("adjust mounts (conflicts)", runTable("mount", false, true, nil)) + t.Run("adjust mounts", runTable("mount", true, false, &api.ContainerAdjustment{ + Mounts: []*api.Mount{ + { + Source: "/dev/10-foo", + Destination: "/mnt/test", + }, + }, + })) + t.Run("adjust environment (conflicts)", runTable("environment", false, true, nil)) + t.Run("adjust environment", runTable("environment", true, false, &api.ContainerAdjustment{ + Env: []*api.KeyValue{ + { + Key: "key", + Value: "10-foo", + }, + }, + })) + t.Run("adjust arguments (conflicts)", runTable("arguments", false, true, nil)) + t.Run("adjust arguments", runTable("arguments", true, false, &api.ContainerAdjustment{ + Args: []string{ + "echo", + "updated", + "argument", + "list", + "twice...", + }, + })) + t.Run("adjust hooks", runTable("hooks", false, false, &api.ContainerAdjustment{ + Hooks: &api.Hooks{ + Prestart: []*api.Hook{ { - Source: "/dev/10-foo", - Destination: "/mnt/test", + Path: "/bin/00-bar", }, - }, - }, - ), - Entry("adjust environment (conflicts)", "environment", false, true, nil), - Entry("adjust environment", "environment", true, false, - &api.ContainerAdjustment{ - Env: []*api.KeyValue{ { - Key: "key", - Value: "10-foo", - }, - }, - }, - ), - - Entry("adjust arguments (conflicts)", "arguments", false, true, nil), - Entry("adjust arguments", "arguments", true, false, - &api.ContainerAdjustment{ - Args: []string{ - "echo", - "updated", - "argument", - "list", - "twice...", - }, - }, - ), - - Entry("adjust hooks", "hooks", false, false, - &api.ContainerAdjustment{ - Hooks: &api.Hooks{ - Prestart: []*api.Hook{ - { - Path: "/bin/00-bar", - }, - { - Path: "/bin/10-foo", - }, + Path: "/bin/10-foo", }, }, }, - ), - Entry("adjust devices", "device", false, true, nil), - Entry("adjust devices", "device", true, false, - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Devices: []*api.LinuxDevice{ - { - Path: "/dev/test", - Type: "c", - Major: 313, - Minor: 110, - }, + })) + t.Run("adjust devices", runTable("device", false, true, nil)) + t.Run("adjust devices", runTable("device", true, false, &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Devices: []*api.LinuxDevice{ + { + Path: "/dev/test", + Type: "c", + Major: 313, + Minor: 110, }, }, }, - ), - Entry("adjust resources", "resources/classes", false, true, nil), - - Entry("adjust I/O priority (conflicts)", "I/O priority", false, true, nil), - - Entry("adjust linux net devices", "linux net device", true, false, - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - NetDevices: map[string]*api.LinuxNetDevice{ - "-hostIf": nil, - "hostIf": { - Name: "containerIf", - }, + })) + t.Run("adjust resources", runTable("resources/classes", false, true, nil)) + t.Run("adjust I/O priority (conflicts)", runTable("I/O priority", false, true, nil)) + t.Run("adjust linux net devices", runTable("linux net device", true, false, &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + NetDevices: map[string]*api.LinuxNetDevice{ + "-hostIf": nil, + "hostIf": { + Name: "containerIf", }, }, }, - ), - - Entry("adjust linux net devices (conflicts)", "linux net device", false, true, nil), - Entry("adjust linux scheduler (conflicts)", "linux scheduler", false, true, nil), - - Entry("adjust RDT (conflicts)", "rdt", false, true, nil), - Entry("adjust RDT", "rdt", true, false, - &api.ContainerAdjustment{ - Linux: &api.LinuxContainerAdjustment{ - Rdt: &api.LinuxRdt{ - ClosId: api.String("foo"), - Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}), - EnableMonitoring: api.Bool(true), - }, + })) + t.Run("adjust linux net devices (conflicts)", runTable("linux net device", false, true, nil)) + t.Run("adjust linux scheduler (conflicts)", runTable("linux scheduler", false, true, nil)) + t.Run("adjust RDT (conflicts)", runTable("rdt", false, true, nil)) + t.Run("adjust RDT", runTable("rdt", true, false, &api.ContainerAdjustment{ + Linux: &api.LinuxContainerAdjustment{ + Rdt: &api.LinuxRdt{ + ClosId: api.String("foo"), + Schemata: api.RepeatedString([]string{"L3:0=ff", "MB:0=50"}), + EnableMonitoring: api.Bool(true), }, }, - ), - ) - }) - - When("there are validating plugins", func() { - BeforeEach(func() { - s.Prepare( - &mockRuntime{}, - &mockPlugin{idx: "00", name: "foo"}, - &mockPlugin{idx: "00", name: "validator"}, - ) + })) }) + }) - DescribeTable("validation result should be honored", - func(subject string, shouldFail bool, expected *api.ContainerAdjustment) { + t.Run("there are validating plugins", func(t *testing.T) { + runTable := func(subject string, shouldFail bool, expected *api.ContainerAdjustment) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, + &mockRuntime{}, + &mockPlugin{idx: "00", name: "foo"}, + &mockPlugin{idx: "00", name: "validator"}, + ) var ( runtime = s.runtime plugins = s.plugins @@ -1279,36 +1161,33 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr, } reply, err := runtime.CreateContainer(ctx, ctrReq) if shouldFail { - Expect(err).ToNot(BeNil()) + require.NotNil(t, err) } else { - Expect(err).To(BeNil()) - Expect(protoEqual(reply.Adjust.Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Adjust, expected)) + require.Nil(t, err) + require.True(t, protoEqual(reply.Adjust.Strip(), expected), protoDiff(reply.Adjust, expected)) } - }, - - Entry("adjust allowed annotation", "annotation", false, - &api.ContainerAdjustment{ - Annotations: map[string]string{ - "key": "00-foo", - }, + } + } + t.Run("validation result should be honored", func(t *testing.T) { + t.Run("adjust allowed annotation", runTable("annotation", false, &api.ContainerAdjustment{ + Annotations: map[string]string{ + "key": "00-foo", }, - ), - - Entry("adjust forbidden annotation", "annotation", true, nil), - ) + })) + t.Run("adjust forbidden annotation", runTable("annotation", true, nil)) + }) }) - When("the default validator is enabled and OCI Hook injection is disabled", func() { - BeforeEach(func() { - s.Prepare( + t.Run("the default validator is enabled and OCI Hook injection is disabled", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1323,9 +1202,10 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } - It("should reject OCI Hook injection", func() { + t.Run("should reject OCI Hook injection", func(t *testing.T) { + setup(t) var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1379,29 +1259,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).ToNot(BeNil()) - Expect(reply).To(BeNil()) + require.NotNil(t, err) + require.Nil(t, reply) }) }) - When("default validator disallows runtime default seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator disallows runtime default seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1416,9 +1296,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should reject runtime default seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should reject runtime default seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1482,29 +1364,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).ToNot(BeNil()) - Expect(reply).To(BeNil()) + require.NotNil(t, err) + require.Nil(t, reply) }) }) - When("default validator allows runtime default seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator allows runtime default seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1519,9 +1401,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should not reject runtime default seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should not reject runtime default seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1585,29 +1469,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) }) - When("default validator disallows custom seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator disallows custom seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1622,9 +1506,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should reject custom seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should reject custom seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1689,29 +1575,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).ToNot(BeNil()) - Expect(reply).To(BeNil()) + require.NotNil(t, err) + require.Nil(t, reply) }) }) - When("default validator allows custom seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator allows custom seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1726,9 +1612,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should not reject custom seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should not reject custom seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1793,29 +1681,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) }) - When("default validator disallows unconfined seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator disallows unconfined seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1830,9 +1718,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should reject unconfined seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should reject unconfined seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1896,29 +1786,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).ToNot(BeNil()) - Expect(reply).To(BeNil()) + require.NotNil(t, err) + require.Nil(t, reply) }) }) - When("default validator allows unconfined seccomp policy adjustment", func() { - BeforeEach(func() { - s.Prepare( + t.Run("default validator allows unconfined seccomp policy adjustment", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -1933,9 +1823,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should not reject unconfined seccomp policy adjustment", func(t *testing.T) { + setup(t) - It("should not reject unconfined seccomp policy adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -1999,29 +1891,29 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) }) - When("the default validator is enabled and namespace adjustment is disabled", func() { - BeforeEach(func() { - s.Prepare( + t.Run("the default validator is enabled and namespace adjustment is disabled", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -2036,9 +1928,11 @@ var _ = Describe("Plugin container creation adjustments", func() { &mockPlugin{idx: "10", name: "validator1"}, &mockPlugin{idx: "20", name: "validator2"}, ) - }) + } + + t.Run("should reject namespace adjustment", func(t *testing.T) { + setup(t) - It("should reject namespace adjustment", func() { var ( create = func(_ *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { a := &api.ContainerAdjustment{} @@ -2087,30 +1981,31 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, Container: ctr0, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) ctrReq = &api.CreateContainerRequest{ Pod: pod, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).ToNot(BeNil()) - Expect(reply).To(BeNil()) + require.NotNil(t, err) + require.Nil(t, reply) }) }) - When("the default validator is enabled with some required plugins", func() { - const AnnotationDomain = plugin.AnnotationDomain - BeforeEach(func() { - s.Prepare( + t.Run("the default validator is enabled with some required plugins", func(t *testing.T) { + const AnnotationDomain = nriplugin.AnnotationDomain + + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{ options: []nri.Option{ nri.WithDefaultValidator( @@ -2127,9 +2022,11 @@ var _ = Describe("Plugin container creation adjustments", func() { }, &mockPlugin{idx: "00", name: "foo"}, ) - }) + } + + t.Run("should not allow container creation if required plugins are missing", func(t *testing.T) { + setup(t) - It("should not allow container creation if required plugins are missing", func() { var ( runtime = s.runtime ctx = context.Background() @@ -2144,7 +2041,7 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, @@ -2156,11 +2053,13 @@ var _ = Describe("Plugin container creation adjustments", func() { }, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).To(BeNil()) - Expect(err).ToNot(BeNil()) + require.Nil(t, reply) + require.NotNil(t, err) }) - It("should allow container creation, if missing plugins are tolerated", func() { + t.Run("should allow container creation, if missing plugins are tolerated", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime ctx = context.Background() @@ -2178,7 +2077,7 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod, @@ -2190,11 +2089,13 @@ var _ = Describe("Plugin container creation adjustments", func() { }, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) - It("should allow container creation if all required plugins are present", func() { + t.Run("should allow container creation if all required plugins are present", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime ctx = context.Background() @@ -2209,7 +2110,7 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) s.StartPlugins(&mockPlugin{idx: "10", name: "bar"}) s.WaitForPluginsToSync(s.plugin("10-bar")) @@ -2224,11 +2125,13 @@ var _ = Describe("Plugin container creation adjustments", func() { }, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) - It("should not allow container creation if annotated required plugins are missing", func() { + t.Run("should not allow container creation if annotated required plugins are missing", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime ctx = context.Background() @@ -2246,7 +2149,7 @@ var _ = Describe("Plugin container creation adjustments", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) s.StartPlugins(&mockPlugin{idx: "10", name: "bar"}) s.WaitForPluginsToSync(s.plugin("10-bar")) @@ -2261,8 +2164,8 @@ var _ = Describe("Plugin container creation adjustments", func() { }, } reply, err := runtime.CreateContainer(ctx, ctrReq) - Expect(reply).To(BeNil()) - Expect(err).ToNot(BeNil()) + require.Nil(t, reply) + require.NotNil(t, err) s.StartPlugins(&mockPlugin{idx: "20", name: "xyzzy"}) s.WaitForPluginsToSync(s.plugin("20-xyzzy")) @@ -2277,20 +2180,16 @@ var _ = Describe("Plugin container creation adjustments", func() { }, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(reply).ToNot(BeNil()) - Expect(err).To(BeNil()) + require.NotNil(t, reply) + require.Nil(t, err) }) - }) - -}) +} // -------------------------------------------- -var _ = Describe("Plugin container updates during creation", func() { - var ( - s = &Suite{} - ) +func TestPluginContainerUpdatesDuringCreation(t *testing.T) { + s := &Suite{} update := func(subject, which string, p *mockPlugin, _ *api.PodSandbox, ctr *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) { plugin := p.idx + "-" + p.name @@ -2341,17 +2240,10 @@ var _ = Describe("Plugin container updates during creation", func() { return nil, []*api.ContainerUpdate{u}, nil } - AfterEach(func() { - s.Cleanup() - }) - - When("there is a single plugin", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) - - DescribeTable("should be successfully collected without conflicts", - func(subject string, expected *api.ContainerUpdate) { + t.Run("there is a single plugin", func(t *testing.T) { + runTable := func(subject string, expected *api.ContainerUpdate) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) var ( runtime = s.runtime plugin = s.plugins[0] @@ -2395,118 +2287,105 @@ var _ = Describe("Plugin container updates during creation", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod0} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod0, Container: ctr0, } _, err := runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) + require.Nil(t, err) podReq = &api.RunPodSandboxRequest{Pod: pod1} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq = &api.CreateContainerRequest{ Pod: pod1, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) + require.Nil(t, err) - Expect(len(reply.Update)).To(Equal(1)) + require.Equal(t, 1, len(reply.Update)) expected.ContainerId = reply.Update[0].ContainerId - Expect(protoEqual(reply.Update[0].Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Update[0], expected)) - }, - - Entry("update CPU resources", "resources/cpu", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(123), - Quota: api.Int64(456), - Period: api.UInt64(789), - RealtimeRuntime: api.Int64(321), - RealtimePeriod: api.UInt64(654), - Cpus: "0-1", - Mems: "2-3", - }, + require.True(t, protoEqual(reply.Update[0].Strip(), expected), protoDiff(reply.Update[0], expected)) + } + } + t.Run("should be successfully collected without conflicts", func(t *testing.T) { + t.Run("update CPU resources", runTable("resources/cpu", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(123), + Quota: api.Int64(456), + Period: api.UInt64(789), + RealtimeRuntime: api.Int64(321), + RealtimePeriod: api.UInt64(654), + Cpus: "0-1", + Mems: "2-3", }, }, }, - ), - Entry("update memory resources", "resources/memory", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Memory: &api.LinuxMemory{ - Limit: api.Int64(1234000), - Reservation: api.Int64(4000), - Swap: api.Int64(34000), - Kernel: api.Int64(30000), - KernelTcp: api.Int64(2000), - Swappiness: api.UInt64(987), - DisableOomKiller: api.Bool(true), - UseHierarchy: api.Bool(true), - }, + })) + t.Run("update memory resources", runTable("resources/memory", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Memory: &api.LinuxMemory{ + Limit: api.Int64(1234000), + Reservation: api.Int64(4000), + Swap: api.Int64(34000), + Kernel: api.Int64(30000), + KernelTcp: api.Int64(2000), + Swappiness: api.UInt64(987), + DisableOomKiller: api.Bool(true), + UseHierarchy: api.Bool(true), }, }, }, - ), - Entry("update class-based resources", "resources/classes", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - RdtClass: api.String("00-test"), - BlockioClass: api.String("00-test"), - }, + })) + t.Run("update class-based resources", runTable("resources/classes", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + RdtClass: api.String("00-test"), + BlockioClass: api.String("00-test"), }, }, - ), - Entry("update hugepage limits", "resources/hugepagelimits", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - HugepageLimits: []*api.HugepageLimit{ - { - PageSize: "1M", - Limit: 4096, - }, - { - PageSize: "4M", - Limit: 1024, - }, + })) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + HugepageLimits: []*api.HugepageLimit{ + { + PageSize: "1M", + Limit: 4096, + }, + { + PageSize: "4M", + Limit: 1024, }, }, }, }, - ), - Entry("update cgroupv2 unified resources", "resources/unified", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Unified: map[string]string{ - "resource.1": "value1", - "resource.2": "value2", - }, + })) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Unified: map[string]string{ + "resource.1": "value1", + "resource.2": "value2", }, }, }, - ), - ) - }) - - When("there are multiple plugins", func() { - BeforeEach(func() { - s.Prepare( - &mockRuntime{}, - &mockPlugin{idx: "10", name: "foo"}, - &mockPlugin{idx: "00", name: "bar"}, - ) + })) }) + }) - DescribeTable("should fail with conflicts, successfully collected otherwise", - func(subject string, which string, expected *api.ContainerUpdate) { + t.Run("there are multiple plugins", func(t *testing.T) { + runTable := func(subject string, which string, expected *api.ContainerUpdate) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, + &mockRuntime{}, + &mockPlugin{idx: "10", name: "foo"}, + &mockPlugin{idx: "00", name: "bar"}, + ) var ( runtime = s.runtime plugins = s.plugins @@ -2550,120 +2429,108 @@ var _ = Describe("Plugin container updates during creation", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod0} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod0, Container: ctr0, } _, err := runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) + require.Nil(t, err) podReq = &api.RunPodSandboxRequest{Pod: pod1} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq = &api.CreateContainerRequest{ Pod: pod1, Container: ctr1, } reply, err = runtime.CreateContainer(ctx, ctrReq) if which == "both" { - Expect(err).ToNot(BeNil()) + require.NotNil(t, err) } else { - Expect(err).To(BeNil()) - Expect(len(reply.Update)).To(Equal(1)) + require.Nil(t, err) + require.Equal(t, 1, len(reply.Update)) expected.ContainerId = reply.Update[0].ContainerId - Expect(protoEqual(reply.Update[0].Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Update[0], expected)) + require.True(t, protoEqual(reply.Update[0].Strip(), expected), protoDiff(reply.Update[0], expected)) } - }, - - Entry("update CPU resources", "resources/cpu", "both", nil), - Entry("update CPU resources", "resources/cpu", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(123), - Quota: api.Int64(456), - Period: api.UInt64(789), - RealtimeRuntime: api.Int64(321), - RealtimePeriod: api.UInt64(654), - Cpus: "0-1", - Mems: "2-3", - }, + } + } + t.Run("should fail with conflicts, successfully collected otherwise", func(t *testing.T) { + t.Run("update CPU resources", runTable("resources/cpu", "both", nil)) + t.Run("update CPU resources", runTable("resources/cpu", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(123), + Quota: api.Int64(456), + Period: api.UInt64(789), + RealtimeRuntime: api.Int64(321), + RealtimePeriod: api.UInt64(654), + Cpus: "0-1", + Mems: "2-3", }, }, }, - ), - Entry("update memory resources", "resources/memory", "both", nil), - Entry("update memory resources", "resources/memory", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Memory: &api.LinuxMemory{ - Limit: api.Int64(1234000), - Reservation: api.Int64(4000), - Swap: api.Int64(34000), - Kernel: api.Int64(30000), - KernelTcp: api.Int64(2000), - Swappiness: api.UInt64(987), - DisableOomKiller: api.Bool(true), - UseHierarchy: api.Bool(true), - }, + })) + t.Run("update memory resources", runTable("resources/memory", "both", nil)) + t.Run("update memory resources", runTable("resources/memory", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Memory: &api.LinuxMemory{ + Limit: api.Int64(1234000), + Reservation: api.Int64(4000), + Swap: api.Int64(34000), + Kernel: api.Int64(30000), + KernelTcp: api.Int64(2000), + Swappiness: api.UInt64(987), + DisableOomKiller: api.Bool(true), + UseHierarchy: api.Bool(true), }, }, }, - ), - Entry("update class-based resources", "resources/classes", "both", nil), - Entry("update class-based resources", "resources/classes", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - RdtClass: api.String("10-foo"), - BlockioClass: api.String("10-foo"), - }, + })) + t.Run("update class-based resources", runTable("resources/classes", "both", nil)) + t.Run("update class-based resources", runTable("resources/classes", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + RdtClass: api.String("10-foo"), + BlockioClass: api.String("10-foo"), }, }, - ), - Entry("update hugepage limits", "resources/hugepagelimits", "both", nil), - Entry("update hugepage limits", "resources/hugepagelimits", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - HugepageLimits: []*api.HugepageLimit{ - { - PageSize: "1M", - Limit: 4096, - }, - { - PageSize: "4M", - Limit: 1024, - }, + })) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", "both", nil)) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + HugepageLimits: []*api.HugepageLimit{ + { + PageSize: "1M", + Limit: 4096, + }, + { + PageSize: "4M", + Limit: 1024, }, }, }, }, - ), - Entry("update cgroupv2 unified resources", "resources/unified", "both", nil), - Entry("update cgroupv2 unified resources", "resources/unified", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Unified: map[string]string{ - "resource.1": "value1", - "resource.2": "value2", - }, + })) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", "both", nil)) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Unified: map[string]string{ + "resource.1": "value1", + "resource.2": "value2", }, }, }, - ), - ) + })) + }) }) -}) +} -var _ = Describe("Solicited container updates by plugins", func() { - var ( - s = &Suite{} - ) +func TestSolicitedContainerUpdatesByPlugins(t *testing.T) { + s := &Suite{} update := func(subject, which string, p *mockPlugin, _ *api.PodSandbox, ctr *api.Container, _, _ *api.LinuxResources) ([]*api.ContainerUpdate, error) { plugin := p.idx + "-" + p.name @@ -2714,17 +2581,10 @@ var _ = Describe("Solicited container updates by plugins", func() { return []*api.ContainerUpdate{u}, nil } - AfterEach(func() { - s.Cleanup() - }) - - When("there is a single plugin", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) - - DescribeTable("should be successfully collected without conflicts", - func(subject string, expected *api.ContainerUpdate) { + t.Run("there is a single plugin", func(t *testing.T) { + runTable := func(subject string, expected *api.ContainerUpdate) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) var ( runtime = s.runtime plugin = s.plugins[0] @@ -2755,13 +2615,13 @@ var _ = Describe("Solicited container updates by plugins", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod0} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod0, Container: ctr0, } _, err := runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) + require.Nil(t, err) updReq := &api.UpdateContainerRequest{ Pod: pod0, @@ -2790,180 +2650,167 @@ var _ = Describe("Solicited container updates by plugins", func() { } reply, err = runtime.UpdateContainer(ctx, updReq) - Expect(len(reply.Update)).To(Equal(1)) - Expect(err).To(BeNil()) + require.Equal(t, 1, len(reply.Update)) + require.Nil(t, err) expected.ContainerId = reply.Update[0].ContainerId - Expect(protoEqual(reply.Update[0].Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Update[0], expected)) - }, - - Entry("update CPU resources", "resources/cpu", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(123), - Quota: api.Int64(456), - Period: api.UInt64(789), - RealtimeRuntime: api.Int64(321), - RealtimePeriod: api.UInt64(654), - Cpus: "0-1", - Mems: "2-3", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, + require.True(t, protoEqual(reply.Update[0].Strip(), expected), protoDiff(reply.Update[0], expected)) + } + } + t.Run("should be successfully collected without conflicts", func(t *testing.T) { + t.Run("update CPU resources", runTable("resources/cpu", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(123), + Quota: api.Int64(456), + Period: api.UInt64(789), + RealtimeRuntime: api.Int64(321), + RealtimePeriod: api.UInt64(654), + Cpus: "0-1", + Mems: "2-3", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), }, }, }, - ), - Entry("update memory resources", "resources/memory", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(1234000), - Reservation: api.Int64(4000), - Swap: api.Int64(34000), - Kernel: api.Int64(30000), - KernelTcp: api.Int64(2000), - Swappiness: api.UInt64(987), - DisableOomKiller: api.Bool(true), - UseHierarchy: api.Bool(true), - }, + })) + t.Run("update memory resources", runTable("resources/memory", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(1234000), + Reservation: api.Int64(4000), + Swap: api.Int64(34000), + Kernel: api.Int64(30000), + KernelTcp: api.Int64(2000), + Swappiness: api.UInt64(987), + DisableOomKiller: api.Bool(true), + UseHierarchy: api.Bool(true), }, }, }, - ), - Entry("update class-based resources", "resources/classes", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, - - RdtClass: api.String("00-test"), - BlockioClass: api.String("00-test"), + })) + t.Run("update class-based resources", runTable("resources/classes", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), + }, + + RdtClass: api.String("00-test"), + BlockioClass: api.String("00-test"), }, }, - ), - Entry("update hugepage limits", "resources/hugepagelimits", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), + })) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), + }, + HugepageLimits: []*api.HugepageLimit{ + { + PageSize: "1M", + Limit: 4096, }, - HugepageLimits: []*api.HugepageLimit{ - { - PageSize: "1M", - Limit: 4096, - }, - { - PageSize: "4M", - Limit: 1024, - }, + { + PageSize: "4M", + Limit: 1024, }, }, }, }, - ), - Entry("update cgroupv2 unified resources", "resources/unified", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, + })) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), + }, - Unified: map[string]string{ - "resource.1": "value1", - "resource.2": "value2", - }, + Unified: map[string]string{ + "resource.1": "value1", + "resource.2": "value2", }, }, }, - ), - ) - }) - - When("there are multiple plugins", func() { - BeforeEach(func() { - s.Prepare( - &mockRuntime{}, - &mockPlugin{idx: "10", name: "foo"}, - &mockPlugin{idx: "00", name: "bar"}, - ) + })) }) + }) - DescribeTable("should fail with conflicts, successfully collected otherwise", - func(subject string, which string, expected *api.ContainerUpdate) { + t.Run("there are multiple plugins", func(t *testing.T) { + runTable := func(subject string, which string, expected *api.ContainerUpdate) func(*testing.T) { + return func(t *testing.T) { + s.Prepare(t, + &mockRuntime{}, + &mockPlugin{idx: "10", name: "foo"}, + &mockPlugin{idx: "00", name: "bar"}, + ) var ( runtime = s.runtime plugins = s.plugins @@ -2995,13 +2842,13 @@ var _ = Describe("Solicited container updates by plugins", func() { s.Startup() podReq := &api.RunPodSandboxRequest{Pod: pod0} - Expect(runtime.RunPodSandbox(ctx, podReq)).To(Succeed()) + require.NoError(t, runtime.RunPodSandbox(ctx, podReq)) ctrReq := &api.CreateContainerRequest{ Pod: pod0, Container: ctr0, } _, err := runtime.CreateContainer(ctx, ctrReq) - Expect(err).To(BeNil()) + require.Nil(t, err) updReq := &api.UpdateContainerRequest{ Pod: pod0, @@ -3030,198 +2877,181 @@ var _ = Describe("Solicited container updates by plugins", func() { } reply, err = runtime.UpdateContainer(ctx, updReq) if which == "both" { - Expect(err).ToNot(BeNil()) + require.NotNil(t, err) } else { - Expect(err).To(BeNil()) - Expect(len(reply.Update)).To(Equal(1)) + require.Nil(t, err) + require.Equal(t, 1, len(reply.Update)) expected.ContainerId = reply.Update[0].ContainerId - Expect(protoEqual(reply.Update[0].Strip(), expected)).Should(BeTrue(), - protoDiff(reply.Update[0], expected)) + require.True(t, protoEqual(reply.Update[0].Strip(), expected), protoDiff(reply.Update[0], expected)) } - }, - - Entry("update CPU resources", "resources/cpu", "both", nil), - Entry("update CPU resources", "resources/cpu", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(123), - Quota: api.Int64(456), - Period: api.UInt64(789), - RealtimeRuntime: api.Int64(321), - RealtimePeriod: api.UInt64(654), - Cpus: "0-1", - Mems: "2-3", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, + } + } + t.Run("should fail with conflicts, successfully collected otherwise", func(t *testing.T) { + t.Run("update CPU resources", runTable("resources/cpu", "both", nil)) + t.Run("update CPU resources", runTable("resources/cpu", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(123), + Quota: api.Int64(456), + Period: api.UInt64(789), + RealtimeRuntime: api.Int64(321), + RealtimePeriod: api.UInt64(654), + Cpus: "0-1", + Mems: "2-3", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), }, }, }, - ), - Entry("update memory resources", "resources/memory", "both", nil), - Entry("update memory resources", "resources/memory", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(1234000), - Reservation: api.Int64(4000), - Swap: api.Int64(34000), - Kernel: api.Int64(30000), - KernelTcp: api.Int64(2000), - Swappiness: api.UInt64(987), - DisableOomKiller: api.Bool(true), - UseHierarchy: api.Bool(true), - }, + })) + t.Run("update memory resources", runTable("resources/memory", "both", nil)) + t.Run("update memory resources", runTable("resources/memory", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(1234000), + Reservation: api.Int64(4000), + Swap: api.Int64(34000), + Kernel: api.Int64(30000), + KernelTcp: api.Int64(2000), + Swappiness: api.UInt64(987), + DisableOomKiller: api.Bool(true), + UseHierarchy: api.Bool(true), }, }, }, - ), - Entry("update class-based resources", "resources/classes", "both", nil), - Entry("update class-based resources", "resources/classes", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, - RdtClass: api.String("10-foo"), - BlockioClass: api.String("10-foo"), + })) + t.Run("update class-based resources", runTable("resources/classes", "both", nil)) + t.Run("update class-based resources", runTable("resources/classes", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), }, + RdtClass: api.String("10-foo"), + BlockioClass: api.String("10-foo"), }, }, - ), - Entry("update hugepage limits", "resources/hugepagelimits", "both", nil), - Entry("update hugepage limits", "resources/hugepagelimits", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), + })) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", "both", nil)) + t.Run("update hugepage limits", runTable("resources/hugepagelimits", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), + }, + HugepageLimits: []*api.HugepageLimit{ + { + PageSize: "1M", + Limit: 4096, }, - HugepageLimits: []*api.HugepageLimit{ - { - PageSize: "1M", - Limit: 4096, - }, - { - PageSize: "4M", - Limit: 1024, - }, + { + PageSize: "4M", + Limit: 1024, }, }, }, }, - ), - Entry("update cgroupv2 unified resources", "resources/unified", "both", nil), - Entry("update cgroupv2 unified resources", "resources/unified", "10-foo", - &api.ContainerUpdate{ - Linux: &api.LinuxContainerUpdate{ - Resources: &api.LinuxResources{ - Cpu: &api.LinuxCPU{ - Shares: api.UInt64(999), - Quota: api.Int64(888), - Period: api.UInt64(777), - RealtimeRuntime: api.Int64(666), - RealtimePeriod: api.UInt64(555), - Cpus: "444", - Mems: "333", - }, - Memory: &api.LinuxMemory{ - Limit: api.Int64(9999), - Reservation: api.Int64(8888), - Swap: api.Int64(7777), - Kernel: api.Int64(6666), - KernelTcp: api.Int64(5555), - Swappiness: api.UInt64(444), - DisableOomKiller: api.Bool(false), - UseHierarchy: api.Bool(false), - }, - Unified: map[string]string{ - "resource.1": "value1", - "resource.2": "value2", - }, + })) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", "both", nil)) + t.Run("update cgroupv2 unified resources", runTable("resources/unified", "10-foo", &api.ContainerUpdate{ + Linux: &api.LinuxContainerUpdate{ + Resources: &api.LinuxResources{ + Cpu: &api.LinuxCPU{ + Shares: api.UInt64(999), + Quota: api.Int64(888), + Period: api.UInt64(777), + RealtimeRuntime: api.Int64(666), + RealtimePeriod: api.UInt64(555), + Cpus: "444", + Mems: "333", + }, + Memory: &api.LinuxMemory{ + Limit: api.Int64(9999), + Reservation: api.Int64(8888), + Swap: api.Int64(7777), + Kernel: api.Int64(6666), + KernelTcp: api.Int64(5555), + Swappiness: api.UInt64(444), + DisableOomKiller: api.Bool(false), + UseHierarchy: api.Bool(false), + }, + Unified: map[string]string{ + "resource.1": "value1", + "resource.2": "value2", }, }, }, - ), - ) + })) + }) }) -}) - -var _ = Describe("Unsolicited container update requests", func() { - var ( - s = &Suite{} - ) +} - AfterEach(func() { - s.Cleanup() - }) +func TestUnsolicitedContainerUpdateRequests(t *testing.T) { + s := &Suite{} - When("there are plugins", func() { - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) + t.Run("there are plugins", func(t *testing.T) { + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) + } - It("should fail gracefully without unstarted plugins", func() { - var ( - plugin = s.plugins[0] - ) + t.Run("should fail gracefully without unstarted plugins", func(t *testing.T) { + setup(t) + plugin := s.plugins[0] s.StartRuntime() - Expect(plugin.Init(s.Dir())).To(Succeed()) + require.NoError(t, plugin.Init(s.Dir())) updates := []*api.ContainerUpdate{ { @@ -3234,10 +3064,12 @@ var _ = Describe("Unsolicited container update requests", func() { }, } _, err := plugin.stub.UpdateContainers(updates) - Expect(err).ToNot(BeNil()) + require.NotNil(t, err) }) - It("should be delivered, without crash/panic", func() { + t.Run("should be delivered, without crash/panic", func(t *testing.T) { + setup(t) + var ( runtime = s.runtime plugin = s.plugins[0] @@ -3265,7 +3097,7 @@ var _ = Describe("Unsolicited container update requests", func() { } s.Startup() - Expect(runtime.startStopPodAndContainer(ctx, pod, ctr)).To(Succeed()) + require.NoError(t, runtime.startStopPodAndContainer(ctx, pod, ctr)) requestedUpdates := []*api.ContainerUpdate{ { @@ -3279,27 +3111,23 @@ var _ = Describe("Unsolicited container update requests", func() { } failed, err := plugin.stub.UpdateContainers(requestedUpdates) - Expect(failed).To(BeNil()) - Expect(err).To(BeNil()) - Expect(recordedUpdates).ToNot(Equal(requestedUpdates)) + require.Nil(t, failed) + require.Nil(t, err) + require.NotEqual(t, requestedUpdates, recordedUpdates) }) }) -}) +} -var _ = Describe("Plugin configuration request", func() { - var ( - s = &Suite{} - ) +func TestPluginConfigurationRequest(t *testing.T) { + s := &Suite{} - AfterEach(func() { - s.Cleanup() - }) + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) + } - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) + t.Run("should pass runtime version information to plugins", func(t *testing.T) { + setup(t) - It("should pass runtime version information to plugins", func() { var ( runtimeName = "test-runtime" runtimeVersion = "1.2.3" @@ -3310,62 +3138,63 @@ var _ = Describe("Plugin configuration request", func() { s.Startup() - Expect(s.plugins[0].RuntimeName()).To(Equal(runtimeName)) - Expect(s.plugins[0].RuntimeVersion()).To(Equal(runtimeVersion)) + require.Equal(t, runtimeName, s.plugins[0].RuntimeName()) + require.Equal(t, runtimeVersion, s.plugins[0].RuntimeVersion()) }) - When("unchanged", func() { - It("should pass default timeout information to plugins", func() { + t.Run("unchanged", func(t *testing.T) { + t.Run("should pass default timeout information to plugins", func(t *testing.T) { + setup(t) + var ( registerTimeout = nri.DefaultPluginRegistrationTimeout requestTimeout = nri.DefaultPluginRequestTimeout ) s.Startup() - Expect(s.plugins[0].stub.RegistrationTimeout()).To(Equal(registerTimeout)) - Expect(s.plugins[0].stub.RequestTimeout()).To(Equal(requestTimeout)) + require.Equal(t, registerTimeout, s.plugins[0].stub.RegistrationTimeout()) + require.Equal(t, requestTimeout, s.plugins[0].stub.RequestTimeout()) }) }) - When("reconfigured", func() { + t.Run("reconfigured", func(t *testing.T) { var ( registerTimeout = nri.DefaultPluginRegistrationTimeout + 5*time.Millisecond requestTimeout = nri.DefaultPluginRequestTimeout + 7*time.Millisecond ) - BeforeEach(func() { + setup := func(t *testing.T) { + t.Helper() + nri.SetPluginRegistrationTimeout(registerTimeout) nri.SetPluginRequestTimeout(requestTimeout) - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - AfterEach(func() { - nri.SetPluginRegistrationTimeout(nri.DefaultPluginRegistrationTimeout) - nri.SetPluginRequestTimeout(nri.DefaultPluginRequestTimeout) - }) + t.Cleanup(func() { + nri.SetPluginRegistrationTimeout(nri.DefaultPluginRegistrationTimeout) + nri.SetPluginRequestTimeout(nri.DefaultPluginRequestTimeout) + }) + } - It("should pass configured timeout information to plugins", func() { + t.Run("should pass configured timeout information to plugins", func(t *testing.T) { + setup(t) s.Startup() - Expect(s.plugins[0].stub.RegistrationTimeout()).To(Equal(registerTimeout)) - Expect(s.plugins[0].stub.RequestTimeout()).To(Equal(requestTimeout)) + require.Equal(t, registerTimeout, s.plugins[0].stub.RegistrationTimeout()) + require.Equal(t, requestTimeout, s.plugins[0].stub.RequestTimeout()) }) }) -}) +} -var _ = Describe("NRI version exchange", func() { - var ( - s = &Suite{} - ) +func TestNRIVersionExchange(t *testing.T) { + s := &Suite{} - AfterEach(func() { - s.Cleanup() - }) + setup := func(t *testing.T) { + s.Prepare(t, &mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) + } - BeforeEach(func() { - s.Prepare(&mockRuntime{}, &mockPlugin{idx: "00", name: "test"}) - }) + t.Run("should pass runtime version information to plugins", func(t *testing.T) { + setup(t) - It("should pass runtime version information to plugins", func() { var ( runtimeName = "test-runtime" runtimeVersion = "1.2.3" @@ -3378,12 +3207,11 @@ var _ = Describe("NRI version exchange", func() { s.Startup() - Expect(s.plugins[0].RuntimeName()).To(Equal(runtimeName)) - Expect(s.plugins[0].RuntimeVersion()).To(Equal(runtimeVersion)) - Expect(s.plugins[0].RuntimeNRIVersion()).To(Equal(nriVersion)) + require.Equal(t, runtimeName, s.plugins[0].RuntimeName()) + require.Equal(t, runtimeVersion, s.plugins[0].RuntimeVersion()) + require.Equal(t, nriVersion, s.plugins[0].RuntimeNRIVersion()) }) - -}) +} func protoDiff(a, b proto.Message) string { return cmp.Diff(a, b, protocmp.Transform()) diff --git a/pkg/adaptation/suite_test.go b/pkg/adaptation/suite_test.go index 36c0830e..34be0d66 100644 --- a/pkg/adaptation/suite_test.go +++ b/pkg/adaptation/suite_test.go @@ -33,15 +33,9 @@ import ( "github.com/containerd/nri/pkg/stub" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "github.com/stretchr/testify/require" ) -func TestRuntime(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "NRI Runtime") -} - const ( startupTimeout = 2 * time.Second defaultRuntimeName = "default-runtime-name" @@ -50,28 +44,28 @@ const ( // A test suite consist of a runtime and a set of plugins. type Suite struct { + t *testing.T dir string // directory to create for test runtime *mockRuntime // runtime instance for test plugins []*mockPlugin // plugin instances for test byName map[string]*mockPlugin } -// SuiteOption can be applied to a suite. -type SuiteOption func(s *Suite) error - // Prepare test suite, creating test directory. -func (s *Suite) Prepare(runtime *mockRuntime, plugins ...*mockPlugin) string { - var ( - dir string - etc string - ) +func (s *Suite) Prepare(t *testing.T, runtime *mockRuntime, plugins ...*mockPlugin) string { + t.Helper() logrus.SetLevel(logrus.ErrorLevel) - dir = GinkgoT().TempDir() - etc = filepath.Join(dir, "etc", "nri") + // Avoid t.TempDir() to keep Unix socket paths below platform limits. + dir, err := os.MkdirTemp("", "nri-") + require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, os.RemoveAll(dir)) + }) - Expect(os.MkdirAll(etc, 0o755)).To(Succeed()) + etc := filepath.Join(dir, "etc", "nri") + require.NoError(t, os.MkdirAll(etc, 0o755)) if runtime.name == "" { runtime.name = defaultRuntimeName @@ -80,13 +74,15 @@ func (s *Suite) Prepare(runtime *mockRuntime, plugins ...*mockPlugin) string { runtime.version = defaultRuntimeVersion } + s.t = t s.dir = dir s.runtime = runtime - s.plugins = plugins - - if s.byName == nil { - s.byName = make(map[string]*mockPlugin) + for _, plugin := range plugins { + plugin.logf = t.Logf } + s.plugins = plugins + s.byName = make(map[string]*mockPlugin) + t.Cleanup(s.Cleanup) return dir } @@ -107,7 +103,8 @@ func (s *Suite) Startup() { // StartRuntime starts the suite runtime. func (s *Suite) StartRuntime() { - Expect(s.runtime.Start(s.dir)).To(Succeed()) + s.t.Helper() + require.NoError(s.t, s.runtime.Start(s.dir)) } // StartPlugins starts the suite plugins. @@ -115,15 +112,16 @@ func (s *Suite) StartPlugins(plugins ...*mockPlugin) { for _, plugin := range plugins { s.plugins = append(s.plugins, plugin) s.byName[plugin.FullName()] = plugin - Expect(plugin.Start(s.dir)).To(Succeed()) + require.NoError(s.t, plugin.Start(s.dir)) } } // WaitForPluginsToSync waits for the given plugins to get synchronized. func (s *Suite) WaitForPluginsToSync(plugins ...*mockPlugin) { + s.t.Helper() timeout := time.After(startupTimeout) for _, plugin := range plugins { - Expect(plugin.Wait(PluginSynchronized, timeout)).To(Succeed()) + require.NoError(s.t, plugin.Wait(PluginSynchronized, timeout)) } s.runtime.runtime.BlockPluginSync().Unblock() // ensure plugins are fully registered } @@ -135,7 +133,6 @@ func (s *Suite) Cleanup() { for _, plugin := range s.plugins { plugin.Stop() } - Expect(os.RemoveAll(s.dir)).To(Succeed()) } // Plugin returns a plugin started by StartPlugins by full plugin name. @@ -146,7 +143,7 @@ func (s *Suite) plugin(fullName string) *mockPlugin { // ------------------------------------ func Log(format string, args ...interface{}) { - GinkgoWriter.Printf(format+"\n", args...) + logrus.Debugf(format, args...) } type mockRuntime struct { @@ -381,6 +378,8 @@ type mockPlugin struct { runtime string version string + logf func(string, ...any) + q *EventQ pods map[string]*api.PodSandbox ctrs map[string]*api.Container @@ -419,8 +418,12 @@ var ( _ = stub.PostUpdateContainerInterface(&mockPlugin{}) ) -func (m *mockPlugin) Log(format string, args ...interface{}) { - Log("* [plugin %s-%s] "+format, append([]interface{}{m.idx, m.name}, args...)...) +func (m *mockPlugin) Log(format string, args ...any) { + logf := m.logf + if logf == nil { + logf = Log + } + logf("* [plugin %s-%s] "+format, append([]any{m.idx, m.name}, args...)...) } func (m *mockPlugin) SetFallbackName(name string, idx int) { From 6ed16f86951e83cbbf3825eda9daa3d4eb5eba8f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Aug 2026 02:37:09 +0200 Subject: [PATCH 3/3] pkg/net/multiplex: rewrite tests without ginkgo Signed-off-by: Sebastiaan van Stijn --- .github/workflows/ci.yml | 2 +- .golangci.yml | 5 - Makefile | 32 +- go.mod | 9 - go.sum | 23 +- pkg/net/multiplex/mux_suite_test.go | 676 ++++++++++--------------- plugins/device-injector/go.sum | 22 +- plugins/differ/go.sum | 16 - plugins/hook-injector/go.sum | 26 +- plugins/logger/go.sum | 22 +- plugins/network-device-injector/go.sum | 27 +- plugins/network-logger/go.sum | 22 +- plugins/rdt/go.sum | 22 +- plugins/template/go.sum | 22 +- plugins/ulimit-adjuster/go.sum | 22 +- plugins/wasm/go.sum | 8 +- plugins/writable-cgroups/go.sum | 22 +- 17 files changed, 340 insertions(+), 638 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 519be07e..42443329 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,4 +116,4 @@ jobs: echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - run: | - make install-ginkgo test codecov + make test codecov diff --git a/.golangci.yml b/.golangci.yml index 2c622076..31aa3a19 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -27,11 +27,6 @@ linters: linters: - govet text: "copylocks: .*protobuf/internal/impl.MessageState.*" - # We dot-import ginkgo and gomega in some tests. Silence any related errors. - - path: 'pkg/adaptation|pkg/runtime-tools/generate|pkg/net/multiplex' - linters: - - revive - text: "dot-imports:" - linters: - revive text: "package-comments:" diff --git a/Makefile b/Makefile index 29f7c21e..9ae3c2f1 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ GO_BUILD_FLAGS ?= GO_MODULES := $(shell $(GO_CMD) list ./...) GOLANG_CILINT := golangci-lint -GINKGO := ginkgo RESOLVED_PWD := $(shell realpath $(shell pwd)) BUILD_PATH := $(RESOLVED_PWD)/build @@ -150,23 +149,19 @@ $(BIN_PATH)/wasm build/bin/wasm: FORCE # test targets # -test-gopkgs: go-generate ginkgo-tests test-ulimits test-rdt test-hook-injector test-writable-cgroups +test-gopkgs: go-generate test-main test-ulimits test-rdt test-hook-injector test-writable-cgroups -SKIPPED_PKGS="ulimit-adjuster,device-injector,rdt,hook-injector,writable-cgroups" - -ginkgo-tests: - $(Q)$(GINKGO) run \ - --race \ - --trace \ - --cover \ - --covermode atomic \ - --output-dir $(COVERAGE_PATH) \ - --junit-report junit.xml \ - --coverprofile coverprofile \ - --succinct \ - --skip-package $(SKIPPED_PKGS) \ - -r && \ - $(GO_CMD) tool cover -html=$(COVERAGE_PATH)/coverprofile -o $(COVERAGE_PATH)/coverage.html +test-main: + $(Q)mkdir -p $(COVERAGE_PATH) + $(Q)$(GO_CMD) test \ + -v \ + -race \ + -covermode=atomic \ + -coverprofile=$(COVERAGE_PATH)/coverprofile \ + ./... && \ + $(GO_CMD) tool cover \ + -html=$(COVERAGE_PATH)/coverprofile \ + -o $(COVERAGE_PATH)/coverage.html test-ulimits: $(Q)cd ./plugins/ulimit-adjuster && $(GO_TEST) -v @@ -237,6 +232,3 @@ install-wasm-plugin: install-protoc-dependencies: $(Q)GOBIN="$(PROTOC_PATH)/bin" $(GO_INSTALL) google.golang.org/protobuf/cmd/protoc-gen-go - -install-ginkgo: - $(Q)$(GO_INSTALL) -mod=mod github.com/onsi/ginkgo/v2/ginkgo diff --git a/go.mod b/go.mod index eda71edd..660a04a8 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,6 @@ require ( github.com/google/go-cmp v0.7.0 github.com/knqyf263/go-plugin v0.9.0 github.com/moby/sys/mountinfo v0.7.2 - github.com/onsi/ginkgo/v2 v2.19.1 - github.com/onsi/gomega v1.34.0 github.com/opencontainers/runtime-spec v1.3.0 github.com/sirupsen/logrus v1.9.4 github.com/stretchr/testify v1.12.1 @@ -23,16 +21,9 @@ require ( require ( github.com/containerd/log v0.1.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect github.com/planetscale/vtprotobuf v0.4.0 // indirect - golang.org/x/net v0.48.0 // indirect - golang.org/x/text v0.32.0 // indirect - golang.org/x/tools v0.40.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) tool ( diff --git a/go.sum b/go.sum index fb8ef42e..67d427b2 100644 --- a/go.sum +++ b/go.sum @@ -5,26 +5,16 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ= github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/planetscale/vtprotobuf v0.4.0 h1:NEI+g4woRaAZgeZ3sAvbtyvMBRjIv5kE7EWYQ8m4JwY= @@ -44,14 +34,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= @@ -62,8 +50,5 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/net/multiplex/mux_suite_test.go b/pkg/net/multiplex/mux_suite_test.go index 4d3d0e59..86492045 100644 --- a/pkg/net/multiplex/mux_suite_test.go +++ b/pkg/net/multiplex/mux_suite_test.go @@ -17,454 +17,287 @@ package multiplex_test import ( + "errors" "fmt" "net" "strings" "sync" "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "github.com/stretchr/testify/require" nrinet "github.com/containerd/nri/pkg/net" mux "github.com/containerd/nri/pkg/net/multiplex" ) -func TestMultiplex(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Connection Multiplexer") -} +func TestOpen(t *testing.T) { + setup := func(t *testing.T) (mux.Mux, mux.Mux) { + t.Helper() -var _ = Describe("Emulated Connection Setup, Open", func() { - var ( - lMux, pMux mux.Mux - connID mux.ConnID - lConn, pConn net.Conn - err error - ) - - BeforeEach(func() { - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - connID = mux.LowestConnID - }) - - AfterEach(func() { - if lMux != nil { + lMux, pMux, err := connectMuxes() + require.NoError(t, err) + require.NotNil(t, lMux) + require.NotNil(t, pMux) + t.Cleanup(func() { lMux.Close() - } - if pMux != nil { pMux.Close() - } - }) + }) + return lMux, pMux + } - It("Open should return a net.Conn", func() { - // When - lConn, err = lMux.Open(connID) + t.Run("Open should return a net.Conn", func(t *testing.T) { + lMux, _ := setup(t) - // Then - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) + lConn, err := lMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, lConn) }) - It("Opened net.Conn should allow sending", func() { - // Given - lConn, err = lMux.Open(connID) - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) + t.Run("Opened net.Conn should allow sending", func(t *testing.T) { + lMux, _ := setup(t) - // When - _, err = lConn.Write([]byte("this is a test message")) + lConn, err := lMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, lConn) - // Then - Expect(err).To(BeNil()) + _, err = lConn.Write([]byte("this is a test message")) + require.NoError(t, err) }) - It("Opened net.Conn should allow receiving", func() { - // Given - pConn, err = pMux.Open(connID) - Expect(err).To(BeNil()) - Expect(pConn).ToNot(BeNil()) + t.Run("Opened net.Conn should allow receiving", func(t *testing.T) { + lMux, pMux := setup(t) - // When - lConn, err = lMux.Open(connID) - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) + pConn, err := pMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, pConn) + + lConn, err := lMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, lConn) msg := "this is a test message" _, err = lConn.Write([]byte(msg)) - Expect(err).To(BeNil()) + require.NoError(t, err) - // Then buf := make([]byte, len(msg)) _, err = pConn.Read(buf) - Expect(err).To(BeNil()) - Expect(string(buf)).To(Equal(msg)) + require.NoError(t, err) + require.Equal(t, msg, string(buf)) }) -}) - -var _ = Describe("Emulated Connection Setup, Close", func() { - var ( - lMux, pMux mux.Mux - connID mux.ConnID - lConn, pConn net.Conn - err error - ) +} - BeforeEach(func() { - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - - connID = mux.LowestConnID - lConn, err = lMux.Open(connID) - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) - pConn, err = pMux.Open(connID) - Expect(err).To(BeNil()) - Expect(pConn).ToNot(BeNil()) - }) +func TestClose(t *testing.T) { + setup := func(t *testing.T) (net.Conn, net.Conn) { + t.Helper() - AfterEach(func() { - if lMux != nil { + lMux, pMux, err := connectMuxes() + require.NoError(t, err) + require.NotNil(t, lMux) + require.NotNil(t, pMux) + t.Cleanup(func() { lMux.Close() - } - if pMux != nil { pMux.Close() - } - }) + }) + + lConn, err := lMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, lConn) + pConn, err := pMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, pConn) + return lConn, pConn + } + + t.Run("Closed connection should fail sending", func(t *testing.T) { + lConn, _ := setup(t) - It("Closed connection should fail sending", func() { - // Given msg := "this is a test message" - _, err = lConn.Write([]byte(msg)) - Expect(err).To(BeNil()) + _, err := lConn.Write([]byte(msg)) + require.NoError(t, err) - // When - err = lConn.Close() - Expect(err).To(BeNil()) + require.NoError(t, lConn.Close()) - // Then _, err = lConn.Write([]byte(msg)) - Expect(err).ToNot(BeNil()) + require.Error(t, err) }) - It("Closed connection should fail receiving", func() { - // Given - err = pConn.Close() - Expect(err).To(BeNil()) + t.Run("Closed connection should fail receiving", func(t *testing.T) { + _, pConn := setup(t) - // When - buf := make([]byte, 64) - _, err = pConn.Read(buf) + require.NoError(t, pConn.Close()) - // Then - Expect(err).ToNot(BeNil()) + buf := make([]byte, 64) + _, err := pConn.Read(buf) + require.Error(t, err) }) -}) +} -var _ = Describe("Emulated Connection Setup, Dial", func() { - var ( - lMux, pMux mux.Mux - connID mux.ConnID - conn net.Conn - err error - ) +func TestDial(t *testing.T) { + setup := func(t *testing.T) mux.Mux { + t.Helper() - BeforeEach(func() { - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - connID = mux.LowestConnID - }) - - AfterEach(func() { - if lMux != nil { + lMux, pMux, err := connectMuxes() + require.NoError(t, err) + require.NotNil(t, lMux) + require.NotNil(t, pMux) + t.Cleanup(func() { lMux.Close() - } - if pMux != nil { pMux.Close() - } - }) + }) + return lMux + } dial := func(m mux.Mux, connID mux.ConnID) (net.Conn, error) { return m.Dialer(connID)("mux", "id") } - It("Dial should return a net.Conn", func() { - // When - conn, err = dial(lMux, connID) + t.Run("Dial should return a net.Conn", func(t *testing.T) { + lMux := setup(t) - // Then - Expect(err).To(BeNil()) - Expect(conn).ToNot(BeNil()) + conn, err := dial(lMux, mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, conn) }) - It("Dialed net.Conn should allow sending", func() { - // Given - conn, err = dial(lMux, connID) - Expect(err).To(BeNil()) - Expect(conn).ToNot(BeNil()) + t.Run("Dialed net.Conn should allow sending", func(t *testing.T) { + lMux := setup(t) - // When - _, err = conn.Write([]byte("this is a test message")) + conn, err := dial(lMux, mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, conn) - // Then - Expect(err).To(BeNil()) + _, err = conn.Write([]byte("this is a test message")) + require.NoError(t, err) }) +} -}) - -var _ = Describe("Emulated Connection Setup, Listen, Accept", func() { - var ( - lMux, pMux mux.Mux - connID mux.ConnID - l net.Listener - lConn, pConn net.Conn - err error - ) - - BeforeEach(func() { - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - connID = mux.LowestConnID - }) +func TestListenAccept(t *testing.T) { + setup := func(t *testing.T) (mux.Mux, mux.Mux) { + t.Helper() - AfterEach(func() { - if lMux != nil { + lMux, pMux, err := connectMuxes() + require.NoError(t, err) + require.NotNil(t, lMux) + require.NotNil(t, pMux) + t.Cleanup(func() { lMux.Close() - } - if pMux != nil { pMux.Close() - } - }) + }) + return lMux, pMux + } - accept := func(m mux.Mux, connID mux.ConnID) (net.Conn, error) { - l, err = m.Listen(connID) + accept := func(m mux.Mux, connID mux.ConnID) (net.Listener, net.Conn, error) { + l, err := m.Listen(connID) if err != nil { - return nil, err + return nil, nil, err } - return l.Accept() + conn, err := l.Accept() + return l, conn, err } - It("Listen should return a net.Listener", func() { - // When - l, err = pMux.Listen(connID) + t.Run("Listen should return a net.Listener", func(t *testing.T) { + _, pMux := setup(t) - // Then - Expect(err).To(BeNil()) - Expect(l).ToNot(BeNil()) + l, err := pMux.Listen(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, l) }) - It("Accept on the net.Listener should return a net.Conn", func() { - // When - pConn, err = accept(pMux, connID) + t.Run("Accept on the net.Listener should return a net.Conn", func(t *testing.T) { + _, pMux := setup(t) - // Then - Expect(err).To(BeNil()) - Expect(pConn).ToNot(BeNil()) + _, pConn, err := accept(pMux, mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, pConn) }) - It("Accepted net.Conn should allow receiving", func() { - // Given - pConn, err = accept(pMux, connID) - Expect(err).To(BeNil()) - Expect(pConn).ToNot(BeNil()) + t.Run("Accepted net.Conn should allow receiving", func(t *testing.T) { + lMux, pMux := setup(t) - // When - lConn, err = lMux.Open(connID) - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) + _, pConn, err := accept(pMux, mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, pConn) + + lConn, err := lMux.Open(mux.LowestConnID) + require.NoError(t, err) + require.NotNil(t, lConn) msg := "this is a test message" _, err = lConn.Write([]byte(msg)) - Expect(err).To(BeNil()) + require.NoError(t, err) - // Then buf := make([]byte, len(msg)) _, err = pConn.Read(buf) - Expect(err).To(BeNil()) - Expect(string(buf)).To(Equal(msg)) - }) - -}) - -var _ = Describe("Transmitting data", func() { - var ( - lMux mux.Mux - pMux mux.Mux - err error - ) - - When("single connection", func() { - It("send and receive messages", func() { - connCnt := 1 - msgCnt := 64 - - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - - lConn, pConn, err := openMuxes(lMux, pMux, connCnt) - Expect(err).To(BeNil()) - Expect(len(lConn)).To(Equal(connCnt)) - Expect(len(pConn)).To(Equal(connCnt)) - - sendAndReceive(lConn, pConn, msgCnt) - }) + require.NoError(t, err) + require.Equal(t, msg, string(buf)) }) +} - When("multiple connections", func() { - It("send and receive messages concurrently", func() { - connCnt := 16 - msgCnt := 64 - - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - - lConn, pConn, err := openMuxes(lMux, pMux, connCnt) - Expect(err).To(BeNil()) - Expect(len(lConn)).To(Equal(connCnt)) - Expect(len(pConn)).To(Equal(connCnt)) - - sendAndReceive(lConn, pConn, msgCnt) - }) - }) +func TestTransmittingData(t *testing.T) { + setup := func(t *testing.T, connCnt int) ([]net.Conn, []net.Conn) { + t.Helper() - When("an oversized message is sent", func() { - It("it is transmitted in multiple chunks", func() { - var ( - connCnt = 1 - maxPayloadSize = 10 + 4<<20 - overflowFactor = 3 - ) - - lMux, pMux, err = connectMuxes() - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - - lConn, pConn, err := openMuxes(lMux, pMux, connCnt) - Expect(err).To(BeNil()) - Expect(len(lConn)).To(Equal(connCnt)) - Expect(len(pConn)).To(Equal(connCnt)) - - msg := strings.Repeat("a", overflowFactor*maxPayloadSize) - cnt, err := lConn[0].Write([]byte(msg)) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(len([]byte(msg)))) - - rcv := make([]byte, overflowFactor*maxPayloadSize) - size := 0 - for i := 0; size < len([]byte(msg)) && i < overflowFactor; i++ { - cnt, err := pConn[0].Read(rcv[size:]) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(maxPayloadSize)) - size += cnt - } - Expect(rcv).To(Equal([]byte(msg))) - - msg = strings.Repeat("b", 200) - cnt, err = lConn[0].Write([]byte(msg)) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(len([]byte(msg)))) - - rcv = make([]byte, len([]byte(msg))) - cnt, err = pConn[0].Read(rcv) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(len([]byte(msg)))) - Expect(rcv).To(Equal([]byte(msg))) + lMux, pMux, err := connectMuxes() + require.NoError(t, err) + require.NotNil(t, lMux) + require.NotNil(t, pMux) + t.Cleanup(func() { + lMux.Close() + pMux.Close() }) - }) -}) -/* -// TODO -var _ = Describe("Read Queue Length", func() { - var ( - lMux, pMux mux.Mux - connID mux.ConnID - lConn, pConn net.Conn - err error - qLen = 1 - ) + lConn, pConn, err := openMuxes(lMux, pMux, connCnt) + require.NoError(t, err) + require.Len(t, lConn, connCnt) + require.Len(t, pConn, connCnt) + return lConn, pConn + } - BeforeEach(func() { - lMux, pMux, err = connectMuxes(mux.WithReadQueueLength(qLen)) - Expect(err).To(BeNil()) - Expect(lMux).ToNot(BeNil()) - Expect(pMux).ToNot(BeNil()) - - connID = mux.LowestConnID - lConn, err = lMux.Open(connID) - Expect(err).To(BeNil()) - Expect(lConn).ToNot(BeNil()) - pConn, err = pMux.Open(connID) - Expect(err).To(BeNil()) - Expect(pConn).ToNot(BeNil()) + t.Run("single connection", func(t *testing.T) { + lConn, pConn := setup(t, 1) + require.NoError(t, sendAndReceive(lConn, pConn, 64)) }) - AfterEach(func() { - if lMux != nil { - lMux.Close() - } - if pMux != nil { - pMux.Close() - } + t.Run("multiple connections", func(t *testing.T) { + lConn, pConn := setup(t, 16) + require.NoError(t, sendAndReceive(lConn, pConn, 64)) }) - It("Messages get queued up till queue length", func() { - var msg string - - // When - for i := 0; i < qLen; i++ { - msg = fmt.Sprintf("qlen test message #%d", i) - _, err = lConn.Write([]byte(msg)) - Expect(err).To(BeNil()) - } - - // Then - buf := make([]byte, len(msg)) - for i := 0; i < qLen; i++ { - _, err = pConn.Read(buf) - Expect(err).To(BeNil()) - } - }) + t.Run("an oversized message is transmitted in multiple chunks", func(t *testing.T) { + const ( + maxPayloadSize = 10 + 4<<20 + overflowFactor = 3 + ) - It("Queue overflow closes mux, connections, results in read error", func() { - var msg string + lConn, pConn := setup(t, 1) - // When - for i := 0; i < qLen+1; i++ { - msg = fmt.Sprintf("qlen test message #%d", i) - _, err = lConn.Write([]byte(msg)) - Expect(err).To(BeNil()) - } + msg := strings.Repeat("a", overflowFactor*maxPayloadSize) + cnt, err := lConn[0].Write([]byte(msg)) + require.NoError(t, err) + require.Equal(t, len(msg), cnt) - // Then - buf := make([]byte, len(msg)) - for i := 0; i < qLen; i++ { - _, err = pConn.Read(buf) + rcv := make([]byte, overflowFactor*maxPayloadSize) + size := 0 + for i := 0; size < len(msg) && i < overflowFactor; i++ { + cnt, err := pConn[0].Read(rcv[size:]) + require.NoError(t, err) + require.Equal(t, maxPayloadSize, cnt) + size += cnt } - _, err = pConn.Read(buf) - Expect(err).ToNot(BeNil()) - + require.Equal(t, []byte(msg), rcv) + + msg = strings.Repeat("b", 200) + cnt, err = lConn[0].Write([]byte(msg)) + require.NoError(t, err) + require.Equal(t, len(msg), cnt) + + rcv = make([]byte, len(msg)) + cnt, err = pConn[0].Read(rcv) + require.NoError(t, err) + require.Equal(t, len(msg), cnt) + require.Equal(t, []byte(msg), rcv) }) -}) - -var _ = Describe("Blocking and Unblocking", func() { - // TODO... -}) -*/ +} // getSocketPairConn returns connections for a socketpair. func getSocketPairConn() (net.Conn, net.Conn, error) { @@ -528,90 +361,129 @@ func openMuxes(lMux, pMux mux.Mux, count int) ([]net.Conn, []net.Conn, error) { return lConn, pConn, nil } -func sendAndReceive(lConn, pConn []net.Conn, msgCount int) { - var ( - wg = &sync.WaitGroup{} - start = make(chan struct{}) - maxMsg = 64 - endMsg = "" - ) +func sendAndReceive(lConn, pConn []net.Conn, msgCount int) error { + const maxMsg = 64 - // message sender - write := func(id int, conn net.Conn, messages []string) []string { - var ( - msg string - cnt int - err error - ) + var wg sync.WaitGroup + start := make(chan struct{}) + errs := make(chan error, 1) + var failOnce sync.Once + fail := func(err error) { + failOnce.Do(func() { + errs <- err + for _, conn := range lConn { + conn.Close() + } + for _, conn := range pConn { + conn.Close() + } + }) + } + + write := func(id int, conn net.Conn, messages []string) ([]string, error) { if messages == nil { for i := 0; i < msgCount; i++ { msg := fmt.Sprintf("[%d] message #%d/%d", id, i+1, msgCount) - Expect(len(msg) <= maxMsg).To(BeTrue()) + if len(msg) > maxMsg { + return nil, fmt.Errorf("message length %d exceeds maximum %d", len(msg), maxMsg) + } messages = append(messages, msg) } } - for _, msg = range messages { - cnt, err = conn.Write([]byte(msg)) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(len(msg))) + for _, msg := range messages { + cnt, err := conn.Write([]byte(msg)) + if err != nil { + return nil, err + } + if cnt != len(msg) { + return nil, fmt.Errorf("wrote %d bytes, expected %d", cnt, len(msg)) + } } - cnt, err = conn.Write([]byte(endMsg)) - Expect(err).To(BeNil()) - Expect(cnt).To(Equal(len(endMsg))) + cnt, err := conn.Write(nil) + if err != nil { + return nil, err + } + if cnt != 0 { + return nil, fmt.Errorf("wrote %d bytes for end message, expected 0", cnt) + } - return messages + return messages, nil } - // message receiver and collector - read := func(conn net.Conn) []string { - var ( - msg = make([]byte, maxMsg) - recv []string - cnt int - err error - ) - + read := func(conn net.Conn) ([]string, error) { + msg := make([]byte, maxMsg) + var recv []string for { - cnt, err = conn.Read(msg) - Expect(err).To(BeNil()) + cnt, err := conn.Read(msg) + if err != nil { + return nil, err + } if cnt == 0 { - return recv + return recv, nil } recv = append(recv, string(msg[:cnt])) } } - // send and receive, or the other way around, check echoed messages for equality sendrecv := func(id int, conn net.Conn, sender bool) { - var ( - sent []string - recv []string - ) - defer wg.Done() <-start if sender { - sent = write(id, conn, nil) - recv = read(conn) - Expect(sent).To(Equal(recv)) - } else { - recv = read(conn) - write(id, conn, recv) + sent, err := write(id, conn, nil) + if err != nil { + fail(err) + return + } + recv, err := read(conn) + if err != nil { + fail(err) + return + } + if !equalStrings(sent, recv) { + fail(errors.New("sent and received messages differ")) + } + return + } + + recv, err := read(conn) + if err != nil { + fail(err) + return + } + if _, err := write(id, conn, recv); err != nil { + fail(err) } } - // set up senders and receivers, waiting for a trigger to start for i := 0; i < len(lConn); i++ { + wg.Add(2) go sendrecv(i, lConn[i], true) go sendrecv(i, pConn[i], false) - wg.Add(2) } - // trigger senders/receivers and wait for them to finish close(start) wg.Wait() + + select { + case err := <-errs: + return err + default: + return nil + } +} + +func equalStrings(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true } diff --git a/plugins/device-injector/go.sum b/plugins/device-injector/go.sum index d6891b5c..ca7828e1 100644 --- a/plugins/device-injector/go.sum +++ b/plugins/device-injector/go.sum @@ -6,24 +6,14 @@ github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRq github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -38,14 +28,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -59,7 +47,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/plugins/differ/go.sum b/plugins/differ/go.sum index 21cb8a3d..e5fb29ca 100644 --- a/plugins/differ/go.sum +++ b/plugins/differ/go.sum @@ -139,8 +139,6 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= @@ -153,10 +151,7 @@ github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= @@ -242,8 +237,6 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEivX+9mPgw= github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -426,15 +419,10 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.1 h1:foqVmeWDD6yYpK+Yz3fHyNIxFYNxswxqNFjSKe+vI54= github.com/onsi/ginkgo v1.16.1/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -864,8 +852,6 @@ golang.org/x/tools v0.0.0-20210104081019-d8d6ddbec6ee/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -987,8 +973,6 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/plugins/hook-injector/go.sum b/plugins/hook-injector/go.sum index 4233a0a5..eb6c3240 100644 --- a/plugins/hook-injector/go.sum +++ b/plugins/hook-injector/go.sum @@ -1,5 +1,3 @@ -github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= -github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/brianvoe/gofakeit/v7 v7.12.1 h1:df1tiI4SL1dR5Ix4D/r6a3a+nXBJ/OBGU5jEKRBmmqg= github.com/brianvoe/gofakeit/v7 v7.12.1/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= @@ -9,26 +7,16 @@ github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY= -github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/onsi/ginkgo/v2 v2.26.0 h1:1J4Wut1IlYZNEAWIV3ALrT9NfiaGW2cDCJQSFQMs/gE= -github.com/onsi/ginkgo/v2 v2.26.0/go.mod h1:qhEywmzWTBUY88kfO0BRvX4py7scov9yR+Az2oavUzw= -github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A= -github.com/onsi/gomega v1.38.2/go.mod h1:W2MJcYxRGV63b418Ai34Ud0hEdTVXq9NW9+Sx6uXf3k= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -45,24 +33,18 @@ go.podman.io/common v0.66.1 h1:zDyd4HhVgQAN8LupBHCnhtM3FEOJ9DwmThjulXZq2qA= go.podman.io/common v0.66.1/go.mod h1:aNd2a0S7pY+fx1X5kpQYuF4hbwLU8ZOccuVrhu7h1Xc= go.podman.io/storage v1.61.0 h1:5hD/oyRYt1f1gxgvect+8syZBQhGhV28dCw2+CZpx0Q= go.podman.io/storage v1.61.0/go.mod h1:A3UBK0XypjNZ6pghRhuxg62+2NIm5lcUGv/7XyMhMUI= -go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= -go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM= +golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= diff --git a/plugins/logger/go.sum b/plugins/logger/go.sum index d6891b5c..ca7828e1 100644 --- a/plugins/logger/go.sum +++ b/plugins/logger/go.sum @@ -6,24 +6,14 @@ github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRq github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -38,14 +28,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -59,7 +47,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/plugins/network-device-injector/go.sum b/plugins/network-device-injector/go.sum index a6b6b82c..57d84702 100644 --- a/plugins/network-device-injector/go.sum +++ b/plugins/network-device-injector/go.sum @@ -8,22 +8,21 @@ github.com/containernetworking/cni v1.1.2 h1:wtRGZVv7olUHMOqouPpn3cXJWpJgM6+EUl3 github.com/containernetworking/cni v1.1.2/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw= github.com/containernetworking/plugins v1.4.1 h1:+sJRRv8PKhLkXIl6tH1D7RMi+CbbHutDGU+ErLBORWA= github.com/containernetworking/plugins v1.4.1/go.mod h1:n6FFGKcaY4o2o5msgu/UImtoC+fpQXM3076VHfHbj60= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk= +github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= +github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= +github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= +github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= +github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -43,14 +42,14 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434 h1:umK/Ey0QEzurTNlsV3R+MfxHAb78HCEX/IkuR+zH4WQ= diff --git a/plugins/network-logger/go.sum b/plugins/network-logger/go.sum index 86887c1e..ef482947 100644 --- a/plugins/network-logger/go.sum +++ b/plugins/network-logger/go.sum @@ -4,24 +4,14 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ= github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -36,14 +26,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -53,5 +41,3 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/rdt/go.sum b/plugins/rdt/go.sum index 86887c1e..ef482947 100644 --- a/plugins/rdt/go.sum +++ b/plugins/rdt/go.sum @@ -4,24 +4,14 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ= github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -36,14 +26,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -53,5 +41,3 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/template/go.sum b/plugins/template/go.sum index d6891b5c..ca7828e1 100644 --- a/plugins/template/go.sum +++ b/plugins/template/go.sum @@ -6,24 +6,14 @@ github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRq github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -38,14 +28,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -59,7 +47,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/plugins/ulimit-adjuster/go.sum b/plugins/ulimit-adjuster/go.sum index d6891b5c..ca7828e1 100644 --- a/plugins/ulimit-adjuster/go.sum +++ b/plugins/ulimit-adjuster/go.sum @@ -6,24 +6,14 @@ github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRq github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -38,14 +28,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -59,7 +47,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/plugins/wasm/go.sum b/plugins/wasm/go.sum index c1bc73d7..ef482947 100644 --- a/plugins/wasm/go.sum +++ b/plugins/wasm/go.sum @@ -26,12 +26,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= diff --git a/plugins/writable-cgroups/go.sum b/plugins/writable-cgroups/go.sum index 3f84d4ae..263ad0ec 100644 --- a/plugins/writable-cgroups/go.sum +++ b/plugins/writable-cgroups/go.sum @@ -4,26 +4,16 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ= github.com/containerd/ttrpc v1.2.7/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/knqyf263/go-plugin v0.9.0 h1:CQs2+lOPIlkZVtcb835ZYDEoyyWJWLbSTWeCs0EwTwI= github.com/knqyf263/go-plugin v0.9.0/go.mod h1:2z5lCO1/pez6qGo8CvCxSlBFSEat4MEp1DrnA+f7w8Q= github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= -github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= -github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= -github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= -github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= @@ -38,14 +28,12 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d h1:pgIUhmqwKOUlnKna4r6amKdUngdL8DrkpFeV8+VBElY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= @@ -55,5 +43,3 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=