Commit b1b95dc
Fix PortChannel name matching in verify_attr_change to handle leading 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 PASSED1 parent 7461bf3 commit b1b95dc
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
0 commit comments