From d7a7883abdbd969130fa52fa38b565f5697b01c5 Mon Sep 17 00:00:00 2001 From: tkishida Date: Wed, 17 Dec 2025 10:30:30 -0800 Subject: [PATCH] fix: #304 skip exception for fabricNodePEp with non-zero totalCount --- aci-preupgrade-validation-script.py | 10 +++++- tests/test_get_vpc_node.py | 47 ++++++++--------------------- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index b969bf69..3bface4f 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -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() diff --git a/tests/test_get_vpc_node.py b/tests/test_get_vpc_node.py index 956377cc..0f664a5d 100644 --- a/tests/test_get_vpc_node.py +++ b/tests/test_get_vpc_node.py @@ -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 = [ @@ -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()