Improvements to end-to-end tests#417
Merged
qdeslandes merged 5 commits intofacebook:mainfrom Feb 13, 2026
Merged
Conversation
Each end-to-end script uses `set -eux`, so it might as well be moved into the tests boilerplate script.
Derive resources (e.g. network namespace name) from the test name: - Allow for cleaning up the left-over resources before running the test, to prevent spurious failures (ctest won't let the cleanup run on failure). - Allow tests to be run in parallel as they use different resources.
Using a user namespace requires bpfilter to run with a BPF token. However, we plan to restore the bf_map from the maps pinned to the bpffs, but the kernel doesn't support passing a BPF token to BPF_OBJ_GET_INFO_BY_FD or BPF_PROG_MAP_GET_FD_BY_ID yet. This change will ensure we can run the tests in a realistic deployment environment.
8d7fd37 to
a78ab27
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability and parallelizability of the tests/e2e bash end-to-end suite by centralizing common shell strict-mode behavior in e2e_test_util.sh, deriving per-test sandbox resource names, and adding pre-run cleanup to reduce interference from previous runs.
Changes:
- Centralize test boilerplate (
set -eux, cleanup/traps, deterministic WORKDIR/netns/veth/IP naming) intests/e2e/e2e_test_util.sh. - Remove duplicated strict-mode boilerplate (
set -eux,set -o pipefail) from individual e2e test scripts. - Update a couple of tests to validate resources via the sandbox bpffs contents (instead of host/global
bpftooloutput).
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/rulesets/rulesets.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/redirect.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/mark.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/log.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/icmp_xdp.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/icmp_tc.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/rules/action_order.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/udp_sport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/udp_dport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/tcp_sport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/tcp_flags.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/tcp_dport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/set.sh | Switch map-count assertion to check pinned resources in sandbox bpffs. |
| tests/e2e/matchers/named_set.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_sport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_probability.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_mark.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_l4_proto.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_l3_proto.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_iface.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_flow_hash.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/meta_dport.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_snet.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_saddr.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_nexthdr.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_dscp.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_dnet.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip6_daddr.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_snet.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_saddr.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_proto.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_dscp.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_dnet.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/ip4_daddr.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/icmpv6_type.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/icmpv6_code.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/icmp_type.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/matchers/icmp_code.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/e2e_test_util.sh | Implement shared strict-mode + deterministic per-test sandbox resource naming + cleanup/traps; remove user-namespace/token logic. |
| tests/e2e/daemon/sock_exists.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/restore_non_attached.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/restore_attached.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/pin_updated_chain.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/netns_to_host.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/host_to_netns.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/daemon/already_running.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/ruleset.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/options_error.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/nf_inet_dual_stack.sh | Validate dual-stack link creation/removal via sandbox bpffs pins instead of host bpftool. |
| tests/e2e/cli/hookopts.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/chain_update_set.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/chain_update.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/chain_set.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/chain_load.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
| tests/e2e/cli/chain_attach.sh | Remove per-test strict-mode boilerplate in favor of shared util. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Call `cleanup()` from the tests boilerplate before running the tests to ensure no left-over remain.
Fix `nf_inet_dual_stack.sh` and `set.sh` to support running the tests in parallel by relying on the new bpffs instead of the system's one.
a78ab27 to
fa81c99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multiple improvements to end-to-end tests:
set -euxwithin the tests boilerplate, so it doesn't need to be set from each testcleanup()from the tests boilerplate to prevent any left-over from previous runsBPF_OBJ_GET_INFO_BY_FDwhich doesn't support BPF token yetRelated to #382