Skip to content

Commit 7a89c3a

Browse files
Fixed duplicate entries
1 parent f30d586 commit 7a89c3a

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

aci-preupgrade-validation-script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6441,6 +6441,7 @@ def wred_affected_model_check(tversion, fabric_nodes, **kwargs):
64416441
else:
64426442
return Result(result=PASS, msg="WRED not enabled.")
64436443

6444+
unique_list = {}
64446445
for obj in icurl("class", "eqptFC.json"):
64456446
attr = obj["eqptFC"]["attributes"]
64466447
model = attr.get("model", "")
@@ -6450,7 +6451,8 @@ def wred_affected_model_check(tversion, fabric_nodes, **kwargs):
64506451
if not dn_match:
64516452
continue
64526453
node_id = dn_match.group("node")
6453-
data.append([node_id, node_name_map.get(node_id, ""), "FM", model])
6454+
unique_list[(node_id, model)] = [node_id, node_name_map.get(node_id, ""), "FM", model]
6455+
data = list(unique_list.values())
64546456

64556457
if not data:
64566458
return Result(result=NA, msg="No affected Fabric module found.")

tests/checks/wred_affected_model_check/test_wred_affected_model_check.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@
9797
script.NA,
9898
[],
9999
),
100+
# Case 7: Same node has two FM slots with the same affected model (duplicate eqptFC objects).
101+
# Deduplication by (node_id, model) must result in only one row.
102+
# Expected: FAIL_O with a single row for node 1001.
103+
(
104+
"6.2(1g)",
105+
read_data(dir, "fabricNode_spine.json"),
106+
{
107+
qosCong_api: read_data(dir, "qosCong_wred.json"),
108+
eqptFC_api: read_data(dir, "eqptFC_duplicate.json"),
109+
},
110+
script.FAIL_O,
111+
[["1001", "spine1001", "FM", "N9K-C9508-FM-E"]],
112+
),
100113
],
101114
)
102115
def test_logic(run_check, mock_icurl, tversion, fabric_nodes, expected_result, expected_data):

0 commit comments

Comments
 (0)