Skip to content

Commit c61611a

Browse files
committed
check bpf progs after tests finish - expect they have not leaked any progs
1 parent eeb64ab commit c61611a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

felix/fv/bpf_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
305305
numericProto uint8
306306
)
307307

308+
leftoverBPFProgsByFelix := make([]map[string]any, 3)
308309
containerIP := func(c *containers.Container) string {
309310
if testOpts.ipv6 {
310311
return c.IPv6
@@ -450,6 +451,19 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
450451
})
451452

452453
JustAfterEach(func() {
454+
for i := range tc.Felixes {
455+
prev := leftoverBPFProgsByFelix[i]
456+
457+
cur, _ := tc.Felixes[i].ExecOutput("bpftool", "-jp", "prog", "show")
458+
curUnmarshalled := make(map[string]any)
459+
json.Unmarshal([]byte(cur), &curUnmarshalled)
460+
461+
if prev != nil {
462+
Expect(prev).To(BeEquivalentTo(curUnmarshalled))
463+
}
464+
leftoverBPFProgsByFelix[i] = curUnmarshalled
465+
}
466+
453467
if CurrentGinkgoTestDescription().Failed {
454468
var (
455469
currBpfsvcs []nat.MapMem

0 commit comments

Comments
 (0)