@@ -14,35 +14,49 @@ def test_snmp_queues(duthosts, enum_rand_one_per_hwsku_hostname, localhost, cred
14
14
15
15
hostip = duthost .host .options ['inventory_manager' ].get_host (
16
16
duthost .hostname ).vars ['ansible_host' ]
17
+ port_name_to_alias_map = {}
17
18
18
19
for asic_id in duthost .get_asic_ids ():
19
20
namespace = duthost .get_namespace_from_asic_id (asic_id )
20
- sonic_db_cmd = "sonic-db-cli {}" .format ("-n " + namespace if namespace else "" )
21
- q_keys_ns = duthost .shell ('{} CONFIG_DB KEYS "QUEUE|*"' .format (sonic_db_cmd ),
22
- module_ignore_errors = False )['stdout_lines' ]
21
+ config_facts_ns = duthost .config_facts (host = duthost .hostname , source = "running" ,
22
+ namespace = namespace )['ansible_facts' ]
23
+ asic = duthost .asic_instance (asic_id )
24
+ q_keys_ns = asic .run_sonic_db_cli_cmd ('CONFIG_DB KEYS "QUEUE|*"' )['stdout_lines' ]
23
25
if q_keys_ns :
24
26
q_keys .extend (q_keys_ns )
27
+ if config_facts_ns and 'port_name_to_alias_map' in config_facts_ns :
28
+ port_name_to_alias_map .update (config_facts_ns ['port_name_to_alias_map' ])
25
29
26
30
if not q_keys :
27
31
pytest .skip ("No queues configured on interfaces" )
28
32
33
+ # Get alias : port_name map
34
+ alias_port_name_map = {k : v for v , k in port_name_to_alias_map .items ()}
35
+
29
36
q_interfaces = set ()
30
37
# get interfaces which has configured queues
31
38
for key in q_keys :
32
39
intf = key .split ('|' )
33
40
# 'QUEUE|Ethernet*|2'
34
41
if len (intf ) == 3 :
35
42
q_interfaces .add (intf [1 ])
43
+ # Packet chassis 'QUEUE|<hostname>|<asic_ns>|Ethernet*|2'
44
+ elif len (intf ) == 5 :
45
+ q_interfaces .add (intf [3 ])
36
46
37
47
snmp_facts = get_snmp_facts (localhost , host = hostip , version = "v2c" ,
38
48
community = creds_all_duts [duthost .hostname ]["snmp_rocommunity" ],
39
49
wait = True )['ansible_facts' ]
40
50
41
- for k , v in list (snmp_facts ['snmp_interfaces' ].items ()):
42
- if "Ethernet" in v ['description' ]:
43
- intf = v ['description' ].split (':' )
44
- # 'ARISTA*:Ethernet*'
45
- if len (intf ) == 2 :
46
- if intf [1 ] in q_interfaces and 'queues' not in v :
47
- pytest .fail (
48
- "port %s does not have queue counters" % v ['name' ])
51
+ snmp_ifnames = [alias_port_name_map [v ['name' ]]
52
+ for k , v in list (snmp_facts ['snmp_interfaces' ].items ()) if v ['name' ] in alias_port_name_map ]
53
+
54
+ for intf in q_interfaces :
55
+ assert intf in snmp_ifnames , "Port %s with QUEUE config is not present in snmp interfaces"
56
+
57
+ for k , v in snmp_facts ['snmp_interfaces' ].items ():
58
+ # v['name'] is alias for example Ethernet1/1
59
+ if v ['name' ] in alias_port_name_map :
60
+ intf = alias_port_name_map [v ['name' ]]
61
+ if intf in q_interfaces and 'queues' not in v :
62
+ pytest .fail ("port %s does not have queue counters" % v ['name' ])
0 commit comments