Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move global definitions to local to the function they are used - so t…
…hat the different scripts that call this function get the same values. (sonic-net#15964) Description of PR Summary: Fixes this problem: * 1e9 * data_flow_dur_sec / 8.0 / data_pkt_size > deviation = (rx_frames - exp_bg_flow_rx_pkts) / float(exp_bg_flow_rx_pkts) E ZeroDivisionError: float division by zero bg_flow_name = 'Background Flow' bg_flow_rate_percent = 0 data_flow_dur_sec = 2 data_pkt_size = 1024 dst_port_id = 0 exp_bg_flow_rx_pkts = 0.0 exp_test_flow_rx_pkts = 1953125.0 flow_name = 'Background Flow 1 -> 0 Prio 1' pause_flow_name = 'Pause Storm' pause_port_id = 0 row = <snappi.snappi.FlowMetric object at 0x7ff2ccffa980> rows = <snappi.snappi.FlowMetricIter object at 0x7ff2cd3df880> rx_frames = 1 speed_gbps = 400 src_port_id = 2 test_flow_name = 'Test Flow' test_flow_rate_percent = 2 tolerance = 0.05 trigger_pfcwd = True tx_frames = 1 snappi_tests/multidut/pfcwd/files/pfcwd_multidut_multi_node_helper.py:633: ZeroDivisionError This issue happens since the initialization for TEST_FLOW_AGGR_RATE_PERCENT and BG_FLOW_AGGR_RATE_PERCENT are global, and everytime the function run_pfcwd_multi_node_test() is called, their value is halved. After 4-5 times of halving, the int() value of the above variables is zero. This results in the above traceback at the 4th or 5th call. Approach What is the motivation for this PR? Fixing the ZeroDivision problem. How did you do it? Moved the global definition to the function scope. How did you verify/test it? Ran it on my TB: =========================================================================================================================== PASSES =========================================================================================================================== ______________________________________________________________________________________________________ test_pfcwd_many_to_one[multidut_port_info0-True] ______________________________________________________________________________________________________ ______________________________________________________________________________________________________ test_pfcwd_many_to_one[multidut_port_info1-True] ______________________________________________________________________________________________________ _________________________________________________________________________________________________ test_multidut_pfcwd_all_to_all[multidut_port_info0-False] __________________________________________________________________________________________________ _________________________________________________________________________________________________ test_multidut_pfcwd_all_to_all[multidut_port_info1-False] __________________________________________________________________________________________________ ------------------------------------------------------------------------------ generated xml file: /run_logs/ixia/zero-division/2024-12-09-02-43-06/tr_2024-12-09-02-43-06.xml ------------------------------------------------------------------------------- INFO:root:Can not get Allure report URL. Please check logs ------------------------------------------------------------------------------------------------------------------- live log sessionfinish ------------------------------------------------------------------------------------------------------------------- 02:55:06 __init__.pytest_terminal_summary L0067 INFO | Can not get Allure report URL. Please check logs ================================================================================================================== short test summary info =================================================================================================================== PASSED snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py::test_pfcwd_many_to_one[multidut_port_info0-True] PASSED snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py::test_pfcwd_many_to_one[multidut_port_info1-True] PASSED snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py::test_multidut_pfcwd_all_to_all[multidut_port_info0-False] PASSED snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py::test_multidut_pfcwd_all_to_all[multidut_port_info1-False] ========================================================================================================= 4 passed, 8 warnings in 717.52s (0:11:57) ========================================================================================================== Any platform specific information? The issue is specific to cisco-8000.
- Loading branch information