Make APF packet count assertion more robust

Improve the APF test by changing the packet count assertion from
`== 1` to `> matched_pkt_count_before_test`.

This handles scenarios where the packet counter might already
have a non-zero value or increment due to other traffic, making
the test more reliable. The test now asserts that the specific
test packet caused the counter to increase.

Flag: EXEMPT test only
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Change-Id: Id3c0de786e674214948e7030519fe25383c9958c
This commit is contained in:
Jimi Chen 2025-07-24 11:53:09 +00:00
commit c4fcf02870

View file

@ -140,6 +140,10 @@ class ApfTestBase(multi_devices_test_base.MultiDevicesTestBase):
counter_name,
)
matched_pkt_count_before_test = apf_utils.get_matched_packet_counts(
self.serverDevice, self.server_iface_name, receive_packet
)
# send 3 packets to prevent flaky test result
for _ in range(3):
apf_utils.send_raw_packet_downstream(
@ -150,7 +154,7 @@ class ApfTestBase(multi_devices_test_base.MultiDevicesTestBase):
lambda: apf_utils.get_matched_packet_counts(
self.serverDevice, self.server_iface_name, receive_packet
)
== 1,
> matched_pkt_count_before_test,
# ensure the server device capturing the offload packet on the handler thread
retry_interval_sec=3,
)