Agent Invariant Test
Overview
Agent Invariant Tests verify that a set of core forwarding "invariants" hold after the agent applies a production-like configuration — for example ACLs are programmed, CoPP (control-plane policing) is in effect, load balancing works across ECMP members, DSCP-to-queue mapping is correct, and the diag/Thrift handlers respond. They are a fast confidence check that a config produces a correctly functioning switch, and they share the Agent Hw Test framework (see Agent Hw Test).
Several role-specific variants exist (RSW, RTSW, FTSW, STSW), each applying the config and buffer settings appropriate to that switch role before checking invariants.
Setup
Invariant tests run on a standalone DUT using the per-platform agent config under fboss/oss/hw_test_configs. Some role variants expect role-appropriate settings (for example the RTSW variant enables MMU lossless mode), so use a config that matches the role you are exercising.
Test Cases
All invariant test cases can be found at:
https://github.com/facebook/fboss/tree/main/fboss/agent/test/prod_invariant_tests https://github.com/facebook/fboss/blob/main/fboss/agent/test/prod_agent_tests/ProdInvariantTests.cpp
Example gtest names: ProdInvariantTest.verifyInvariants, ProdInvariantRtswTest.verifyInvariants.
Run Modes
Invariant tests can run in either agent run mode:
- multi_switch (recommended) — SwSwitch and HwAgent run as separate processes over Thrift, as in production.
run_test.pybrings up thehw_agentservice automatically. Binary:multi_switch_invariant_agent_test. - mono (deprecated) — single-process. Binary:
sai_invariant_agent_test-sai_impl.
Prefer multi_switch — it mirrors the production process model. mono is deprecated and will be removed in the future. If --agent-run-mode is not specified, run_test.py defaults to multi_switch.
Steps to Run Agent Invariant Test
Build and package FBOSS following the build guide and copy the package to the switch per Packaging and Running FBOSS HW Tests on Switch. You must be in the
/opt/fbossdirectory when running tests.Run the full invariant suite (recommended).
run_test.pyautomatically discovers and runs all invariant tests; pass--skip-known-bad-teststo skip tests known not to pass for your ASIC/SDK (key formatvendor/coldboot-sdk/warmboot-sdk/asic/mode):./bin/run_test.py sai_invariant_agent \
--config ./share/hw_test_configs/$CONFIG \
--agent-run-mode multi_switch \
--skip-known-bad-tests "brcm/13.3.0.0_odp/13.3.0.0_odp/tomahawk5/multi_switch"Run a single test (optional).
--filteris only needed to narrow the run; the test name below is for illustration only — use any valid gtest name (e.g. a role variant likeProdInvariantRtswTest.verifyInvariants):# multi_switch (recommended)
./bin/run_test.py sai_invariant_agent \
--config ./share/hw_test_configs/$CONFIG \
--agent-run-mode multi_switch \
--filter ProdInvariantTest.verifyInvariants
# mono
./bin/run_test.py sai_invariant_agent \
--config ./share/hw_test_configs/$CONFIG \
--agent-run-mode mono \
--filter ProdInvariantTest.verifyInvariants
Common flags:
--filter: GTEST filter passed through to the test binary (doc). Use it to select a role variant, e.g.ProdInvariantRtswTest.verifyInvariants.--agent-run-mode:monoormulti_switch(defaultmulti_switch).--num-npus {1,2}: number of NPUs to run in multi_switch mode (default 1).--skip-known-bad-tests: ASIC/SDK key (vendor/coldboot-sdk/warmboot-sdk/asic/mode) used to skip known-bad/unsupported tests. Invariant tests reuse the SAI Agent known-bad lists underfboss/oss/hw_known_bad_testsandfboss/oss/sai_hw_unsupported_tests.