Skip to content

Minor clean-up for flow-filter tests#1332

Open
qmonnet wants to merge 4 commits intomainfrom
pr/qmonnet/simplify-flow-filter-tests
Open

Minor clean-up for flow-filter tests#1332
qmonnet wants to merge 4 commits intomainfrom
pr/qmonnet/simplify-flow-filter-tests

Conversation

@qmonnet
Copy link
Member

@qmonnet qmonnet commented Mar 11, 2026

Tests in flow-filter's lib.rs have grown quite a lot, I tried to "condense" them a little by making them slightly less verbose. They were still taking a huge portion of the file, so I also moved them to a separate file.

There's no functional change (even in tests), although we do add an argument to .make_port_forwarding().

qmonnet added 2 commits March 11, 2026 02:41
We want to make the code for the flow-filter tests less verbose.

Add some helpers to determine what NAT mode is required for a packet
exiting the flow-filter stage. Contrary to the existing methods for
metadata .requires_...(), these helpers check that a given flag is set
but also that flags for other modes are not set. This avoids checking
three different requirements each time we assess a packet in tests.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
We want to make the code for the flow-filter tests less verbose. To that
end, we condense the assessment of the packets processed by the
flow-filter, in flow-filter tests: we directly assume there's only one
packet in the output and don't validate the length, making the code
slightly simpler and easier to read. Given that it's less dense, we also
remove some blank lines to condense the tests more.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
@qmonnet qmonnet requested a review from Fredi-raspall March 11, 2026 02:45
@qmonnet qmonnet self-assigned this Mar 11, 2026
@qmonnet qmonnet requested a review from a team as a code owner March 11, 2026 02:45
Copilot AI review requested due to automatic review settings March 11, 2026 02:45
@qmonnet qmonnet enabled auto-merge March 11, 2026 02:45
Copy link
Contributor

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

Refactors the flow-filter crate’s unit tests by moving the large #[cfg(test)] mod tests block out of lib.rs into a dedicated tests.rs module and introducing small helper utilities to reduce verbosity. As part of making port-forwarding tests less ad-hoc, it also extends VpcExpose::make_port_forwarding to accept an optional L4 protocol and updates call sites accordingly.

Changes:

  • Move flow-filter tests from flow-filter/src/lib.rs into flow-filter/src/tests.rs and simplify assertions/helpers.
  • Extend VpcExpose::make_port_forwarding to accept proto: Option<L4Protocol> and apply it to nat.proto.
  • Update all in-repo call sites/tests to the new make_port_forwarding signature.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
nat/src/stateful/apalloc/setup.rs Updates test call sites to new make_port_forwarding(None, None) signature.
flow-filter/src/tests.rs New test module containing the moved/condensed flow-filter tests.
flow-filter/src/setup.rs Updates test call sites to new make_port_forwarding(None, None) signature.
flow-filter/src/lib.rs Removes inline tests module and wires in #[cfg(test)] mod tests;.
config/src/external/overlay/vpcpeering.rs Updates VpcExpose::make_port_forwarding API to accept optional protocol and sets nat.proto.
config/src/converters/k8s/config/expose.rs Updates converter call site to pass the new proto argument.

qmonnet added 2 commits March 11, 2026 03:21
We want to make the code for the flow-filter tests less verbose.

Let's make it possible to specify the L4 protocol to use for port
forwarding rules with the VpcExpose method .make_port_forwarding(). This
way, we can pass expose definitions inline to peering_table.add(), even
if we need to define a port forwarding block for TCP only or UDP only.
It's more consistent, and less verbose.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
The tests have grown quite a lot in flow-filter/src/lib.rs and it is not
very convenient to have such a large portion of the file occupied by
tests. Let's move them to a separate file.

Submodules retain their own tests.

Signed-off-by: Quentin Monnet <qmo@qmon.net>
@qmonnet qmonnet force-pushed the pr/qmonnet/simplify-flow-filter-tests branch from d4b9ba6 to 7d931a9 Compare March 11, 2026 03:21
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.

2 participants