Skip to content

Commit

Permalink
pkg/sensors: add a test for override map resize
Browse files Browse the repository at this point in the history
[ upstream commit 659704f ]

Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Jul 19, 2024
1 parent 42c41c0 commit c028288
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/sensors/tracing/kprobe_maxentries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/cilium/ebpf"
"github.com/cilium/tetragon/pkg/bpf"
"github.com/cilium/tetragon/pkg/observer/observertesthelper"
"github.com/cilium/tetragon/pkg/sensors"
tus "github.com/cilium/tetragon/pkg/testutils/sensors"
Expand Down Expand Up @@ -72,6 +73,7 @@ func TestMaxEntries(t *testing.T) {
{"fdinstall_map", 1},
{"stack_trace_map", 1},
{"ratelimit_map", 1},
{"override_tasks", 1},
}, `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
Expand All @@ -89,6 +91,7 @@ spec:
{"fdinstall_map", fdInstallMapMaxEntries},
{"stack_trace_map", 1},
{"ratelimit_map", 1},
{"override_tasks", 1},
}, `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
Expand Down Expand Up @@ -121,6 +124,7 @@ spec:
{"fdinstall_map", 1},
{"stack_trace_map", stackTraceMapMaxEntries},
{"ratelimit_map", 1},
{"override_tasks", 1},
}, `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
Expand All @@ -143,6 +147,7 @@ spec:
{"fdinstall_map", 1},
{"stack_trace_map", 1},
{"ratelimit_map", ratelimitMapMaxEntries},
{"override_tasks", 1},
}, `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
Expand All @@ -164,6 +169,40 @@ spec:
matchActions:
- action: Post
rateLimit: "1m"
`)
})

t.Run("override_tasks", func(t *testing.T) {
if !bpf.HasOverrideHelper() {
t.Skip("skipping test, neither bpf_override_return nor fmod_ret for syscalls is available")
}

run(t, []testMap{
{"fdinstall_map", 1},
{"stack_trace_map", 1},
{"ratelimit_map", 1},
{"override_tasks", overrideMapMaxEntries},
}, `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "override-example"
spec:
kprobes:
- call: "sys_symlinkat"
syscall: true
args:
- index: 0
type: "string"
selectors:
- matchArgs:
- index: 0
operator: "Equal"
values:
- "/etc/passwd"
matchActions:
- action: Override
argError: -1
`)
})
}

0 comments on commit c028288

Please sign in to comment.