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

implement memory utilization fixture #13698

Merged
merged 13 commits into from
Aug 14, 2024

Conversation

lipxu
Copy link
Contributor

@lipxu lipxu commented Jul 17, 2024

Description of PR

Summary:
Fixes # (issue)
27216861

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?

Test gap for memory leak

How did you do it?

Introduced a new fixture to collect the memory information before and after the test case.
Then compare the memory information to confirm that it has not exceeded the high memory usage threshold and that no memory leaks have occurred.

How did you verify/test it?

Run case locally.
Set a fake threshold, check the result.
Run nightly pipeline.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

Signed-off-by: xuliping <xuliping@microsoft.com>
@wsycqyz
Copy link
Contributor

wsycqyz commented Jul 18, 2024

/azp run

Copy link

Commenter does not have sufficient privileges for PR 13698 in repo sonic-net/sonic-mgmt

@StormLiangMS
Copy link
Collaborator

@lipxu could we have an example to give when this check passed / failed?

@lipxu
Copy link
Contributor Author

lipxu commented Jul 29, 2024

@lipxu could we have an example to give when this check passed / failed?

Sure, added the examples for supported memory items.

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/plugins/memory_utilization/README.md

fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/common/plugins/memory_utilization/README.md

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@StormLiangMS
Copy link
Collaborator

/azp run Azure.sonic-mgmt

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StormLiangMS
Copy link
Collaborator

/azp run Azure.sonic-mgmt

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lipxu
Copy link
Contributor Author

lipxu commented Aug 1, 2024

/azp run Azure.sonic-mgmt

Copy link

Commenter does not have sufficient privileges for PR 13698 in repo sonic-net/sonic-mgmt

@StormLiangMS
Copy link
Collaborator

hi @lipxu should we consider when this fixture can kick in? if it is after teardown, it may not work as expected since all process could be already reloaded without memory leak evidence.

@lipxu
Copy link
Contributor Author

lipxu commented Aug 9, 2024

hi @lipxu should we consider when this fixture can kick in? if it is after teardown, it may not work as expected since all process could be already reloaded without memory leak evidence.

I've updated the branch by adding the following two functions and adjusted the setup to use "trylast" and teardown to use "tryfirst". This will allow memory utilization to collect the memory information before and after the test case. ensuring accurate capture memory usage of the test case.

@pytest.hookimpl(trylast=True)
def pytest_runtest_setup(item):

@pytest.hookimpl(tryfirst=True)
def pytest_runtest_teardown(item, nextitem):

@lipxu lipxu mentioned this pull request Aug 12, 2024
8 tasks
Copy link
Collaborator

@StormLiangMS StormLiangMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StormLiangMS
Copy link
Collaborator

hi @lipxu LGTM, could you work with other reviewers to close the comment before we get this merged?

@StormLiangMS StormLiangMS merged commit e417fbf into sonic-net:master Aug 14, 2024
16 checks passed
StormLiangMS pushed a commit that referenced this pull request Aug 15, 2024
What is the motivation for this PR?
There was a production issue related to the memory leak caused by link flap.

How did you do it?
Add a new stress link flap cases. with the memory utilization fixture #13698.
Could check the memory information before and after the stress link flap case and failure if any memory leak.

Currently, the test time is 10 minutes for nightly run.
would add a parameter to enlarge the test times and run the case much longer for stress flaps.

How did you verify/test it?
Run the case locally.

bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[dut] PASSED [ 25%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[fanout] PASSED [ 50%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[neighbor] PASSED [ 75%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[all] PASSED [100%]

Verify the case on kvm
https://elastictest.org/scheduler/testplan/66b9d5c20fde6eb55e3adcf
https://elastictest.org/scheduler/testplan/66b9d5b8a79f777a863fe6f8
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 15, 2024
What is the motivation for this PR?
There was a production issue related to the memory leak caused by link flap.

How did you do it?
Add a new stress link flap cases. with the memory utilization fixture sonic-net#13698.
Could check the memory information before and after the stress link flap case and failure if any memory leak.

Currently, the test time is 10 minutes for nightly run.
would add a parameter to enlarge the test times and run the case much longer for stress flaps.

How did you verify/test it?
Run the case locally.

bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[dut] PASSED [ 25%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[fanout] PASSED [ 50%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[neighbor] PASSED [ 75%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[all] PASSED [100%]

Verify the case on kvm
https://elastictest.org/scheduler/testplan/66b9d5c20fde6eb55e3adcf
https://elastictest.org/scheduler/testplan/66b9d5b8a79f777a863fe6f8
mssonicbld pushed a commit that referenced this pull request Aug 16, 2024
What is the motivation for this PR?
There was a production issue related to the memory leak caused by link flap.

How did you do it?
Add a new stress link flap cases. with the memory utilization fixture #13698.
Could check the memory information before and after the stress link flap case and failure if any memory leak.

Currently, the test time is 10 minutes for nightly run.
would add a parameter to enlarge the test times and run the case much longer for stress flaps.

How did you verify/test it?
Run the case locally.

bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[dut] PASSED [ 25%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[fanout] PASSED [ 50%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[neighbor] PASSED [ 75%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[all] PASSED [100%]

Verify the case on kvm
https://elastictest.org/scheduler/testplan/66b9d5c20fde6eb55e3adcf
https://elastictest.org/scheduler/testplan/66b9d5b8a79f777a863fe6f8
eddieruan-alibaba pushed a commit to eddieruan-alibaba/sonic-mgmt that referenced this pull request Sep 4, 2024
What is the motivation for this PR?
Test gap for memory leak

How did you do it?
Introduced a new fixture to collect the memory information before and after the test case.
Then compare the memory information to confirm that it has not exceeded the high memory usage threshold and that no memory leaks have occurred.

How did you verify/test it?
Run case locally.
Set a fake threshold, check the result.
Run nightly pipeline.
eddieruan-alibaba pushed a commit to eddieruan-alibaba/sonic-mgmt that referenced this pull request Sep 4, 2024
What is the motivation for this PR?
There was a production issue related to the memory leak caused by link flap.

How did you do it?
Add a new stress link flap cases. with the memory utilization fixture sonic-net#13698.
Could check the memory information before and after the stress link flap case and failure if any memory leak.

Currently, the test time is 10 minutes for nightly run.
would add a parameter to enlarge the test times and run the case much longer for stress flaps.

How did you verify/test it?
Run the case locally.

bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[dut] PASSED [ 25%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[fanout] PASSED [ 50%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[neighbor] PASSED [ 75%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[all] PASSED [100%]

Verify the case on kvm
https://elastictest.org/scheduler/testplan/66b9d5c20fde6eb55e3adcf
https://elastictest.org/scheduler/testplan/66b9d5b8a79f777a863fe6f8
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
What is the motivation for this PR?
Test gap for memory leak

How did you do it?
Introduced a new fixture to collect the memory information before and after the test case.
Then compare the memory information to confirm that it has not exceeded the high memory usage threshold and that no memory leaks have occurred.

How did you verify/test it?
Run case locally.
Set a fake threshold, check the result.
Run nightly pipeline.
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
What is the motivation for this PR?
There was a production issue related to the memory leak caused by link flap.

How did you do it?
Add a new stress link flap cases. with the memory utilization fixture sonic-net#13698.
Could check the memory information before and after the stress link flap case and failure if any memory leak.

Currently, the test time is 10 minutes for nightly run.
would add a parameter to enlarge the test times and run the case much longer for stress flaps.

How did you verify/test it?
Run the case locally.

bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[dut] PASSED [ 25%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[fanout] PASSED [ 50%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[neighbor] PASSED [ 75%]
bgp/test_bgp_stress_link_flap.py::test_bgp_stress_link_flap[all] PASSED [100%]

Verify the case on kvm
https://elastictest.org/scheduler/testplan/66b9d5c20fde6eb55e3adcf
https://elastictest.org/scheduler/testplan/66b9d5b8a79f777a863fe6f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants