Skip to content

[IPv6 only]Fixture to convert/revert the mgmt-ip to IPv6 olny, enhance connection plugin#11957

Merged
yejianquan merged 1 commit intosonic-net:masterfrom
yejianquan:jianquanye/support_ipv6_only
Mar 14, 2024
Merged

[IPv6 only]Fixture to convert/revert the mgmt-ip to IPv6 olny, enhance connection plugin#11957
yejianquan merged 1 commit intosonic-net:masterfrom
yejianquan:jianquanye/support_ipv6_only

Conversation

@yejianquan
Copy link
Collaborator

@yejianquan yejianquan commented Mar 12, 2024

Description of PR

  1. Add a fixture to convert the DUT to IPv6 only(only mgmt-ip)
  2. Enhance the connection plugin to re-connect with the IPv6 address if the IPv4 address is unavailable
  3. Add a new test module with examples to test the IPv6-only scenario.

Summary:
Fixes # (issue)

Type of change

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

Back port request

  • 201911
  • 202012
  • 202205
  • 202305
  • 202311

Approach

What is the motivation for this PR?

Support test mgmt-ip IPv6 only scenario.

How did you do it?

Remove the IPv4 mgmt address before the test module starts, and restore after the test module is finished.
Enhance the connection plugging to first connect with the IPv4 address, and retry with the IPv6 address if IPv4 is unavailable.
Add a new test module with examples to test the IPv6-only scenario.

How did you verify/test it?

Run on physical testbeds, with dual-stack mgmt-ip addresses testbed and only with IPv6/IPv4 mgmt-ip address testbed.

================================================================================================================== test session starts ==================================================================================================================

ip/test_mgmt_ipv6_only.py::test_bgp_facts[-None] PASSED [ 25%]
ip/test_mgmt_ipv6_only.py::test_bgp_facts_ipv6_only[-None] PASSED [ 50%]
ip/test_mgmt_ipv6_only.py::test_show_features[-4] PASSED [ 75%]
ip/test_mgmt_ipv6_only.py::test_show_features_ipv6_only[-4] PASSED [100%]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
--------------------------------------------------------------------------------------------- generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml ---------------------------------------------------------------------------------------------
======================================================================================================= 4 passed, 3 warnings in 741.52s (0:12:21) =======================================================================================================
INFO:root:Can not get Allure report URL. Please check logs
jianquanye@sonic-mgmt-jianquanye:/var/src/sonic-mgmt-int/tests$

Any platform specific information?

No.

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

All topologies.

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.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/common/devices/duthosts.py
Fixing tests/ip/test_mgmt_ipv6_only.py

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

