Add a function to compare running config. #8744
Conversation
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
1 similar comment
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
ead8671 to
93114a7
Compare
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
tests/conftest.py
Outdated
| return True | ||
| if type(pre_running_config) != type(cur_running_config): | ||
| return False | ||
| if sorted(pre_running_config.keys()) != sorted(cur_running_config.keys()): |
There was a problem hiding this comment.
How about using set to do the key comparison? Then no need to sort the list.
There was a problem hiding this comment.
Good idea~
|
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
Description of PR
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
What is the motivation for this PR?
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
How did you do it?
Add a function to compare two running config dict.
How did you verify/test it?
```
06:35:15 conftest.core_dump_and_config_check L2115 INFO | Core dump and config check passed for acl/test_acl_outer_vlan.py
```
Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
|
Cherry-pick PR to 202205: #8846 |
|
@yutongzhang-microsoft PR conflicts with 202012 branch |
Description of PR
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
What is the motivation for this PR?
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
How did you do it?
Add a function to compare two running config dict.
How did you verify/test it?
```
06:35:15 conftest.core_dump_and_config_check L2115 INFO | Core dump and config check passed for acl/test_acl_outer_vlan.py
```
Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
Co-authored-by: jianquanye@microsoft.com
Description of PR There is a conflict when cherry pick PR (#8744) into 202012 branch, so raise this PR to cherry pick. co-authorized by: jianquanye@microsoft.com
Description of PR
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
What is the motivation for this PR?
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
How did you do it?
Add a function to compare two running config dict.
How did you verify/test it?
```
06:35:15 conftest.core_dump_and_config_check L2115 INFO | Core dump and config check passed for acl/test_acl_outer_vlan.py
```
Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
Description of PR
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
What is the motivation for this PR?
We only use `==` to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in module `acl/test_acl_outer_vlan.py`, it somehow change the order of part of the running dict from `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}` to `{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}`. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.
How did you do it?
Add a function to compare two running config dict.
How did you verify/test it?
```
06:35:15 conftest.core_dump_and_config_check L2115 INFO | Core dump and config check passed for acl/test_acl_outer_vlan.py
```
Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
Description of PR
We only use
==to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in moduleacl/test_acl_outer_vlan.py, it somehow change the order of part of the running dict from{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}to{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
We only use
==to compare running config before, but our running config is a nested dict, and if the value is disordered, it will wrongly return false. Just in moduleacl/test_acl_outer_vlan.py, it somehow change the order of part of the running dict from{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel104", "PortChannel103"]}}to{"DATAACL": {"ports": ["PortChannel101", "PortChannel102", "PortChannel103", "PortChannel104"]}}. And this disorder will cause config reload after running all cases in this module. In this PR, I add a function to compare running config, which will avoid such wrong judgement caused by order.How did you do it?
Add a function to compare two running config dict.
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation