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

GCU cacl test combination #4835

Merged
merged 4 commits into from
Dec 27, 2021
Merged

GCU cacl test combination #4835

merged 4 commits into from
Dec 27, 2021

Conversation

wen587
Copy link
Contributor

@wen587 wen587 commented Dec 10, 2021

Description of PR

Summary: Combine GCU cacl test into one due to dependency among them
Fixes # (issue)

Type of change

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

Back port request

  • 201911

Approach

What is the motivation for this PR?

To avoid testing on one test case that is dependent on the previous test.

How did you do it?

Combine all test into one

How did you verify/test it?

Run test of sonic-mgmt/tests/generic_config_updater/test_cacl.py on KVM

Any platform specific information?

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

Documentation

@wen587 wen587 requested a review from a team as a code owner December 10, 2021 06:01
@lgtm-com
Copy link

lgtm-com bot commented Dec 23, 2021

This pull request introduces 1 alert when merging 3137427 into e95452b - view on LGTM.com

new alerts:

  • 1 for Unused import

@qiluo-msft
Copy link
Contributor

Please fix the LGTM alert.


pytestmark = [
pytest.mark.topology('any'),
pytest.mark.topology('t0'),
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 24, 2021

Choose a reason for hiding this comment

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

t0

It is not limited to t0. #Pending

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My previous test is to remove all ACL_TABLE and ACL_RULE settings, then test based on that. So it could be applied to any topo.
You mentioned we better test the scenario more practically. So I think it is more applicable that users just modify the change based on one of the topo.
That's why I change to t0 and just make changes above that.
Besides, rollback verification is easier if we have known the topo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Then I feel there is also practical test case for t1. Let's discuss and implement in another PR.

def get_cacl_tables(duthost):
"""Get acl control palne tables
"""
cmds = "show acl table | grep -w CTRLPLANE | awk {'print $1'} || true"
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 24, 2021

Choose a reason for hiding this comment

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

|| true

Not to ignore return code. If anything other than grep match failed, we need to capture and report an error. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed true to ignore errors.
Have some test on below scenario, it will not report an error because return code is still 0.
The only difference matters is whether the last command succeed or not.

admin@vlab-01:~$ showwwww acl table | grep -w CTRLPLANE | awk {'print $1'}
-bash: showwwww: command not found
admin@vlab-01:~$ echo $?
0
admin@vlab-01:~$ show acl table | greeeeep -w CTRLPLANE | awk {'print $1'}
-bash: greeeeep: command not found
admin@vlab-01:~$ echo $?
0
admin@vlab-01:~$ show acl table | grep -w CTRLPLANE | aaaaawk {'print $1'}
-bash: aaaaawk: command not found
admin@vlab-01:~$ echo $?
127

Also tested in sonic-mgmt, the return code will not be 0 only when the last pipe command fails. So it will not report error even first several commands fail.

{'stderr_lines': [u'/bin/sh: 1: shows: not found'], u'cmd': u"shows acl table | grep -w CTRLPLANE | awk {'print $1'}", u'end': u'2021-12-24 04:23:40.000951', '_ansible_no_log': False, u'stdout': u'', u'changed': True, u'rc': 0, u'start': u'2021-12-24 04:23:39.995670', u'stderr': u'/bin/sh: 1: shows: not found', u'delta': u'0:00:00.005281', u'invocation': {u'module_args': {u'creates': None, u'executable': None, u'_uses_shell': True, u'strip_empty_ends': True, u'_raw_params': u"shows acl table | grep -w CTRLPLANE | awk {'print $1'}", u'removes': None, u'argv': None, u'warn': True, u'chdir': None, u'stdin_add_newline': True, u'stdin': None}}, 'stdout_lines': [], 'failed': False}

Maybe the shell command should report an error based on non-empty stderr instead of non-zero rc ?

Copy link
Contributor

@qiluo-msft qiluo-msft Dec 24, 2021

Choose a reason for hiding this comment

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

Thanks for the experiment details! LGTM now.

If you would like to investigate further, you may check set -e and set -o pipefail, ref: https://stackoverflow.com/a/4959616/2514803.

Or consider use python to invoke individual commands, check return codes, and chain their stdout/stdin together. This is difficult since it is invoked on duthost.

@wen587 wen587 mentioned this pull request Dec 24, 2021
4 tasks
@wen587 wen587 merged commit 9ea6e9e into sonic-net:master Dec 27, 2021
AntonHryshchuk pushed a commit to AntonHryshchuk/sonic-mgmt that referenced this pull request Jan 4, 2022
…ndependently (sonic-net#4835)

Summary:
Make cacl test run independently

What is the motivation for this PR?
To avoid testing on one test case that is dependent on the previous test.

How did you do it?
Setup prerequisite environment for each test and rollback to the original setup

How did you verify/test it?
Run test of sonic-mgmt/tests/generic_config_updater/test_cacl.py on KVM
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.

2 participants