Skip to content

Commit

Permalink
fix: fix port does not exist error test_bgp_queue (#15949)
Browse files Browse the repository at this point in the history
Description of PR
Summary:
Fixes # (issue) 30457143

Currently this is using the old method of capturing queue counters:

sudo ip netns exec asic1 show queue counters Ethernet128
This will throw an issue with some testbed and says Ethernet128 does not exists. (haven't had chance to confirm why)

However since we have new support for -n sonic-net/sonic-utilities#2439 we should be using this instead

Tested by running manual commands

admin@str3-8800-lc4-1:~$ sudo ip netns exec asic1 show queue counters Ethernet128
Port doesn't exist! Ethernet128
admin@str3-8800-lc4-1:~$ show queue counters Ethernet128 -n asic1
For namespace asic1:
       Port    TxQ    Counter/pkts    Counter/bytes    Drop/pkts    Drop/bytes
-----------  -----  --------------  ---------------  -----------  ------------
Ethernet128    UC0               0                0            0             0
...
Type of change

Approach
What is the motivation for this PR?
How did you do it?
Update the test to use new APIs that support -n

How did you verify/test it?
Manually run, needs to verify with available testbed.

Signed-off-by: Austin Pham <[email protected]>
  • Loading branch information
auspham authored Dec 11, 2024
1 parent da28241 commit 4e48542
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/bgp/test_bgp_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def get_queue_counters(asichost, port, queue):
Return the counter for a given queue in given port
"""
cmd = "show queue counters {}".format(port)
output = asichost.command(cmd)['stdout_lines']
output = asichost.command(cmd, new_format=True)['stdout_lines']

txq = "UC{}".format(queue)
for line in output:
fields = line.split()
Expand Down
9 changes: 7 additions & 2 deletions tests/common/devices/sonic_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ def create_ssh_tunnel_sai_rpc(self):
" -L *:{}:{}:{} localhost").format(self.get_rpc_port_ssh_tunnel(), ns_docker_if_ipv4,
self._RPC_PORT_FOR_SSH_TUNNEL))

def command(self, cmdstr):
def command(self, cmdstr, new_format=False):
"""
Prepend 'ip netns' option for commands meant for this ASIC
If new format is provided (new_format=True) we use the syntax "{cmd} -n asic{index}" instead.
Args:
cmdstr
Returns:
Expand All @@ -419,7 +421,10 @@ def command(self, cmdstr):
if not self.sonichost.is_multi_asic or self.namespace == DEFAULT_NAMESPACE:
return self.sonichost.command(cmdstr)

cmdstr = "sudo ip netns exec {} {}".format(self.namespace, cmdstr)
if new_format:
cmdstr = "sudo {} {}".format(cmdstr, self.cli_ns_option)
else:
cmdstr = "sudo ip netns exec {} {}".format(self.namespace, cmdstr)

return self.sonichost.command(cmdstr)

Expand Down

0 comments on commit 4e48542

Please sign in to comment.