Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

killer sensor: improve testing #1948

Merged
merged 8 commits into from
Jan 10, 2024
Merged

killer sensor: improve testing #1948

merged 8 commits into from
Jan 10, 2024

Conversation

kkourt
Copy link
Contributor

@kkourt kkourt commented Jan 9, 2024

This PR aims address the fact that our killer sensor tests were always skipped and we never noticed.

The reason was that our CI kernels were not configured with CONFIG_BPF_KPROBE_OVERRIDE. This was fixed in cilium/little-vm-helper-images#286.

Adding the new kernel images (#1907) lead to some test failures that are meant to be addressed in this PR. This was because our CI did not have a ia32 libc: this is addressed by compiling the ia32 program statically

The only way to note that the tests were skipped using t.Skip() was to execute them manually and check the logs. This is not ideal, so this PR adds support to the vmtests for providing detailed results that show what tests are actually skipped and what tests are not.

We introduce a new symbol for the tests that are skipped using t.Skip(): ⚡

Parsing the detailed results allows us to also report sub-tests (i.e., tests executed with t.Run()).

Here's an output example:

✅      pkg.sensors.tracing.Test_Kprobe_DisableEnablePolicy                                     (total:3 failed:0 skipped:0)    2.680496982s    1m33.952671893s
├─✅    Test_Kprobe_DisableEnablePolicy/sensor                                                  1.05s                           (1.05s)
├─✅    Test_Kprobe_DisableEnablePolicy/tracing-policy                                          1.09s                           (2.14s)
└─✅    Test_Kprobe_DisableEnablePolicy                                                         2.56s                           (4.7s)
⚡      pkg.sensors.tracing.TestKillerOverride32                                                (total:1 failed:0 skipped:1)    130.759191ms    1m34.083431084s
⚡      pkg.sensors.tracing.TestKillerSignal32                                                  (total:1 failed:0 skipped:1)    132.393451ms    1m34.215824535s
⚡      pkg.sensors.tracing.TestKillerOverrideBothBits                                          (total:1 failed:0 skipped:1)    119.455061ms    1m34.335279596s
⚡      pkg.sensors.tracing.TestKillerOverride                                                  (total:1 failed:0 skipped:1)    121.255148ms    1m34.456534744s
⚡      pkg.sensors.tracing.TestKillerSignal                                                    (total:1 failed:0 skipped:1)    136.665421ms    1m34.593200165s
✅      pkg.sensors.tracing.TestKillerMulti                                                     (total:1 failed:0 skipped:0)    132.761861ms    1m34.

Note that above is just an example. Killer tests are no longer skipped in kernels other than 4.19:

✅	pkg.sensors.tracing.TestKillerOverride32						(total:1 failed:0 skipped:0)	5.387274581s	2m32.342462607s
✅	pkg.sensors.tracing.TestKillerSignal32							(total:1 failed:0 skipped:0)	5.502833907s	2m37.845296514s
✅	pkg.sensors.tracing.TestKillerOverrideBothBits						(total:1 failed:0 skipped:0)	5.436053879s	2m43.281350393s
✅	pkg.sensors.tracing.TestKillerOverride32						(total:1 failed:0 skipped:0)	5.477340976s	2m48.758691369s
✅	pkg.sensors.tracing.TestKillerOverrideBothBits						(total:1 failed:0 skipped:0)	5.398464379s	2m54.157155748s
✅	pkg.sensors.tracing.TestKillerOverride							(total:1 failed:0 skipped:0)	2.410312467s	2m56.567468215s
✅	pkg.sensors.tracing.TestKillerSignal32							(total:1 failed:0 skipped:0)	5.409613867s	3m1.977082082s
✅	pkg.sensors.tracing.TestKillerSignal							(total:1 failed:0 skipped:0)	2.470995213s	3m4.448077295s
✅	pkg.sensors.tracing.TestKillerMulti							(total:1 failed:0 skipped:0)	498.18272ms	3m4.946260015s

A subsequent PR (#1953) will add:

  • support for fmod_ret for kernels that do not provide CONFIG_BPF_KPROBE_OVERRIDE.
  • the ability to test all different combinations in our kernels. For example, we should test both killer sensors with fmod_ret and bpf_override_return in our CI kernels where CONFIG_BPF_KPROBE_OVERRIDE is set.
  • a check in the killer sensor on whether the bpf_send_signal is supported

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
@kkourt kkourt added the release-note/minor This PR introduces a minor user-visible change label Jan 9, 2024
@kkourt kkourt force-pushed the pr/kkourt/killer-improvements branch 2 times, most recently from 17c3547 to 153eb1a Compare January 9, 2024 09:09
@kkourt kkourt added release-note/ci This PR makes changes to the CI. and removed release-note/minor This PR introduces a minor user-visible change labels Jan 9, 2024
@kkourt kkourt changed the title improvements to the killer sensor: better testing and supporting fmod_ret killer sensor: improve testing Jan 9, 2024
@kkourt kkourt force-pushed the pr/kkourt/killer-improvements branch 2 times, most recently from c34a1a4 to 99b8ebd Compare January 9, 2024 10:40
@kkourt kkourt marked this pull request as ready for review January 9, 2024 11:18
@kkourt kkourt requested review from willfindlay and a team as code owners January 9, 2024 11:18
Currently, if all tests are skipped we print success, which is
misleading. Print a better message.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Previously, we always used "." to list tests in listTests. This patch
adds it as an argument to be used in a later patch.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
This patch improves loading tests form a file.

First, it allows for having comments with lines starting with '#'.

Second, it lists the tests based on the provided user pattern instead of
using it as it is. Previously, the test name was defined by the user
pattern. This lead to inconsistent reporting. This patch fixes this
because now we report per-test results rather than per-pattern results.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
It is possible that a test is a substring of another. Use a strict
pattern so that we execute only the specified test.

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
@kkourt kkourt force-pushed the pr/kkourt/killer-improvements branch from 99b8ebd to 8aef23c Compare January 9, 2024 14:29
kkourt and others added 3 commits January 10, 2024 08:52
There are two ways to skip a test in our CI:
 1. add it to CiBlacklist in split-tetragon-gotests
 2. use t.Skip()

CI results report 1., but they do not report 2.

This means that skipped tests can go easily unnoticed.

To report tests skipped with (2), we need to parse the result files.
This patch does exactly that. It adds a new option
--enable-detailed-results. If this option is set, we set KeepAllLogs
because we need to parse all logs after the tests are finished.

The tests we skip with (1) are marked with ⏭️.
We introduce a new symbol for the tests that are skipped with (2): ⚡

Parsing the detailed results allows us to also report sub-tests (i.e.,
tests executed with t.Run()).

Here's an output example:

```
✅      pkg.sensors.tracing.Test_Kprobe_DisableEnablePolicy                                     (total:3 failed:0 skipped:0)    2.680496982s    1m33.952671893s
├─✅    Test_Kprobe_DisableEnablePolicy/sensor                                                  1.05s                           (1.05s)
├─✅    Test_Kprobe_DisableEnablePolicy/tracing-policy                                          1.09s                           (2.14s)
└─✅    Test_Kprobe_DisableEnablePolicy                                                         2.56s                           (4.7s)
⚡      pkg.sensors.tracing.TestKillerOverride32                                                (total:1 failed:0 skipped:1)    130.759191ms    1m34.083431084s
⚡      pkg.sensors.tracing.TestKillerSignal32                                                  (total:1 failed:0 skipped:1)    132.393451ms    1m34.215824535s
⚡      pkg.sensors.tracing.TestKillerOverrideBothBits                                          (total:1 failed:0 skipped:1)    119.455061ms    1m34.335279596s
⚡      pkg.sensors.tracing.TestKillerOverride                                                  (total:1 failed:0 skipped:1)    121.255148ms    1m34.456534744s
⚡      pkg.sensors.tracing.TestKillerSignal                                                    (total:1 failed:0 skipped:1)    136.665421ms    1m34.593200165s
✅      pkg.sensors.tracing.TestKillerMulti                                                     (total:1 failed:0 skipped:0)    132.761861ms    1m34.725962026s
```

Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Signed-off-by: cilium-renovate[bot] <134692979+cilium-renovate[bot]@users.noreply.github.com>
@kkourt kkourt force-pushed the pr/kkourt/killer-improvements branch from 8aef23c to e0ee8d3 Compare January 10, 2024 07:52
Copy link

netlify bot commented Jan 10, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit e0ee8d3
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/659e4cd28cd2680008cf3d85
😎 Deploy Preview https://deploy-preview-1948--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@olsajiri olsajiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kkourt
Copy link
Contributor Author

kkourt commented Jan 10, 2024

restarted failed e2e test (see #1954) for details.

@kkourt kkourt merged commit 908f4db into main Jan 10, 2024
30 checks passed
@kkourt kkourt deleted the pr/kkourt/killer-improvements branch January 10, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants