Skip to content

[Nexthop] Fix baseline stats retrieval for ACL queue per host tests - #1508

Open
vvasavada-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:fix-baseline-stats-retrieval-acl-queue
Open

[Nexthop] Fix baseline stats retrieval for ACL queue per host tests#1508
vvasavada-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:fix-baseline-stats-retrieval-acl-queue

Conversation

@vvasavada-nexthop

Copy link
Copy Markdown

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

The test expects to run as follows:

  1. Read the counter before (baseline) -> statBefore
  2. Send packets
  3. Read the counter after -> statAfter
  4. Check statAfter - statBefore is expected value

Problem:

The HW agent process polls the ACL counters and pushes them to the SW agent every 1s. Until the first push lands, the SW agent's cached stats map is empty - and the old getAclInOutPackets couldn't distinguish "no HwSwitch has reported this coutner yet" from "the counter reports 0". It returned 0 for both.

Across a warm boot the hardware counter keeps it pre-warmboot value (20). But if the baseline is read before the first stats push arrives, statBefore gets 0 instead of 20, so the delta comes out as the full accumulated count:

  08:57:07.837500 AgentQueuePerHostTests.cpp:231] Verify class id for 1.0.0.14 ...   <- baseline read here
  08:57:07.877734 MultiSwitchThriftHandler.cpp:378] Got stats event from switchIndex 0  <- stats polled
  08:57:10.840604 AgentQueuePerHostTests.cpp:349]  Acl stats : 25                    <- 25-0 != 5, fails 30s
  08:57:41.849150 AgentQueuePerHostTests.cpp:349]  Acl stats : 30                    <- next sub-phase passes

Since statBefore is not in WITH_RETRIES loop, it stays 0 for full 30s until timeout.

Fix:

getAclInOutPacketsIf returns nullopt when no HwSwitch has reported the counter, and 0 only when 0 is genuinely reported. getLatestAclInOutPackets wraps it to wait until the counter is present, mirroring how getLatestPortStats waits for port stats. Only the baseline snapshot switch to it - getAclInOutPackets keeps its existing absent-is-0 behavior, so other tests are unchanged.

As a side fix, also make sure HwFb303Counter::cumulativeValue is explicitly inited to 0.

Test Plan

[ PASSED ] cold_boot.AgentQueuePerHostL2Test.VerifyHostToQueueMappingClassID (17887 ms)
[ PASSED ] warm_boot.AgentQueuePerHostL2Test.VerifyHostToQueueMappingClassID (8544 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsAfterResolve (20091 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsAfterResolve (12629 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsAfterResolveBlock (16187 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsAfterResolveBlock (4755 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsWithResolve (21140 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsWithResolve (12542 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsWithResolveBlock (16035 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.VerifyHostToQueueMappingClassIDsWithResolveBlock (4705 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.VerifyTtldCounter (20290 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.VerifyTtldCounter (8604 ms)
[ PASSED ] cold_boot.AgentQueuePerHostTest.RemovePendingNeighborDoesNotCrash (16035 ms)
[ PASSED ] warm_boot.AgentQueuePerHostTest.RemovePendingNeighborDoesNotCrash (4700 ms)
[ PASSED ] cold_boot.AgentQueuePerHostRouteTest.VerifyHostToQueueMappingClassID (33005 ms)
[ PASSED ] warm_boot.AgentQueuePerHostRouteTest.VerifyHostToQueueMappingClassID (13857 ms)
[ PASSED ] cold_boot.AgentQueuePerHostRouteTest.VerifyHostToQueueMappingClassIDBlock (29143 ms)
[ PASSED ] warm_boot.AgentQueuePerHostRouteTest.VerifyHostToQueueMappingClassIDBlock (9886 ms)
Summary:
   PASSED : 18
   FAILED : 0
   SKIPPED : 0
   TIMEOUT : 0

Signed-off-by: Vishrant Vasavada <vvasavada@nexthop.ai>
@vvasavada-nexthop
vvasavada-nexthop requested review from a team as code owners August 11, 2026 22:36
@meta-cla meta-cla Bot added the CLA Signed label Aug 11, 2026
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