Skip to content

Optimize ip/test_mgmt_ipv6_only.py to reduce runtime by ~85%#25501

Open
peterbailey-arista wants to merge 1 commit into
sonic-net:masterfrom
peterbailey-arista:fix-test-mgmt-ipv6-address
Open

Optimize ip/test_mgmt_ipv6_only.py to reduce runtime by ~85%#25501
peterbailey-arista wants to merge 1 commit into
sonic-net:masterfrom
peterbailey-arista:fix-test-mgmt-ipv6-address

Conversation

@peterbailey-arista

Copy link
Copy Markdown
Contributor

Right now, ip/test_mgmt_ipv6_only.py takes 2 to 2.5 hours to run. The test is so slow because every ansible connection times out after removing the ipv4 mgmt interface address. The new tested runtime is about 22 minutes, which is 6x to 7x faster.

We need to update the ansible host to be aware of the correct IPv6 address it should now be using. Previously this test still passed because every ansible ssh connection would fall back to using the IPv6 address, it just took a very long time to do so.

The fix is to set the default address to the IPv6 as soon as we remove the IPv4 configuration.

Description of PR

Speed up ip/test_mgmt_ipv6_only.py up to 7 times faster.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605

Approach

What is the motivation for this PR?

Right now ip/test_mgmt_ipv6_only.py takes an excessively long time to run, I am fixing it and speeding it up.

How did you do it?

As-is the test "worked" and tested the IPv6 address on the management interface, just in a roundabout way since it relied on IPv4 timing out and falling back to IPv6. I added a new function to update this address on the ansible host after it is found.

The new set_ansible_host function is called twice: once before config reload and once after duthosts.reset() This is intentional, to speed up the config reload which will and then to speed up the tests after duthosts.reset wipes out the ansible_host ip address setting update.

How did you verify/test it?

I ran ip/test_mgmt_ipv6_only.py several times without then with my change.
Without my change on a max topology T2 device this test would take as long as 2 hours and 40 minutes.
With my change this test file took between 20 and 30 minutes.

9 passed, 1 skipped, 531 warnings in 1323.60s (0:22:03)

I also verified that this change did not affect the tests running before and after it:

[ ip/test_mgmt_ipv6_only.py runs ]
------- live log setup -------
19/06/2026 17:14:55 duthost_utils.log_ansible_host           L0781 WARNING| PBAILEY [BEFORE duthosts_ipv6_mgmt_only] HOSTNAME ansible_host=<an IPv4 address>
19/06/2026 17:23:09 duthost_utils.log_ansible_host           L0781 WARNING| PBAILEY [AFTER duthosts_ipv6_mgmt_only] qzd301 ansible_host=<an IPv6 Address>
[ all ip/test_mgmt_ipv6_only.py tests pass ]

[ ipfwd/ tests run ]
------- live log setup -------
19/06/2026 17:36:56 duthost_utils.log_ansible_host           L0781 WARNING| PBAILEY [BEFORE ipfwd/test_dip_sip lldp_setup] HOSTNAME ansible_host=<the original IPv4 address>

[ all ipfwd tests pass]

Right now, ip/test_mgmt_ipv6_only.py takes 2 to 2.5 hours to run.
The test is so slow because every ansible connection times out after removing the ipv4 mgmt interface address.
The new runtime is about 22 minutes, which is 6x to 7x faster.

We need to update the ansible host to be aware of the correct IPv6 address it should now be using.
Previously this test still passed because every ansible ssh connection would fall back to using the IPv6 address
So the fix is to set the default address to the IPv6 as soon as we remove the IPv4 configuration.

As-is the test "worked" and tested the ipv6 address on the management interface, just in a roundabout way since it relied on ipv4 timing out and falling back to ipv6.
I added a new function to update this address on the ansible host after it is found.

The new set_ansible_host function is called twice: once before config reload and once after `duthosts.reset()`
This is intentional, to speed up the config reload which will and then to speed up the tests after `duthosts.reset` wipes out the ansible_host ip address setting update.

Signed-off-by: Peter <peterbailey@arista.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@peterbailey-arista peterbailey-arista changed the title Reduce ip/test_mgmt_ipv6_only.py runtime by ~85% Optimize ip/test_mgmt_ipv6_only.py to reduce runtime by ~85% Jun 19, 2026
@mssonicbld mssonicbld added Request for 202511 branch Request to backport a change to 202511 branch Request for 202605 branch labels Jun 20, 2026
@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request for branch(es): 202511,202605.
Added label(s) for branch(es) 202511,202605.

---Powered by SONiC BuildBot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Request for 202511 branch Request to backport a change to 202511 branch Request for 202605 branch

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants