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

bpf: make BPF unit tests reproducible #31526

Merged
merged 1 commit into from Mar 21, 2024
Merged

bpf: make BPF unit tests reproducible #31526

merged 1 commit into from Mar 21, 2024

Conversation

ti-mo
Copy link
Contributor

@ti-mo ti-mo commented Mar 20, 2024

Currently, we develop the datapath against multiple versions of LLVM: various local (host) toolchains during development, CI uses an LLVM version installed by a GH workflow, and the agent uses the cilium-builder container image.

This PR changes the BPF unit tests to use cilium-builder by default using the run_bpf_tests make target in the root Makefile of the project.

Small overview of the changes:

  • run bpf unit tests CI using the cilium-builder image so we use the same LLVM toolchain across all tests
  • set -j on the root Docker invocation to build .o's in parallel, as building the tests was becoming rather slow
  • moved test/bpf_tests/ to bpf/tests/bpftest to keep the BPF test runner closer to the .c test files it's used with
  • removed the layer of indirection through test/Makefile; the root Makefile now calls bpf/tests/Makefile directly
  • added a run target to bpf/tests/Makefile to make it easier to invoke the tests using the host Go toolchain without rebuilding the world. sudo is now used automatically for 'go test' if make is invoked as a non-root user.
  • cleaned up output generated by bpf/tests/Makefile
Make BPF unit tests reproducible

Currently, we develop the datapath against multiple versions of LLVM: various local
(host) toolchains during development, CI uses an LLVM version installed by a GH workflow,
and the agent uses the cilium-builder container image.

This PR changes the BPF unit tests to use cilium-builder by default using the
`run_bpf_tests` make target in the root Makefile of the project.

Small overview of the changes:
- run bpf unit tests CI using the cilium-builder image so we use the same LLVM
  toolchain across all tests
- set -j<numcpu> on the root Docker invocation to build .o's in parallel, as
  building the tests was becoming rather slow
- moved `test/bpf_tests/` to `bpf/tests/bpftest` to keep the BPF test runner closer
  to the .c test files it's used with
- removed the layer of indirection through `test/Makefile`; the root Makefile now
  calls `bpf/tests/Makefile` directly
- added a `run` target to `bpf/tests/Makefile` to make it easier to invoke the tests
  using the host Go toolchain without rebuilding the world. sudo is now used
  automatically for 'go test' if `make` is invoked as a non-root user.
- cleaned up output generated by bpf/tests/Makefile

Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo added the release-note/ci This PR makes changes to the CI. label Mar 20, 2024
@ti-mo
Copy link
Contributor Author

ti-mo commented Mar 20, 2024

/test

@ti-mo ti-mo marked this pull request as ready for review March 20, 2024 15:15
@ti-mo ti-mo requested review from a team as code owners March 20, 2024 15:15
Copy link
Contributor

@ldelossa ldelossa left a comment

Choose a reason for hiding this comment

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

Nice!

@ti-mo ti-mo enabled auto-merge March 21, 2024 10:50
@ti-mo ti-mo added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit 0b9b390 Mar 21, 2024
235 checks passed
@ti-mo ti-mo deleted the tb/reproducible-bpf-tests branch March 21, 2024 11:02
@ti-mo ti-mo added the backport-pending/1.15 The backport for Cilium 1.15.x for this PR is in progress. label Mar 28, 2024
@rgo3 rgo3 removed the backport-pending/1.15 The backport for Cilium 1.15.x for this PR is in progress. label Apr 2, 2024
@rgo3 rgo3 added the backport-done/1.15 The backport for Cilium 1.15.x for this PR is done. label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.15 The backport for Cilium 1.15.x for this PR is done. release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants