Skip to content

Refactor fixture recover_acl_rule and and use it in module cacl/test_cacl_function.py.#9312

Merged
yutongzhang-microsoft merged 4 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/cacl
Aug 10, 2023
Merged

Refactor fixture recover_acl_rule and and use it in module cacl/test_cacl_function.py.#9312
yutongzhang-microsoft merged 4 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/cacl

Conversation

@yutongzhang-microsoft
Copy link
Contributor

@yutongzhang-microsoft yutongzhang-microsoft commented Aug 7, 2023

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.

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

Any platform specific information?

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

Documentation

@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.................................................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/conftest.py:2247:1: E302 expected 2 blank lines, found 1
tests/conftest.py:2257:1: E302 expected 2 blank lines, found 1

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>

@yutongzhang-microsoft
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

"interface_ref":
{
"config": {
"interface": "Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet4,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet8"
Copy link
Contributor

Choose a reason for hiding this comment

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

@yutongzhang-microsoft use the same interfaces for different topology?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is set by pre_acl_rules

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 <yutongzhang@microsoft.com>
"vlan_id": "1000"
}
},
"input_interface": {
Copy link
Contributor

Choose a reason for hiding this comment

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

According to #9346, should remove input_interface here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this template only be used by backend topo, and backend topo support this config.

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 <yutongzhang@microsoft.com>
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 <yutongzhang@microsoft.com>
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 <yutongzhang@microsoft.com>
Copy link
Contributor

@ZhaohuiS ZhaohuiS left a comment

Choose a reason for hiding this comment

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

LGTM

@yutongzhang-microsoft yutongzhang-microsoft merged commit f59f2a8 into sonic-net:master Aug 10, 2023
@yutongzhang-microsoft yutongzhang-microsoft deleted the yutongzhang/cacl branch August 10, 2023 02:08
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 <yutongzhang@microsoft.com>
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 <yutongzhang@microsoft.com>
@arlakshm
Copy link
Contributor

arlakshm commented Aug 10, 2023

In #9199 the acl.json is modified, which this PR revert this change in acl.json, #9199 cause this isssue ion T2 #9368

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 <yutongzhang@microsoft.com>
@mssonicbld
Copy link
Collaborator

@yutongzhang-microsoft PR conflicts with 202012 branch

@mssonicbld
Copy link
Collaborator

@yutongzhang-microsoft PR conflicts with 202205 branch

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 <yutongzhang@microsoft.com>
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #9524

yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 17, 2023
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 <yutongzhang@microsoft.com>
yutongzhang-microsoft added a commit that referenced this pull request Aug 21, 2023
Description of PR
PR #9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

What is the motivation for this PR?
PR #9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

How did you do it?
Run TC on testbed which enable_data_acl is false when deploying minigraph.

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 22, 2023
yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 22, 2023
StormLiangMS pushed a commit that referenced this pull request Aug 23, 2023
yutongzhang-microsoft added a commit that referenced this pull request Aug 23, 2023
…02012 (#9590)

Description of PR
Cherry pick conflict #9523 and #9312

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
wangxin pushed a commit that referenced this pull request Aug 28, 2023
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 <yutongzhang@microsoft.com>
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 <yutongzhang@microsoft.com>
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
Description of PR
PR sonic-net#9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

What is the motivation for this PR?
PR sonic-net#9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

How did you do it?
Run TC on testbed which enable_data_acl is false when deploying minigraph.

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
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.

5 participants