From 4e48542b5cd0da111bb644fb05c4399f8323f164 Mon Sep 17 00:00:00 2001 From: "Austin (Thang Pham)" Date: Wed, 11 Dec 2024 15:50:18 +1100 Subject: [PATCH] fix: fix port does not exist error test_bgp_queue (#15949) 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 --- tests/bgp/test_bgp_queue.py | 3 ++- tests/common/devices/sonic_asic.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/bgp/test_bgp_queue.py b/tests/bgp/test_bgp_queue.py index 35666cf1204..88ff7b50387 100644 --- a/tests/bgp/test_bgp_queue.py +++ b/tests/bgp/test_bgp_queue.py @@ -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() diff --git a/tests/common/devices/sonic_asic.py b/tests/common/devices/sonic_asic.py index 89e1b33f8b7..7bffb324027 100644 --- a/tests/common/devices/sonic_asic.py +++ b/tests/common/devices/sonic_asic.py @@ -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: @@ -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)