From 623afc9d83f223c8e32bbf5faff6cf25e7a99e2c Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Thu, 22 Feb 2018 15:52:10 -0300 Subject: [PATCH] ldp-vpls-topo1: support new OSPF JSON format Support the new OSPF JSON output format for `show ip ospf neighbor json` introduced in FRR's PR 1723. Signed-off-by: Rafael Zalamena --- .../r1/show_ip_ospf_neighbor.json | 26 +++++++++++++++++++ .../r2/show_ip_ospf_neighbor.json | 26 +++++++++++++++++++ .../r3/show_ip_ospf_neighbor.json | 26 +++++++++++++++++++ .../ldp-vpls-topo1/test_ldp_vpls_topo1.py | 11 +++++--- 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.json create mode 100644 tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.json diff --git a/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.json b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..6e6c3c8cb8 --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.json @@ -0,0 +1,26 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "state": "Full/DR", + "address": "10.0.1.2", + "ifaceName": "r1-eth1:10.0.1.1", + "requestCounter": 0 + } + ], + "3.3.3.3": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "state": "Full/DR", + "address": "10.0.2.3", + "ifaceName": "r1-eth2:10.0.2.1", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.json b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..b5b10cc535 --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.json @@ -0,0 +1,26 @@ +{ + "neighbors": { + "1.1.1.1": [ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.1.1", + "ifaceName":"r2-eth1:10.0.1.2", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ], + "3.3.3.3": [ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.3.3", + "ifaceName":"r2-eth2:10.0.3.2", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ] + } +} diff --git a/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.json b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..bc7bb1e894 --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.json @@ -0,0 +1,26 @@ +{ + "neighbors": { + "1.1.1.1": [ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.2.1", + "ifaceName":"r3-eth1:10.0.2.3", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ], + "2.2.2.2": [ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.3.2", + "ifaceName":"r3-eth2:10.0.3.3", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ] + } +} diff --git a/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py b/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py index 32e958fa56..e279c8fc68 100755 --- a/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py +++ b/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py @@ -189,13 +189,18 @@ def test_ospf_convergence(): # We could have either old format (without "neighbors" and direct list # of IP's or new format from PR1659 with "neighbors". # Trying old formats first and fall back to new format - try: + # + # New format: neighbors have dict instead of list of dicts (PR1723). + if output.has_key('neighbors'): + if isinstance(output['neighbors'], dict): + reffile = "show_ip_ospf_neighbor.json" + else: + reffile = "show_ip_ospf_neighbor.ref" + else: if isinstance(output["2.2.2.2"], dict): reffile = "show_ip_ospf_neighbor.ref-old-nolist" else: reffile = "show_ip_ospf_neighbor.ref-no-neigh" - except: - reffile = "show_ip_ospf_neighbor.ref" for rname in ['r1', 'r2', 'r3']: router_compare_json_output(rname, "show ip ospf neighbor json", reffile) -- 2.39.5