ansible/plugins/connection/multi_passwd_ssh.py:66:121: E501 line too long (903 > 120 characters)
tests/common/fixtures/duthost_utils.py:639:44: E127 continuation line over-indented for visual indent
tests/common/fixtures/duthost_utils.py:641:44: E127 continuation line over-indented for visual indent
tests/common/fixtures/duthost_utils.py:644:121: E501 line too long (129 > 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>

@yejianquan yejianquan closed this Mar 12, 2024
@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.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/common/devices/duthosts.py
Fixing tests/ip/test_mgmt_ipv6_only.py

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/ip/test_mgmt_ipv6_only.py:5:1: F401 'tests.common.helpers.assertions.pytest_assert' imported but unused
tests/ip/test_mgmt_ipv6_only.py:15:30: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 4
tests/ip/test_mgmt_ipv6_only.py:21:63: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 4
...
[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>

@yejianquan yejianquan reopened this Mar 13, 2024
@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.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing tests/common/devices/duthosts.py

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/ip/test_mgmt_ipv6_only.py:13:30: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 3
tests/ip/test_mgmt_ipv6_only.py:49:63: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 3

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>

@yejianquan
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

Fixing tests/common/devices/duthosts.py

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/ip/test_mgmt_ipv6_only.py:13:30: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 3
tests/ip/test_mgmt_ipv6_only.py:49:63: F811 redefinition of unused 'convert_and_restore_config_db_to_ipv6_only' from line 3

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>

@wangxin
Copy link
Collaborator

wangxin commented Mar 13, 2024

PR title is so long. Can you make the title shorter?

… the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable
@yejianquan yejianquan force-pushed the jianquanye/support_ipv6_only branch from e238b9b to f75db3c Compare March 13, 2024 09:09
@yejianquan yejianquan changed the title [IPv6 only]Add a fixture to convert the DUT to IPv6 only, and enhance the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable [IPv6 only]Fixture to convert/revert the mgmt-ip to IPv6 olny, enhance connection plugin Mar 13, 2024
@yejianquan yejianquan requested a review from wangxin March 13, 2024 10:14
@mssonicbld
Copy link
Collaborator

@yejianquan PR conflicts with 202305 branch

@mssonicbld
Copy link
Collaborator

@yejianquan PR conflicts with 202311 branch

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 14, 2024
… the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable (sonic-net#11957)

Approach
What is the motivation for this PR?
Support test mgmt-ip IPv6 only scenario.

How did you do it?
Remove the IPv4 mgmt address before the test module starts, and restore after the test module is finished.
Enhance the connection plugging to first connect with the IPv4 address, and retry with the IPv6 address if IPv4 is unavailable.
Add a new test module with examples to test the IPv6-only scenario.

How did you verify/test it?
Run on physical testbeds, with dual-stack mgmt-ip addresses testbed and only with IPv6/IPv4 mgmt-ip address testbed.

================================================================================================================== test session starts ==================================================================================================================

ip/test_mgmt_ipv6_only.py::test_bgp_facts[-None] PASSED [ 25%]
ip/test_mgmt_ipv6_only.py::test_bgp_facts_ipv6_only[-None] PASSED [ 50%]
ip/test_mgmt_ipv6_only.py::test_show_features[-4] PASSED [ 75%]
ip/test_mgmt_ipv6_only.py::test_show_features_ipv6_only[-4] PASSED [100%]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
--------------------------------------------------------------------------------------------- generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml ---------------------------------------------------------------------------------------------
======================================================================================================= 4 passed, 3 warnings in 741.52s (0:12:21) =======================================================================================================
INFO:root:Can not get Allure report URL. Please check logs
jianquanye@sonic-mgmt-jianquanye:/var/src/sonic-mgmt-int/tests$
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202311: #11983

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Mar 14, 2024
… the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable (sonic-net#11957)

Approach
What is the motivation for this PR?
Support test mgmt-ip IPv6 only scenario.

How did you do it?
Remove the IPv4 mgmt address before the test module starts, and restore after the test module is finished.
Enhance the connection plugging to first connect with the IPv4 address, and retry with the IPv6 address if IPv4 is unavailable.
Add a new test module with examples to test the IPv6-only scenario.

How did you verify/test it?
Run on physical testbeds, with dual-stack mgmt-ip addresses testbed and only with IPv6/IPv4 mgmt-ip address testbed.

================================================================================================================== test session starts ==================================================================================================================

ip/test_mgmt_ipv6_only.py::test_bgp_facts[-None] PASSED [ 25%]
ip/test_mgmt_ipv6_only.py::test_bgp_facts_ipv6_only[-None] PASSED [ 50%]
ip/test_mgmt_ipv6_only.py::test_show_features[-4] PASSED [ 75%]
ip/test_mgmt_ipv6_only.py::test_show_features_ipv6_only[-4] PASSED [100%]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
--------------------------------------------------------------------------------------------- generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml ---------------------------------------------------------------------------------------------
======================================================================================================= 4 passed, 3 warnings in 741.52s (0:12:21) =======================================================================================================
INFO:root:Can not get Allure report URL. Please check logs
jianquanye@sonic-mgmt-jianquanye:/var/src/sonic-mgmt-int/tests$
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #11984

yejianquan added a commit to yejianquan/sonic-mgmt that referenced this pull request Mar 14, 2024
… enhance the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable (sonic-net#11957)"

This reverts commit afd7fce.
yejianquan added a commit that referenced this pull request Mar 15, 2024
* Revert "[image_download] Add ipv6 only mgmt image download test (#11936)"

This reverts commit f5cdac4.

* Revert "[IPv6 only]Add a fixture to convert the DUT to IPv6 only, and enhance the connection plugin to retry with IPv6 addr if IPv4 addr is unavailable (#11957)"

This reverts commit afd7fce.


Approach
What is the motivation for this PR?
There's a performance impact introduced by the IPv6 fixture, the test time is getting longer.
Revert and will create another PR after the performance issue is resolved.
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.

3 participants