sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

Add test case for syslog rate limit feature

Open Junchao-Mellanox opened this issue 2 years ago • 4 comments

HLD: https://github.com/sonic-net/SONiC/pull/1049

Change-Id: I11f29fa1a2265e2ba8c9a4ea4bac6ed2a0bb5a25

Description of PR

Add test case for syslog rate limit feature.

Summary: test_syslog_rate_limit_container

  1. Randomly choose on container
  2. Change the syslog rate limit of current container
  3. Use a generated script to print log from current container which is fast enough to hit the limit
  4. Check syslog that some logs are dropped

test_syslog_rate_limit_host

  1. Change the syslog rate limit of host
  2. Use a generated script to print log from host which is fast enough to hit the limit
  3. Check syslog that some logs are dropped

Type of change

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

Back port request

  • [ ] 201911
  • [ ] 202012
  • [ ] 202205

Approach

What is the motivation for this PR?

Add test case for syslog rate limit feature

How did you do it?

Add test case for syslog rate limit feature

How did you verify/test it?

Run the test case

Any platform specific information?

N/A

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

N/A

Documentation

Junchao-Mellanox avatar Oct 26 '22 07:10 Junchao-Mellanox

The pre-commit check detected issues in the files touched by this pull request. The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results: trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/syslog/test_syslog_rate_limit.py:58:121: E501 line too long (143 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:60:121: E501 line too long (130 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:116:121: E501 line too long (124 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:122:121: E501 line too long (146 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:124:121: E501 line too long (185 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:125:121: E501 line too long (170 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:127:121: E501 line too long (130 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:129:45: E128 continuation line under-indented for visual indent
tests/syslog/test_syslog_rate_limit.py:130:45: E128 continuation line under-indented for visual indent
tests/syslog/test_syslog_rate_limit.py:130:121: E501 line too long (148 > 120 characters)
tests/syslog/test_syslog_rate_limit.py:131:45: E128 continuation line under-indented for visual indent
...
[truncated extra lines, please run pre-commit locally to view full check results]

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>

azure-pipelines[bot] avatar Oct 26 '22 07:10 azure-pipelines[bot]

/azpw run Azure.sonic-mgmt

Junchao-Mellanox avatar Oct 31 '22 08:10 Junchao-Mellanox

/AzurePipelines run Azure.sonic-mgmt

mssonicbld avatar Oct 31 '22 08:10 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Oct 31 '22 08:10 azure-pipelines[bot]

Hi @wangxin, i have replied to your comment, would you please check if it addressed your comment?

Junchao-Mellanox avatar Dec 05 '22 05:12 Junchao-Mellanox

@Junchao-Mellanox could we move forward merging this one now that the feature PRs are all in? or should we wait for some submodule updates?

liat-grozovik avatar Dec 13 '22 11:12 liat-grozovik