Skip to content

Recover default acl rules if necessary in module crm/test_crm.py. #9199

Merged
yutongzhang-microsoft merged 2 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/test_crm
Aug 1, 2023
Merged

Recover default acl rules if necessary in module crm/test_crm.py. #9199
yutongzhang-microsoft merged 2 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/test_crm

Conversation

@yutongzhang-microsoft
Copy link
Copy Markdown
Contributor

Description of PR

In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

Summary:
Fixes # (issue)

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?

In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?

Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?

05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Any platform specific information?

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

Documentation

@mssonicbld
Copy link
Copy Markdown
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.................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/crm/templates/acl.json

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/crm/test_crm.py:862:1: E302 expected 2 blank lines, found 1
tests/crm/test_crm.py:866:5: F841 local variable 'asic_collector' is assigned to but never used
tests/crm/test_crm.py:884:121: E501 line too long (121 > 120 characters)
tests/crm/test_crm.py:902:1: E302 expected 2 blank lines, found 1
tests/crm/test_crm.py:902:121: E501 line too long (135 > 120 characters)
...
[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>

wangxin
wangxin previously approved these changes Aug 1, 2023
@yutongzhang-microsoft yutongzhang-microsoft merged commit e26ca23 into sonic-net:master Aug 1, 2023
@yutongzhang-microsoft yutongzhang-microsoft deleted the yutongzhang/test_crm branch August 1, 2023 08:02
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 2, 2023
…onic-net#9199)

Description of PR
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

What is the motivation for this PR?
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?
Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?
05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Signed-off-by: Yutong Zhang <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

@yutongzhang-microsoft PR conflicts with 202012 branch

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 2, 2023
…onic-net#9199)

Description of PR
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

What is the motivation for this PR?
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?
Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?
05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Signed-off-by: Yutong Zhang <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202305: #9225

@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202205: #9226

mssonicbld pushed a commit that referenced this pull request Aug 2, 2023
…9199)

Description of PR
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

What is the motivation for this PR?
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?
Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?
05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit that referenced this pull request Aug 2, 2023
…9199)

Description of PR
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

What is the motivation for this PR?
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?
Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?
05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Signed-off-by: Yutong Zhang <[email protected]>
yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 3, 2023
yutongzhang-microsoft added a commit that referenced this pull request Aug 4, 2023
…crm/test_crm.py in 202012 (#9249)

Description of PR
Cherry pick conflict #9199

What is the motivation for this PR?
Cherry pick conflict #9199

Signed-off-by: Yutong Zhang <[email protected]>
yutongzhang-microsoft added a commit that referenced this pull request Aug 9, 2023
Description of PR
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312 .

What is the motivation for this PR?
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 10, 2023
Description of PR
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312 .

What is the motivation for this PR?
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 10, 2023
Description of PR
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312 .

What is the motivation for this PR?
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 10, 2023
Description of PR
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312 .

What is the motivation for this PR?
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
yutongzhang-microsoft added a commit that referenced this pull request Aug 10, 2023
…st_cacl_function.py`. (#9312)

Description of PR
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR #9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

What is the motivation for this PR?
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR #9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you do it?
Move fixture recover_acl_rule to tests/conftest.py and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you verify/test it?
```
07:34:42 conftest.core_dump_and_config_check      L1893 INFO   | Core dump and config check passed for cacl/test_cacl_function.py
```

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit that referenced this pull request Aug 10, 2023
Description of PR
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312 .

What is the motivation for this PR?
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit that referenced this pull request Aug 10, 2023
Description of PR
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312 .

What is the motivation for this PR?
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit that referenced this pull request Aug 12, 2023
Description of PR
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312 .

What is the motivation for this PR?
PR #9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR #9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Aug 17, 2023
…st_cacl_function.py`. (sonic-net#9312)

Description of PR
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR sonic-net#9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

What is the motivation for this PR?
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR sonic-net#9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you do it?
Move fixture recover_acl_rule to tests/conftest.py and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you verify/test it?
```
07:34:42 conftest.core_dump_and_config_check      L1893 INFO   | Core dump and config check passed for cacl/test_cacl_function.py
```

Signed-off-by: Yutong Zhang <[email protected]>
mssonicbld pushed a commit that referenced this pull request Aug 18, 2023
…st_cacl_function.py`. (#9312)

Description of PR
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR #9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

What is the motivation for this PR?
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR #9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you do it?
Move fixture recover_acl_rule to tests/conftest.py and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you verify/test it?
```
07:34:42 conftest.core_dump_and_config_check      L1893 INFO   | Core dump and config check passed for cacl/test_cacl_function.py
```

Signed-off-by: Yutong Zhang <[email protected]>
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
…onic-net#9199)

Description of PR
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

What is the motivation for this PR?
In module crm/test_crm.py, it will delete all acl rules after test running. But of DUT has original data plan acl rules, they are also deleted, and will cause inconsistent between previous running config and current running config. In this PR, we will recover original acl rules if exist.

How did you do it?
Add a fixture to record the original data plan acl rules and recover them if exist.

How did you verify/test it?
05:46:38 conftest.core_dump_and_config_check      L1767 INFO   | Collecting running config after test on str2-7050qx-32s-acs-02

Signed-off-by: Yutong Zhang <[email protected]>
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
Description of PR
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312 .

What is the motivation for this PR?
PR sonic-net#9199 modified the template acl.json under folder tests/crm/templates and added a key input_interface in this template. Only backend topo supports this key, so it will generate an error log in non-backend topo. In this PR, I revert the change to this template. And for recovery, we have another template in PR sonic-net#9312

How did you do it?
Revert the change to template acl json.

Signed-off-by: Yutong Zhang <[email protected]>
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
…st_cacl_function.py`. (sonic-net#9312)

Description of PR
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR sonic-net#9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

What is the motivation for this PR?
In module cacl/test_cacl_function.py, it will use command acl-loader delete to delete all acl rules, no matter if the testbed has DATAACL rules before test or not. If this testbed has DATAACL rules before, this deletion will cause inconsistent between previous running config and current running config, and will cause unnecessary config reload. In PR sonic-net#9199 , we have a fixture recover_acl_rule to recovery acl rules. So in this PR, I refactor this fixture and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you do it?
Move fixture recover_acl_rule to tests/conftest.py and use this fixture to recover acl rules in module cacl/test_cacl_function.py.

How did you verify/test it?
```
07:34:42 conftest.core_dump_and_config_check      L1893 INFO   | Core dump and config check passed for cacl/test_cacl_function.py
```

Signed-off-by: Yutong Zhang <[email protected]>
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.

3 participants