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

Add test case for syslog rate limit feature #6627

Merged
merged 3 commits into from
Dec 20, 2022

Conversation

Junchao-Mellanox
Copy link
Contributor

@Junchao-Mellanox Junchao-Mellanox commented Oct 26, 2022

HLD: sonic-net/SONiC#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)
  • 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

Change-Id: I11f29fa1a2265e2ba8c9a4ea4bac6ed2a0bb5a25
@azure-pipelines
Copy link

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>

Change-Id: Ic9ed9183f8838b240c6b7f5a4b39aefa1133507b
@Junchao-Mellanox
Copy link
Contributor Author

/azpw run Azure.sonic-mgmt

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

keboliu
keboliu previously approved these changes Nov 4, 2022
Returns:
None.
"""
skip_release(rand_selected_dut, ["201811", "201911", "202012", "202106", "202205"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you use the conditional mark plugin to do the skipping?

Copy link
Contributor Author

@Junchao-Mellanox Junchao-Mellanox Nov 25, 2022

Choose a reason for hiding this comment

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

I did not find such conditional mark plugin. Do you mean to create one? If my understanding is correct, I suppose it is good suggestion, but we should implement it in a separate PR because there are many places skip test case like this.

# Save configuration and reload, verify the configuration can be loaded
logger.info('Persist syslog rate limit configuration to DB and do config reload')
rand_selected_dut.command('config save -y')
config_reload(rand_selected_dut)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this config_reload during test cause loganalyzer to complain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not find any complain due my test.

@Junchao-Mellanox
Copy link
Contributor Author

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

@liat-grozovik
Copy link
Collaborator

@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?

Change-Id: I6c99fb62ac1482283278615b12b1cd02a807b5a9
@liat-grozovik liat-grozovik merged commit 0517bfa into sonic-net:master Dec 20, 2022
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.

5 participants