Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:15964] T2/Snappi: Move global definitions of test and background flow rates to be local to the function they are used. #16329

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

mssonicbld
Copy link
Collaborator

Description of PR

Summary:
Fixes this problem:

 LICENSE README.md SECURITY.md ansible azure-pipelines.yml docs git pyproject.toml sdn_tests setup-container.sh spytest test_reporting tests 1e9 LICENSE README.md SECURITY.md ansible azure-pipelines.yml docs git pyproject.toml sdn_tests setup-container.sh spytest test_reporting tests 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.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

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.

…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.
@mssonicbld
Copy link
Collaborator Author

/azp run

@mssonicbld
Copy link
Collaborator Author

Original PR: #15964

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld mssonicbld merged commit e8774d7 into sonic-net:202411 Jan 3, 2025
16 checks passed
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.

2 participants