Skip to content

Improvements to end-to-end tests#417

Merged
qdeslandes merged 5 commits intofacebook:mainfrom
qdeslandes:improve_e2e
Feb 13, 2026
Merged

Improvements to end-to-end tests#417
qdeslandes merged 5 commits intofacebook:mainfrom
qdeslandes:improve_e2e

Conversation

@qdeslandes
Copy link
Contributor

@qdeslandes qdeslandes commented Feb 13, 2026

Multiple improvements to end-to-end tests:

  • Define set -eux within the tests boilerplate, so it doesn't need to be set from each test
  • Use unique resources names to allow tests to run in parallel (fix 2 tests relying on system resources instead of the sandbox ones)
  • Run cleanup() from the tests boilerplate to prevent any left-over from previous runs
  • Do not run tests in user namespace: the new implement to restore the daemon's context will depend on BPF_OBJ_GET_INFO_BY_FD which doesn't support BPF token yet

Related to #382

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.
Copilot AI review requested due to automatic review settings February 13, 2026 11:06
@meta-cla meta-cla bot added the cla signed label Feb 13, 2026
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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) in tests/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 bpftool output).

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.
@qdeslandes qdeslandes merged commit cad574e into facebook:main Feb 13, 2026
29 checks passed
@qdeslandes qdeslandes deleted the improve_e2e branch February 13, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant