Skip to content

Fix unreachable DUT mgmt_ip in IPv6 only test case#12492

Merged
qiluo-msft merged 8 commits intosonic-net:masterfrom
maipbui:fix_mgmt_ip
Apr 23, 2024
Merged

Fix unreachable DUT mgmt_ip in IPv6 only test case#12492
qiluo-msft merged 8 commits intosonic-net:masterfrom
maipbui:fix_mgmt_ip

Conversation

@maipbui
Copy link
Copy Markdown
Contributor

@maipbui maipbui commented Apr 17, 2024

Description of PR

Summary: Fix unreachable DUT mgmt_ip in IPv6 only test case
Fixes # (issue)

Microsoft ADO 27674168, 27674176

Type of change

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

Back port request

Approach

What is the motivation for this PR?

#12303 introduced a bug that DUT mgmt_ipv4 is unreachable in a IPv6 only test case, causing test_rw_user_ipv6_only, test_ro_user_ipv6_only, test_snmp_ipv6_only failed with paramiko.ssh_exception.NoValidConnectionsError or socket.timeout: timed out

How did you do it?

If mgmt_ip is unreachable, try mgmt_ipv6

How did you verify/test it?

Verified on internal and 202305 branch on physical DUT

Any platform specific information?

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

Documentation

@maipbui maipbui changed the title test Fix unreachable DUT mgmt_ip in IPv6 only test case Apr 18, 2024
@maipbui maipbui marked this pull request as ready for review April 18, 2024 01:48
qiluo-msft
qiluo-msft previously approved these changes Apr 18, 2024
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

Please also check with other reviewers.

@sdszhang
Copy link
Copy Markdown
Contributor

sdszhang commented Apr 19, 2024

@maipbui I tested this change locally in KVM t0 testbed, there is a failure, can you please take a look?
You can follow the steps in #12377 to enable ipv6 in docker for KVM testbed.

$./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c ip/test_mgmt_ipv6_only.py::test_ro_user_ipv6_only -f vtestbed.yaml -i ../ansible/veos_vtb -u -E -m individual -u
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

output = {'failed': True, 'changed': True, 'stdout': '', 'stderr': "Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the ...fec0::ffff:afa:1' (RSA) to the list of known hosts.", 'Permission denied, please try again.'], '_ansible_no_log': None}
exp_val1 = 'test', exp_val2 = 'remote_user'

    def check_output(output, exp_val1, exp_val2):
>       pytest_assert(not output['failed'], output['stderr'])
E       Failed: Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the list of known hosts.
E       Permission denied, please try again.

exp_val1   = 'test'
exp_val2   = 'remote_user'
output     = {'failed': True, 'changed': True, 'stdout': '', 'stderr': "Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the ...fec0::ffff:afa:1' (RSA) to the list of known hosts.", 'Permission denied, please try again.'], '_ansible_no_log': None}

Signed-off-by: Mai Bui <[email protected]>
@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.........................................................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/common/utilities.py:21:1: F401 'socket' imported but unused
tests/common/utilities.py:26:1: F401 'paramiko.ssh_exception.NoValidConnectionsError' imported but unused

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>

return pwd
def get_dut_current_passwd(ipv4_address, ipv6_address, username, passwords):
try:
return _paramiko_ssh(ipv4_address, username, passwords)
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Apr 19, 2024

Choose a reason for hiding this comment

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

return

original this function return a password string. you want to return a pair instead? Is it an unexpected behavior change? #Closed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you would like to keep old bahavior, suggest use a different variable name pwd -> passwd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks for catching this

Signed-off-by: Mai Bui <[email protected]>
@maipbui
Copy link
Copy Markdown
Contributor Author

maipbui commented Apr 22, 2024

Tested on 202305 and internal on physical DUT, syncing offline with Dashuai Zhang for kvm test

@sdszhang
Copy link
Copy Markdown
Contributor

@maipbui I tested this change locally in KVM t0 testbed, there is a failure, can you please take a look? You can follow the steps in #12377 to enable ipv6 in docker for KVM testbed.

$./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c ip/test_mgmt_ipv6_only.py::test_ro_user_ipv6_only -f vtestbed.yaml -i ../ansible/veos_vtb -u -E -m individual -u
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

output = {'failed': True, 'changed': True, 'stdout': '', 'stderr': "Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the ...fec0::ffff:afa:1' (RSA) to the list of known hosts.", 'Permission denied, please try again.'], '_ansible_no_log': None}
exp_val1 = 'test', exp_val2 = 'remote_user'

    def check_output(output, exp_val1, exp_val2):
>       pytest_assert(not output['failed'], output['stderr'])
E       Failed: Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the list of known hosts.
E       Permission denied, please try again.

exp_val1   = 'test'
exp_val2   = 'remote_user'
output     = {'failed': True, 'changed': True, 'stdout': '', 'stderr': "Warning: Permanently added 'fec0::ffff:afa:1' (RSA) to the ...fec0::ffff:afa:1' (RSA) to the list of known hosts.", 'Permission denied, please try again.'], '_ansible_no_log': None}

You can skip this error. It seems to be separate issues, not related to your change. I will check it further and reach out if needed. Your current code change looks good to me.

Copy link
Copy Markdown
Contributor

@sdszhang sdszhang left a comment

Choose a reason for hiding this comment

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

LGTM

@maipbui maipbui marked this pull request as ready for review April 23, 2024 13:47
@qiluo-msft qiluo-msft merged commit 1376afa into sonic-net:master Apr 23, 2024
@maipbui maipbui deleted the fix_mgmt_ip branch April 23, 2024 18:35
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Apr 24, 2024
## Description of PR
Summary: Fix unreachable DUT mgmt_ip in IPv6 only test case

### Type of change

- [X] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] Test case(new/improvement)

## Approach
#### What is the motivation for this PR?
sonic-net#12303 introduced a bug that DUT mgmt_ipv4 is unreachable in a IPv6 only test case, causing test_rw_user_ipv6_only, test_ro_user_ipv6_only, test_snmp_ipv6_only failed with `paramiko.ssh_exception.NoValidConnectionsError` or `socket.timeout: timed out`
#### How did you do it?
If mgmt_ip is unreachable, try mgmt_ipv6
#### How did you verify/test it?
Verified on internal and 202305 branch on physical DUT
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Apr 24, 2024
## Description of PR
Summary: Fix unreachable DUT mgmt_ip in IPv6 only test case

### Type of change

- [X] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] Test case(new/improvement)

## Approach
#### What is the motivation for this PR?
sonic-net#12303 introduced a bug that DUT mgmt_ipv4 is unreachable in a IPv6 only test case, causing test_rw_user_ipv6_only, test_ro_user_ipv6_only, test_snmp_ipv6_only failed with `paramiko.ssh_exception.NoValidConnectionsError` or `socket.timeout: timed out`
#### How did you do it?
If mgmt_ip is unreachable, try mgmt_ipv6
#### How did you verify/test it?
Verified on internal and 202305 branch on physical DUT
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202305: #12573

@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202311: #12574

mssonicbld pushed a commit that referenced this pull request Apr 24, 2024
## Description of PR
Summary: Fix unreachable DUT mgmt_ip in IPv6 only test case

### Type of change

- [X] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] Test case(new/improvement)

## Approach
#### What is the motivation for this PR?
#12303 introduced a bug that DUT mgmt_ipv4 is unreachable in a IPv6 only test case, causing test_rw_user_ipv6_only, test_ro_user_ipv6_only, test_snmp_ipv6_only failed with `paramiko.ssh_exception.NoValidConnectionsError` or `socket.timeout: timed out`
#### How did you do it?
If mgmt_ip is unreachable, try mgmt_ipv6
#### How did you verify/test it?
Verified on internal and 202305 branch on physical DUT
mssonicbld pushed a commit that referenced this pull request Apr 27, 2024
## Description of PR
Summary: Fix unreachable DUT mgmt_ip in IPv6 only test case

### Type of change

- [X] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] Test case(new/improvement)

## Approach
#### What is the motivation for this PR?
#12303 introduced a bug that DUT mgmt_ipv4 is unreachable in a IPv6 only test case, causing test_rw_user_ipv6_only, test_ro_user_ipv6_only, test_snmp_ipv6_only failed with `paramiko.ssh_exception.NoValidConnectionsError` or `socket.timeout: timed out`
#### How did you do it?
If mgmt_ip is unreachable, try mgmt_ipv6
#### How did you verify/test it?
Verified on internal and 202305 branch on physical DUT
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