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

Refactor ebpf test runner #208

Merged
merged 36 commits into from
Sep 26, 2024
Merged

Refactor ebpf test runner #208

merged 36 commits into from
Sep 26, 2024

Conversation

fearful-symmetry
Copy link
Contributor

@fearful-symmetry fearful-symmetry commented Sep 20, 2024

How to run tests

This completely refactors the go testrunner for EventsTrace. This has a number of advantages:

  • tests can now be run locally, without bluebox
  • You can run individual tests
  • Tests are structured in the "standard" golang way, and take advantage of the go stdlib test functionality
  • I added a make testbins target for the c test binaries

This also fixes a few known bugs, and probably many more:

  • The test runner would sometimes eat stderr messages that occur during startup
  • If the test runner got overwhelmed with data from stdout/stderr, it would drop the log data
  • If a test failed, it would sometimes hang and time out instead of immediately failing

In addition, I fixed a few bugs in the tests that I ran into while refactoring:

  • The tty output would try to use the escape character \x, which is not a valid JSON escape character and broke all the JSON parsers I tried.
  • the overlayfs test would try to remove a directory without unmounting it, which would fail

How to run tests

make testbins #make the test binaries in testing/test_bins
cd testing/testrunner
go test -c #compile the test in advance, so we don't need root to have a go environment
# run all tests
sudo ./testrunner.test
# run a single test
sudo ./testrunner.test -test.run TestEbpf/Tcpv6ConnectionClose -test.v

Known issues with individual tests:

  • fork_exec.c works by setting the capabilities mask to an identifiable but meaningless mask value; for whatever reason this works in the test environment, but on my machine the new capability set completely breaks the binary.
  • create_rename_delete_file_container.c breaks on newer kernels if you try to remove the directories before doing an unmount on ovl_mountpoint, but on the mainline tests, and only the mainline tests (which are actually kind of old), this unmount operation fails with an Invalid Argument error.

@fearful-symmetry fearful-symmetry self-assigned this Sep 20, 2024
@fearful-symmetry fearful-symmetry marked this pull request as ready for review September 24, 2024 04:11
@fearful-symmetry fearful-symmetry requested a review from a team as a code owner September 24, 2024 04:11
non-GPL/Events/EventsTrace/EventsTrace.c Show resolved Hide resolved
testing/testrunner/tests.go Show resolved Hide resolved
testing/testrunner/tests.go Show resolved Hide resolved
testing/testrunner/utils.go Outdated Show resolved Hide resolved
testing/testrunner/utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@haesbaert haesbaert left a comment

Choose a reason for hiding this comment

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

I made three small suggestions, basically whitespace.
I was able to run the tests, but it took me awhile to figure why it wasn't working initially, I had a /tmp/foo already in place.

Makefile Show resolved Hide resolved
non-GPL/Events/EventsTrace/EventsTrace.c Show resolved Hide resolved
testing/README.md Show resolved Hide resolved
@fearful-symmetry fearful-symmetry merged commit 99cc9df into main Sep 26, 2024
26 checks passed
@fearful-symmetry fearful-symmetry deleted the test-runner-refactor branch September 26, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants