Skip to content

[action] [PR:18301] Fix PortChannel name matching in verify_attr_change to handle leading spaces#19458

Merged
mssonicbld merged 1 commit intosonic-net:202411from
mssonicbld:cherry/202411/18301
Jul 9, 2025
Merged

[action] [PR:18301] Fix PortChannel name matching in verify_attr_change to handle leading spaces#19458
mssonicbld merged 1 commit intosonic-net:202411from
mssonicbld:cherry/202411/18301

Conversation

@mssonicbld
Copy link
Collaborator

Description of PR

Summary:
Fixes # (issue)

Type of change

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

Back port request

  • 202405
  • 202411

Approach

What is the motivation for this PR?

test_portchannel_interface_tc2_attributes failed with the following error:

 if attr == "mtu":
 output = duthost.shell("show interfaces status | grep -w '^{}' | awk '{{print $4}}'".format(po_name))
 
> pytest_assert(output['stdout'] == value, "{} attribute {} failed to change to {}".format(po_name, attr, value))
E Failed: PortChannel102 attribute mtu failed to change to 3324

This is due to cmd "show interfaces status | grep -w '^{}' | awk '{{print $4}}'" failed to filter out the correct PortChannel interface line when the PortChannel name is indented with spaces:

 PortChannel102 N/A 100G 9100 N/A N/A routed up up N/A N/A
 PortChannel104 N/A 100G 9100 N/A N/A routed up up N/A N/A
 PortChannel106 N/A 100G 9100 N/A N/A routed up up N/A N/A
 PortChannel108 N/A 100G 9100 N/A N/A routed up up N/A N/A
 PortChannel109 N/A 100G 9100 N/A N/A routed up up N/A N/A
PortChannel1010 N/A 100G 9100 N/A N/A routed up up N/A N/A
PortChannel1011 N/A 100G 9100 N/A N/A routed up up N/A N/A
PortChannel1012 N/A 100G 9100 N/A N/A routed up up N/A N/A

This PR updates the verify_attr_change function in test_portchannel_interface.py to correctly handle leading spaces in the PortChannel name when parsing interface status output.

How did you do it?

Modified the grep pattern from '^{}' to ^[[:space:]]*{} to match interface lines with leading spaces robustly.

How did you verify/test it?

Run generic_config_updater/test_portchannel_interface.py::test_portchannel_interface_tc2_attributes manually on DUT.

generic_config_updater/test_portchannel_interface.py::test_portchannel_interface_tc2_attributes PASSED [100%]

Any platform specific information?

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

Documentation

Signed-off-by: zitingguo-ms zitingguo@microsoft.com

… spaces (sonic-net#18301)

What is the motivation for this PR?
test_portchannel_interface_tc2_attributes failed with the following error:

        if attr == "mtu":
            output = duthost.shell("show interfaces status | grep -w '^{}' | awk '{{print $4}}'".format(po_name))
    
>           pytest_assert(output['stdout'] == value, "{} attribute {} failed to change to {}".format(po_name, attr, value))
E           Failed: PortChannel102 attribute mtu failed to change to 3324
This is due to cmd "show interfaces status | grep -w '^{}' | awk '{{print $4}}'" failed to filter out the correct PortChannel interface line when the PortChannel name is indented with spaces:

 PortChannel102              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
 PortChannel104              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
 PortChannel106              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
 PortChannel108              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
 PortChannel109              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
PortChannel1010              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
PortChannel1011              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
PortChannel1012              N/A     100G   9100    N/A           N/A           routed      up       up              N/A         N/A
This PR updates the verify_attr_change function in test_portchannel_interface.py to correctly handle leading spaces in the PortChannel name when parsing interface status output.

How did you do it?
Modified the grep pattern from '^{}' to ^[[:space:]]*{} to match interface lines with leading spaces robustly.

How did you verify/test it?
Run generic_config_updater/test_portchannel_interface.py::test_portchannel_interface_tc2_attributes manually on DUT.

generic_config_updater/test_portchannel_interface.py::test_portchannel_interface_tc2_attributes PASSED
@mssonicbld
Copy link
Collaborator Author

Original PR: #18301

@mssonicbld
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StormLiangMS StormLiangMS reopened this Jul 9, 2025
@mssonicbld
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld mssonicbld merged commit b1b95dc into sonic-net:202411 Jul 9, 2025
17 checks passed
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.

3 participants