Skip to content

[snmp][multi-asic]: Fix test_snmp_queue to support multi-asic platform #9115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tests/snmp/test_snmp_queue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from tests.common.helpers.snmp_helpers import get_snmp_facts
from tests.common.helpers.sonic_db import redis_get_keys

pytestmark = [
pytest.mark.topology('any'),
Expand All @@ -11,14 +10,20 @@
def test_snmp_queues(duthosts, enum_rand_one_per_hwsku_hostname, localhost, creds_all_duts,
collect_techsupport_all_duts):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
if duthost.is_supervisor_node():
pytest.skip("interfaces not present on supervisor node")
q_keys = []

hostip = duthost.host.options['inventory_manager'].get_host(
duthost.hostname).vars['ansible_host']

q_keys = redis_get_keys(duthost, "CONFIG_DB", "QUEUE|*")
for asic_id in duthost.get_asic_ids():
namespace = duthost.get_namespace_from_asic_id(asic_id)
sonic_db_cmd = "sonic-db-cli {}".format("-n " + namespace if namespace else "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonicAsic class already function to run sonic-db-cli on a given asic. Use it directly?

def run_sonic_db_cli_cmd(self, sonic_db_cmd):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified as per comment

q_keys_ns = duthost.shell('{} CONFIG_DB KEYS "QUEUE|*"'.format(sonic_db_cmd),
module_ignore_errors=False)['stdout_lines']
if q_keys_ns:
q_keys.extend(q_keys_ns)

if q_keys is None:
if not q_keys:
pytest.skip("No queues configured on interfaces")

q_interfaces = set()
Expand Down