From ed518a5e534663d872f43d3c691cf296481fa3dc Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 19 Oct 2022 13:07:02 +0000 Subject: [PATCH] topotests: ospfapi - enahnce test to cover explicit delete and 0 len opaque LSAs Signed-off-by: Lou Berger (cherry picked from commit 0b242b118fb8db6397d186f62d7f912abeb620ac) --- .../topotests/ospfapi/test_ospf_clientapi.py | 237 +++++++++++++++++- 1 file changed, 229 insertions(+), 8 deletions(-) diff --git a/tests/topotests/ospfapi/test_ospf_clientapi.py b/tests/topotests/ospfapi/test_ospf_clientapi.py index 631c8025b5..f6928d7cd0 100644 --- a/tests/topotests/ospfapi/test_ospf_clientapi.py +++ b/tests/topotests/ospfapi/test_ospf_clientapi.py @@ -468,28 +468,249 @@ def _test_opaque_add_del(tgen, apibin): stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) - p = r1.popen([apibin, "-v", "add,11,232,3,ebadf00d"]) + p = r1.popen( + [ + apibin, + "-v", + "add,9,10.0.1.1,230,2,00000202", + "add,10,1.2.3.4,231,1,00010101", + "wait,1", + "add,10,1.2.3.4,231,2", + "add,11,232,3,ebadf00d", + "wait,20", + "del,10,1.2.3.4,231,1", + "del,10,1.2.3.4,231,2", + ] + ) + + add_input_dict = { + "areas": { + "1.2.3.4": { + "linkLocalOpaqueLsa": [ + { + "lsId": "230.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "8142", + } + ], + "areaLocalOpaqueLsa": [ + { + "lsId": "231.0.0.1", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "695a", + }, + { + "lsId": "231.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "4881", + }, + ], + } + }, + "asExternalOpaqueLsa": [ + { + "lsId": "232.0.0.3", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "c666", + } + ], + } + + step("reachable: check for add LSAs") + json_cmd = "show ip ospf da json" + assert verify_ospf_database(tgen, r1, add_input_dict, json_cmd) is None + assert verify_ospf_database(tgen, r2, add_input_dict, json_cmd) is None + + numcs = 3 + json_cmds = [ + "show ip ospf da opaque-link json", + "show ip ospf da opaque-area json", + "show ip ospf da opaque-as json", + ] + add_detail_input_dict = [ + { + "linkLocalOpaqueLsa": { + "areas": { + "1.2.3.4": [ + { + "linkStateId": "230.0.0.2", + "advertisingRouter": "192.168.0.1", + "lsaSeqNumber": "80000001", + "checksum": "8142", + "length": 24, + "opaqueId": 2, + "opaqueDataLength": 4, + } + ] + } + } + }, + { + "areaLocalOpaqueLsa": { + "areas": { + "1.2.3.4": [ + { + "linkStateId": "231.0.0.1", + "advertisingRouter": "192.168.0.1", + "lsaSeqNumber": "80000001", + "checksum": "695a", + "length": 24, + "opaqueDataLength": 4, + }, + { + "linkStateId": "231.0.0.2", + "advertisingRouter": "192.168.0.1", + "lsaSeqNumber": "80000001", + "checksum": "4881", + "length": 20, + "opaqueDataLength": 0, + }, + ] + } + } + }, + { + "asExternalOpaqueLsa": [ + { + "linkStateId": "232.0.0.3", + "advertisingRouter": "192.168.0.1", + "lsaSeqNumber": "80000001", + "checksum": "c666", + "length": 24, + "opaqueDataLength": 4, + } + ] + }, + ] + i = 0 + while i < numcs: + step("reachable: check for add LSA details: %s" % json_cmds[i]) + assert ( + verify_ospf_database(tgen, r1, add_detail_input_dict[i], json_cmds[i]) + is None + ) + assert ( + verify_ospf_database(tgen, r2, add_detail_input_dict[i], json_cmds[i]) + is None + ) + i += 1 # Wait for add notification # RECV: LSA update msg for LSA 232.0.0.3 in area 0.0.0.0 seq 0x80000001 len 24 age 9 - ls_id = "232.0.0.3" - waitfor = "RECV:.*update msg.*LSA {}.*age ([0-9]+)".format(ls_id) - _ = _wait_output(pread, waitfor) + step("reachable: check for API add notifications") + ls_ids = ["230.0.0.2", "231.0.0.1", "231.0.0.2", "232.0.0.3"] + for ls_id in ls_ids: + waitfor = "RECV:.*update msg.*LSA {}.*age ([0-9]+)".format(ls_id) + _ = _wait_output(pread, waitfor) + + del_input_dict = { + "areas": { + "1.2.3.4": { + "linkLocalOpaqueLsa": [ + { + "lsId": "230.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "8142", + } + ], + "areaLocalOpaqueLsa": [ + { + "lsaAge": 3600, + "lsId": "231.0.0.1", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "695a", + }, + { + "lsaAge": 3600, + "lsId": "231.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "4881", + }, + ], + } + }, + "asExternalOpaqueLsa": [ + { + "lsId": "232.0.0.3", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "c666", + } + ], + } + + step("reachable: check for explicit withdrawal LSAs") + json_cmd = "show ip ospf da json" + assert verify_ospf_database(tgen, r1, del_input_dict, json_cmd) is None + assert verify_ospf_database(tgen, r2, del_input_dict, json_cmd) is None p.terminate() if p.wait(): comm_error(p) + del_input_dict = { + "areas": { + "1.2.3.4": { + "linkLocalOpaqueLsa": [ + { + "lsaAge": 3600, + "lsId": "230.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "8142", + } + ], + "areaLocalOpaqueLsa": [ + { + "lsaAge": 3600, + "lsId": "231.0.0.1", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "695a", + }, + { + "lsaAge": 3600, + "lsId": "231.0.0.2", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "4881", + }, + ], + } + }, + "asExternalOpaqueLsa": [ + { + "lsaAge": 3600, + "lsId": "232.0.0.3", + "advertisedRouter": "192.168.0.1", + "sequenceNumber": "80000001", + "checksum": "c666", + } + ], + } + + step("reachable: check for implicit withdrawal LSAs") + json_cmd = "show ip ospf da json" + assert verify_ospf_database(tgen, r1, del_input_dict, json_cmd) is None + assert verify_ospf_database(tgen, r2, del_input_dict, json_cmd) is None # step("reachable: check for flush/age out") # # Wait for max age notification # waitfor = "RECV:.*update msg.*LSA {}.*age 3600".format(ls_id) # _wait_output(pread, waitfor) - step("reachable: check for delete") - # Wait for delete notification - waitfor = "RECV:.*delete msg.*LSA {}.*".format(ls_id) - _wait_output(pread, waitfor) + step("reachable: check for API delete notifications") + ls_ids = ["231.0.0.1", "231.0.0.2", "230.0.0.2", "232.0.0.3"] + for ls_id in ls_ids: + waitfor = "RECV:.*delete msg.*LSA {}.*".format(ls_id) + _ = _wait_output(pread, waitfor) except Exception: if p: p.terminate() -- 2.39.5