[Nexthop] Simplify run_test.py arguments#898
Conversation
450c827 to
9efd772
Compare
## Summary This PR completes the cleanup of the `--hw-agent-bin-path` option from `run_test.py` following the upstream sync. If the changes are approved here, will incorporate them in the upstream sync at facebook#898 ## Changes Made 1. Removed `SUB_ARG_HW_AGENT_BIN_PATH` constant definition 2. Removed `--hw-agent-bin-path` argument from `LinkTestRunner.add_subcommand_arguments()` 3. Removed `hw_agent_service_bin_path` parameter from `setup_and_start_hw_agent_service()` calls in: - `LinkTestRunner._setup_coldboot_test()` - `LinkTestRunner._setup_warmboot_test()` ## Testing Done ### Test 1: Python Syntax Check ```bash python3 -m py_compile fboss/oss/scripts/run_scripts/run_test.py ``` **Result:** ✓ PASSED - No syntax errors ### Test 2: Grep for Remaining References ```bash grep -n "hw.agent.bin.path|hw_agent_bin_path" fboss/oss/scripts/run_scripts/run_test.py ``` **Result:** ✓ PASSED - No references found in run_test.py ### Test 3: Grep for References in Related Files ```bash grep -r "hw.agent.bin.path|hw_agent_bin_path" fboss/oss/scripts/run_scripts/ --include="*.py" ``` **Result:** ✓ PASSED - No references found in any Python files in the directory ### Test 4: Help Text Verification Programmatically checked `LinkTestRunner` help output. **Result:** ✓ PASSED - `--hw-agent-bin-path` option not present in help text Confirmed remaining options: `--agent-run-mode`, `--num-npus`, `--platform_mapping_override_path`, `--bsp_platform_mapping_override_path` ### Test 5: Function Signature Compatibility Verified `setup_and_start_hw_agent_service()` in `fboss_agent_utils.py`. **Result:** ✓ PASSED - `hw_agent_service_bin_path` parameter is `Optional[str] = None` The function handles `None` gracefully, so removing the parameter from calls is safe. ## Conclusion All references to `--hw-agent-bin-path` have been successfully removed from `run_test.py`. The cleanup is complete and the script remains functional.
9efd772 to
41aa4f3
Compare
41aa4f3 to
8a7fff0
Compare
8a7fff0 to
0660a82
Compare
0660a82 to
f25a002
Compare
f25a002 to
bc9e3b5
Compare
Simplify the command-line interface for run_test.py by removing redundant options and consolidating related functionality. - Remove --sai-bin and --hw-agent-bin-path option (install WIP binaries in the absolute path instead) - Remove --asic option (consolidated into --enable-production-features) - Consolidate --enable-production-features to take ASIC as argument instead of being a boolean flag - Update all test binaries to use absolute paths (/opt/fboss/bin/*) - Fix typo: producition_features -> production_features - Update documentation with simplified command examples - Add test configuration variables documentation - Simplify T0/T1/T2 test examples in documentation **Device:** fboss101 **Build ID:** 23679 **Test Suite:** 11 targeted integration tests **Results:** ✅ **11/11 PASSED (100%)** <details> <summary>Click to expand full test results</summary> ``` ========================================= Starting Integration Tests for PR facebook#408 DUT: fboss101 Results Directory: /tmp/pr408_integration_results_20260203_155518 ========================================= ======================================== Test 1: Verify --enable-production-features takes ASIC argument Command: ssh fboss101 -c 'cd /opt/fboss && ./bin/run_test.py sai_agent --help 2>&1 | grep -A3 "enable-production-features"' ======================================== ✓ PASSED Output: [--enable-production-features ASIC] [--platform_mapping_override_path [PLATFORM_MAPPING_OVERRIDE_PATH]] [--agent-run-mode [{mono,multi_switch}]] [--num-npus {1,2}] -- --enable-production-features ASIC Enable filtering by production features for the specified ASIC --platform_mapping_override_path [PLATFORM_MAPPING_OVERRIDE_PATH] ======================================== Test 2: Test --enable-production-features with valid ASIC (tomahawk5) Command: ssh fboss101 -c 'cd /opt/fboss && timeout 30 ./bin/run_test.py sai_agent --list_tests --config ./share/hw_test_configs/meru400biu.agent.materialized_JSON --enable-production-features tomahawk5 2>&1 | tail -10' ======================================== ✓ PASSED Output: VerifyPortRateTraffic/1 # GetParam() = 100000 VerifyPortRateTraffic/2 # GetParam() = 200000 VerifyPortRateTraffic/3 # GetParam() = 400000 test/AgentHwPtpTcProvisionTests. VerifyPtpTcDelayRequest/TWENTYFIVEG # GetParam() = 25000 VerifyPtpTcDelayRequest/FIFTYG # GetParam() = 50000 VerifyPtpTcDelayRequest/HUNDREDG # GetParam() = 100000 VerifyPtpTcDelayRequest/TWOHUNDREDG # GetParam() = 200000 VerifyPtpTcDelayRequest/FOURHUNDREDG # GetParam() = 400000 ======================================== Test 3: Test --enable-production-features with invalid ASIC shows error Command: ssh fboss101 -c 'cd /opt/fboss && timeout 10 ./bin/run_test.py sai_agent --list_tests --config ./share/hw_test_configs/meru400biu.agent.materialized_JSON --enable-production-features invalid_asic_xyz 2>&1 || true' | grep "Error: ASIC" ======================================== ✓ PASSED Output: Error: ASIC 'invalid_asic_xyz' not found in production features file. ======================================== Test 4: Verify --asic option is removed Command: ssh fboss101 -c 'cd /opt/fboss && ./bin/run_test.py sai_agent --help 2>&1' | grep -c "\-\-asic" ======================================== ✓ PASSED Output: 0 ======================================== Test 5: Verify --sai-bin option is removed from global options Command: ssh fboss101 -c 'cd /opt/fboss && ./bin/run_test.py --help 2>&1' | grep -c "\-\-sai-bin" ======================================== ✓ PASSED Output: 0 ======================================== Test 6: Verify --hw-agent-bin-path option is removed Command: ssh fboss101 -c 'cd /opt/fboss && ./bin/run_test.py sai_agent --help 2>&1' | grep -c "\-\-hw-agent-bin-path" ======================================== ✓ PASSED Output: 0 ======================================== Test 7: Verify run_test.py references absolute paths for test binaries Command: ssh fboss101 -c 'sudo cat /opt/fboss/bin/run_test.py | grep -c "/opt/fboss/bin/sai_test-sai_impl"' ======================================== ✓ PASSED Output: 1 ======================================== Test 8: Verify typo fix: production_features (not producition_features) Command: ssh fboss101 -c 'sudo cat /opt/fboss/bin/run_test.py' | grep -c "producition_features" ======================================== ✓ PASSED Output: 0 ======================================== Test 9: Verify run_test.py has valid Python syntax Command: ssh fboss101 -c 'sudo cp /opt/fboss/bin/run_test.py /tmp/run_test_syntax_check.py && python3 -m py_compile /tmp/run_test_syntax_check.py && echo "Syntax check passed" && sudo rm -f /tmp/run_test_syntax_check.py*' ======================================== ✓ PASSED Output: Syntax check passed ======================================== Test 10: Verify run_test.py can be imported as module Command: ssh fboss101 -c 'cd /opt/fboss/bin && python3 -c "import sys; sys.path.insert(0, \".\"); import run_test" && echo "Import successful"' ======================================== ✓ PASSED Output: Import successful ======================================== Test 11: Verify --production-features option removed from qsfp subcommand Command: ssh fboss101 -c 'cd /opt/fboss && ./bin/run_test.py qsfp --help 2>&1' | grep -c "\-\-production-features" ======================================== ✓ PASSED Output: 0 ========================================= Test Summary ========================================= Total Tests: 11 Passed: 11 Failed: 0 ========================================= Results saved to: /tmp/pr408_integration_results_20260203_155518 All tests passed! ``` </details>
bc9e3b5 to
ba660c0
Compare
|
We should not remove the bin path arg. Instead can we make it optional? If not provided, use the default binary path, but user can still have an option to use different binary. |
|
@AarjunC Can you give some context why you would like to keep the bin option? It was already optional, but made it confusing why you might need to provide it. Also, why only for the hw and sai test binaries? If it's just for testing purposes, why not just overwrite the binary at the default path? |
|
@AarjunC has imported this pull request. If you are a Meta employee, you can view this in D100650164. |
AarjunC
left a comment
There was a problem hiding this comment.
Please check review comments.
- Add bcm and platform to the supported test types in the header comment - Add example of multiple filters with negative filter (--filter=*Vlan*:*Port*:-*Mac*:*Intf*) - Remove --oss and --no-oss arguments (dead after --sai-bin removal) - Remove --fsdb-bin-path argument and fsdb_service_bin_path parameter from fsdb_service_utils, matching the hw_agent_bin_path cleanup - Remove qsfp_service_bin_path parameter from qsfp_service_utils (never passed by callers) Ruff linter also found more 'subprocess.run' commands that were missing passing in the 'check' argumnet explicitly. Test: - py_compile passed on all three changed Python files - run_test.py --help shows updated help without removed flags - run_test.py rejects --oss, --no-oss, and --fsdb-bin-path as unrecognized arguments - grep confirmed no dangling references to removed constants or args
|
@anna-nexthop has updated the pull request. You must reimport the pull request before landing. |
Added information about overriding known bad tests and unsupported test options
|
@anna-nexthop has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this comment.
test_binary_name != "qsfp_hw_test" will fail. _get_test_binary_name() returns "/opt/fboss/bin/qsfp_hw_test".
Can we make /opt/fboss/bin as a const value?
Enhancement suggestion:- Can we log error in _get_test_binary_name() if file is not found? This will be helpful if vendor scp fboss in location other than /opt/
There was a problem hiding this comment.
@AarjunC This check in the abstract class seems really fragile and I see that more than just the QSFP hw test runner doesn't need a conf file. What about if I update this check that if a conf_file is provided (isn't None or an empty string), then the path exists check is ran and the updated error message to be printed is that the provided path {conf_file} is not found.
For when the test binary isn't available, the issue is very obvious and looks like this (ran it locally that doesn't have that /opt/ directory available):

I'm hesitant to create yet another const value of the base path since the script is already so obfuscated, but can make the change if you feel strongly about it.
There was a problem hiding this comment.
@AarjunC Applied my suggestion that should resolve your comment about the fragility of the qsfp_hw_test binary check in the latest commit.
|
@anna-nexthop has updated the pull request. You must reimport the pull request before landing. |
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
Simplify the command-line interface for run_test.py by
removing redundant options and consolidating related functionality.
Changes
Removed Options
Updated Options
instead of being a boolean flag
Bug Fixes
Documentation
Testing
Integration Test Results
Device: fboss101
Build ID: 23679
Test Suite: 11 targeted integration tests
Results: ✅ 11/11 PASSED (100%)
Click to expand full test results