Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion aci-preupgrade-validation-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,15 @@ def get_vpc_nodes():
""" Returns list of VPC Node IDs; ['101', '102', etc...] """
prints("Collecting VPC Node IDs...", end='')
vpc_nodes = []
prot_pols = icurl('class', 'fabricNodePEp.json')
try:
prot_pols = icurl('class', 'fabricNodePEp.json')
except Exception as e:
# CSCws30568: expected for fabricNodePEp to return non-zero totalCount
# incorrectly for an empty response.
if str(e).startswith("API response empty with totalCount:"):
prot_pols = []
else:
raise e
for vpc_node in prot_pols:
vpc_nodes.append(vpc_node['fabricNodePEp']['attributes']['id'])
vpc_nodes.sort()
Expand Down
47 changes: 13 additions & 34 deletions tests/test_get_vpc_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,10 @@
fabricNodePEps = "fabricNodePEp.json"

data = [
{
"fabricNodePEp": {
"attributes": {
"dn": "uni/fabric/protpol/expgep-101-103/nodepep-101",
"id": "101"
}
}
},
{
"fabricNodePEp": {
"attributes": {
"dn": "uni/fabric/protpol/expgep-204-206/nodepep-206",
"id": "206"
}
}
},
{
"fabricNodePEp": {
"attributes": {
"dn": "uni/fabric/protpol/expgep-101-103/nodepep-103",
"id": "103"
}
}
},
{
"fabricNodePEp": {
"attributes": {
"dn": "uni/fabric/protpol/expgep-204-206/nodepep-204",
"id": "204"
}
}
}
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-101-103/nodepep-101", "id": "101"}}},
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-204-206/nodepep-206", "id": "206"}}},
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-101-103/nodepep-103", "id": "103"}}},
{"fabricNodePEp": {"attributes": {"dn": "uni/fabric/protpol/expgep-204-206/nodepep-204", "id": "204"}}},
]

data2 = [
Expand Down Expand Up @@ -68,8 +40,15 @@
{fabricNodePEps: data2},
["101", "102", "103", "104", "105", "106"],
"Collecting VPC Node IDs...101, 102, 103, 104, ... (and 2 more)\n\n",
)
]
),
# CSCws30568: expected for fabricNodePEp to return non-zero totalCount
# incorrectly for an empty response.
(
{fabricNodePEps: {"totalCount": "8", "imdata": []}},
[],
"Collecting VPC Node IDs...\n\n",
),
],
)
def test_get_vpc_nodes(capsys, mock_icurl, expected_result, expected_stdout):
vpc_nodes = script.get_vpc_nodes()
Expand Down