Skip to content

Commit 8159995

Browse files
authored
fix: #304 skip exception for fabricNodePEp with non-zero totalCount (#305)
1 parent 80b9555 commit 8159995

2 files changed

Lines changed: 22 additions & 35 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,15 @@ def get_vpc_nodes():
17641764
""" Returns list of VPC Node IDs; ['101', '102', etc...] """
17651765
prints("Collecting VPC Node IDs...", end='')
17661766
vpc_nodes = []
1767-
prot_pols = icurl('class', 'fabricNodePEp.json')
1767+
try:
1768+
prot_pols = icurl('class', 'fabricNodePEp.json')
1769+
except Exception as e:
1770+
# CSCws30568: expected for fabricNodePEp to return non-zero totalCount
1771+
# incorrectly for an empty response.
1772+
if str(e).startswith("API response empty with totalCount:"):
1773+
prot_pols = []
1774+
else:
1775+
raise e
17681776
for vpc_node in prot_pols:
17691777
vpc_nodes.append(vpc_node['fabricNodePEp']['attributes']['id'])
17701778
vpc_nodes.sort()

tests/test_get_vpc_node.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,10 @@
77
fabricNodePEps = "fabricNodePEp.json"
88

99
data = [
10-
{
11-
"fabricNodePEp": {
12-
"attributes": {
13-
"dn": "uni/fabric/protpol/expgep-101-103/nodepep-101",
14-
"id": "101"
15-
}
16-
}
17-
},
18-
{
19-
"fabricNodePEp": {
20-
"attributes": {
21-
"dn": "uni/fabric/protpol/expgep-204-206/nodepep-206",
22-
"id": "206"
23-
}
24-
}
25-
},
26-
{
27-
"fabricNodePEp": {
28-
"attributes": {
29-
"dn": "uni/fabric/protpol/expgep-101-103/nodepep-103",
30-
"id": "103"
31-
}
32-
}
33-
},
34-
{
35-
"fabricNodePEp": {
36-
"attributes": {
37-
"dn": "uni/fabric/protpol/expgep-204-206/nodepep-204",
38-
"id": "204"
39-
}
40-
}
41-
}
10+
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-101-103/nodepep-101", "id": "101"}}},
11+
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-204-206/nodepep-206", "id": "206"}}},
12+
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-101-103/nodepep-103", "id": "103"}}},
13+
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-204-206/nodepep-204", "id": "204"}}},
4214
]
4315

4416
data2 = [
@@ -68,8 +40,15 @@
6840
{fabricNodePEps: data2},
6941
["101", "102", "103", "104", "105", "106"],
7042
"Collecting VPC Node IDs...101, 102, 103, 104, ... (and 2 more)\n\n",
71-
)
72-
]
43+
),
44+
# CSCws30568: expected for fabricNodePEp to return non-zero totalCount
45+
# incorrectly for an empty response.
46+
(
47+
{fabricNodePEps: {"totalCount": "8", "imdata": []}},
48+
[],
49+
"Collecting VPC Node IDs...\n\n",
50+
),
51+
],
7352
)
7453
def test_get_vpc_nodes(capsys, mock_icurl, expected_result, expected_stdout):
7554
vpc_nodes = script.get_vpc_nodes()

0 commit comments

Comments
 (0)