Skip to content

Commit 6c0d4e8

Browse files
[msft-202503] Cherry pick PR18062: Voq tests changes to support single-dut-multi-asic (sonic-net#253)
Cherry pick of sonic-net#18062 Depends on sonic-net#252 We should first merge sonic-net#252, this will cause a conflict which I can resolve with a rebase and then we should merge this in.
1 parent 49811f8 commit 6c0d4e8

6 files changed

Lines changed: 76 additions & 23 deletions

File tree

tests/common/helpers/voq_helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,12 @@ def check_neighbors_are_gone(duthosts, all_cfg_facts, per_host, asic, neighbors)
11001100

11011101
asicdb_neigh_table = asicdb.dump_neighbor_table()
11021102
app_neigh_table = appdb.dump_neighbor_table()
1103-
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
1103+
if len(duthosts) == 1:
1104+
voqdb = VoqDbCli(duthosts.frontend_nodes[0])
1105+
elif len(duthosts) > 1:
1106+
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
1107+
else:
1108+
raise RuntimeError("Length of duthosts is:{}".format(len(duthosts)))
11041109
voq_dump = voqdb.dump_neighbor_table()
11051110

11061111
for neighbor in neighbors:

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,14 +2543,20 @@ voq/test_voq_counter.py::TestVoqCounter::test_voq_queue_counter[multi_dut_shortl
25432543
voq/test_voq_fabric_capacity.py:
25442544
skip:
25452545
reason: "Skip test_voq_fabric_capacity on unsupported testbed."
2546+
conditions_logical_operator: "OR"
25462547
conditions:
2547-
- "('t2' not in topo_name) or (asic_subtype not in ['broadcom-dnx']) or (asic_type in ['cisco-8000'])"
2548+
- "('t2' not in topo_name)"
2549+
- "(asic_subtype not in ['broadcom-dnx'])"
2550+
- "(asic_type in ['cisco-8000'])"
25482551

25492552
voq/test_voq_fabric_isolation.py:
25502553
skip:
25512554
reason: "Skip test_voq_fabric_isolation on unsupported testbed."
2555+
conditions_logical_operator: "OR"
25522556
conditions:
2553-
- "('t2' not in topo_name) or (asic_subtype not in ['broadcom-dnx']) or (asic_type in ['cisco-8000'])"
2557+
- "('t2' not in topo_name)"
2558+
- "(asic_subtype not in ['broadcom-dnx'])"
2559+
- "(asic_type in ['cisco-8000'])"
25542560

25552561
voq/test_voq_fabric_status_all.py:
25562562
skip:

tests/voq/test_voq_chassis_app_db_consistency.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def verify_data_in_db(post_change_db_dump, tmp_pc, pc_members, duthosts, pc_nbr_
2828
# Verifcation on SYSTEM_LAG_MEMBER_TABLE
2929
voq_lag.verify_lag_member_in_chassis_db(duthosts, pc_members)
3030
# Verification on SYSTEM_NEIGH for pc_nbr_ip
31-
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
31+
if len(duthosts) == 1:
32+
voqdb = VoqDbCli(duthosts.frontend_nodes[0])
33+
else:
34+
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
3235
neigh_key = voqdb.get_neighbor_key_by_ip(pc_nbr_ip)
3336
if tmp_pc not in neigh_key:
3437
pytest.fail("Portchannel Neigh ip {} is not allocatioed to tmp portchannel {}".format(pc_nbr_ip, tmp_pc))
@@ -249,7 +252,15 @@ def get_db_dump(duthosts, duthost):
249252
chassis_app_db_sysparams = {}
250253
system_lag_id = {}
251254
key = "*SYSTEM*|*" + duthost.sonichost.hostname + "*"
252-
chassis_app_db_result = redis_get_keys(duthosts.supervisor_nodes[0], "CHASSIS_APP_DB", key)
255+
if len(duthosts) == 1:
256+
chassis_app_db_result = redis_get_keys(duthosts.frontend_nodes[0],
257+
"CHASSIS_APP_DB", key)
258+
voqdb = VoqDbCli(duthosts.frontend_nodes[0])
259+
elif len(duthosts) > 1:
260+
chassis_app_db_result = redis_get_keys(duthosts.supervisor_nodes[0], "CHASSIS_APP_DB", key)
261+
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])
262+
else:
263+
raise RuntimeError("Length of duthosts is:{}".format(len(duthosts)))
253264
if chassis_app_db_result is not None:
254265
chassis_app_db_sysparams["CHASSIS_APP_DB"] = chassis_app_db_result
255266
voqdb = VoqDbCli(duthosts.supervisor_nodes[0])

tests/voq/test_voq_disrupts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def test_reboot_supervisor(duthosts, localhost, all_cfg_facts, nbrhosts, nbr_mac
168168
nbrhosts: nbrhosts fixture
169169
nbr_macs: nbr_macs fixture
170170
"""
171+
if len(duthosts) == 1:
172+
pytest.skip("Test only applicable for modular chassis")
171173
logger.info("=" * 80)
172174
logger.info("Precheck")
173175
logger.info("-" * 80)

tests/voq/test_voq_fabric_capacity.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ def test_fabric_capacity(duthosts, enum_frontend_dut_hostname):
8282

8383
# Start the test. Isolate a link and check if the capacity command get updated.
8484
# Unisolate the link and check if the capacity command get updated.
85-
if duthost.is_multi_asic:
86-
asicName = "asic{}".format(asic)
87-
else:
88-
asicName = ""
8985
try:
9086
# isolate a link on the chip
91-
cmd = "sudo config fabric port isolate {} {}".format(shutlink, asicName)
87+
if duthost.is_multi_asic:
88+
cmd = "sudo config fabric port isolate {} -n asic{}".format(shutlink, asic)
89+
else:
90+
cmd = "sudo config fabric port isolate {}".format(shutlink)
9291
cmd_output = duthost.shell(cmd, module_ignore_errors=True)["stdout"].split("\n")
9392

9493
# check the output of "show fabric monitor capcity" command
@@ -98,7 +97,10 @@ def test_fabric_capacity(duthosts, enum_frontend_dut_hostname):
9897
"The number of opertional links should be {}".format(exp_links))
9998

10099
# unisolate the link so the capacity is back
101-
cmd = "sudo config fabric port unisolate {} {}".format(shutlink, asicName)
100+
if duthost.is_multi_asic:
101+
cmd = "sudo config fabric port unisolate {} -n asic{}".format(shutlink, asic)
102+
else:
103+
cmd = "sudo config fabric port unisolate {}".format(shutlink)
102104
cmd_output = duthost.shell(cmd, module_ignore_errors=True)["stdout"].split("\n")
103105

104106
# check the output of "show fabric monitor capcity" command
@@ -108,7 +110,10 @@ def test_fabric_capacity(duthosts, enum_frontend_dut_hostname):
108110
"The number of opertional links should be {}".format(exp_links))
109111
finally:
110112
# clean up the test
111-
cmd = "sudo config fabric port unisolate {} {}".format(shutlink, asicName)
113+
if duthost.is_multi_asic:
114+
cmd = "sudo config fabric port unisolate {} -n asic{}".format(shutlink, asic)
115+
else:
116+
cmd = "sudo config fabric port unisolate {}".format(shutlink)
112117
cmd_output = duthost.shell(cmd, module_ignore_errors=True)["stdout"].split("\n")
113118

114119

tests/voq/test_voq_ipfwd.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,21 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
216216
for a_dut in duthosts:
217217
minigraph_facts = a_dut.get_extended_minigraph_facts(tbinfo)
218218
minigraph_neighbors = minigraph_facts['minigraph_neighbors']
219+
minigraph_portchannels = minigraph_facts['minigraph_portchannels']
220+
portT1_neigh = defaultdict(list)
219221
for key, value in list(minigraph_neighbors.items()):
220222
if 'T1' in value['name'] or 'LT2' in value['name']:
221223
dutA = a_dut
222-
break
224+
asic = value['namespace'][-1]
225+
port = None
226+
for port_ch, val in list(minigraph_portchannels.items()):
227+
if key in val['members']:
228+
port = port_ch
229+
if not port:
230+
port = key
231+
if port not in portT1_neigh[asic]:
232+
portT1_neigh[asic].append(port)
233+
223234
if dutA:
224235
break
225236

@@ -229,10 +240,12 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
229240

230241
for asic_index, asic_cfg in enumerate(all_cfg_facts[dutA.hostname]):
231242
cfg_facts = asic_cfg['ansible_facts']
232-
cfgd_intfs = cfg_facts['INTERFACE'] if 'INTERFACE' in cfg_facts else {}
233-
cfgd_pos = cfg_facts['PORTCHANNEL_INTERFACE'] if 'PORTCHANNEL_INTERFACE' in cfg_facts else {}
234-
eths = [intf for intf in cfgd_intfs if "ethernet" in intf.lower() and cfgd_intfs[intf] != {}]
235-
pos = [intf for intf in cfgd_pos if "portchannel" in intf.lower()]
243+
eths = []
244+
pos = []
245+
for asic, intf in portT1_neigh.items():
246+
if int(asic) == asic_index:
247+
eths = [n for n in intf if n.startswith("Ethernet")]
248+
pos = [n for n in intf if n.startswith("PortChannel")]
236249
if port_type_a == "ethernet":
237250
if len(eths) != 0:
238251
intfs_to_test['portA'] = get_info_for_a_port(cfg_facts, eths, version, dutA, asic_index, nbrhosts)
@@ -278,23 +291,34 @@ def pick_ports(duthosts, all_cfg_facts, nbrhosts, tbinfo, port_type_a="ethernet"
278291
other_dut_to_use = None
279292
minigraph_facts = dut.get_extended_minigraph_facts(tbinfo)
280293
minigraph_neighbors = minigraph_facts['minigraph_neighbors']
294+
minigraph_portchannels = minigraph_facts['minigraph_portchannels']
295+
portT3_neigh = defaultdict(list)
281296
for key, value in list(minigraph_neighbors.items()):
282297
if 'T3' in value['name']:
283298
other_dut_to_use = dut
284-
break
299+
asic = value['namespace'][-1]
300+
port = None
301+
for port_ch, val in list(minigraph_portchannels.items()):
302+
if key in val['members']:
303+
port = port_ch
304+
if not port:
305+
port = key
306+
if port not in portT3_neigh[asic]:
307+
portT3_neigh[asic].append(port)
285308

286309
if other_dut_to_use is None:
287310
# This DUT is not connected to T3 VM's - ignore it
288311
continue
289312
cfg_facts = asic_cfg['ansible_facts']
290-
cfgd_intfs = cfg_facts['INTERFACE'] if 'INTERFACE' in cfg_facts else {}
291313
cfgd_dev_neighbor = cfg_facts['DEVICE_NEIGHBOR'] if 'DEVICE_NEIGHBOR' in cfg_facts else {}
292314
cfgd_dev_neigh_md = cfg_facts['DEVICE_NEIGHBOR_METADATA'] if 'DEVICE_NEIGHBOR_METADATA' in cfg_facts else {}
293-
cfgd_pos = cfg_facts['PORTCHANNEL_INTERFACE'] if 'PORTCHANNEL_INTERFACE' in cfg_facts else {}
294315
cfgd_pc_members = cfg_facts['PORTCHANNEL_MEMBER'] if 'PORTCHANNEL_MEMBER' in cfg_facts else {}
295-
eths_orig = [intf for intf in cfgd_intfs if "ethernet" in intf.lower() and cfgd_intfs[intf] != {}]
296-
pos = [intf for intf in cfgd_pos if "portchannel" in intf.lower()]
297-
316+
eths_orig = []
317+
pos = []
318+
for asic, intf in portT3_neigh.items():
319+
if int(asic) == asic_index:
320+
eths_orig = [n for n in intf if n.startswith("Ethernet")]
321+
pos = [n for n in intf if n.startswith("PortChannel")]
298322
# Remove the interface from eths and pos if the BGP neighbor is of type RegionalHub
299323
dev_rh_neigh = [neigh for neigh in cfgd_dev_neigh_md
300324
if cfgd_dev_neigh_md[neigh]["type"] == "RegionalHub"]

0 commit comments

Comments
 (0)