From 4649eef8e1b201c9c61ef854e70b453997702bfd Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 27 Jan 2018 06:06:22 -0800 Subject: [PATCH] ldp-vpls-topo1: new format for ospf neighbor json Accept new format in ospf neighbor json output in addition to old version. New format was introduced with PR1659 Signed-off-by: Martin Winter --- .../r1/show_ip_ospf_neighbor.ref | 37 +++++++++++++------ .../r1/show_ip_ospf_neighbor.ref-no-neigh | 18 +++++++++ .../r2/show_ip_ospf_neighbor.ref | 36 ++++++++++++------ .../r2/show_ip_ospf_neighbor.ref-no-neigh | 18 +++++++++ .../r3/show_ip_ospf_neighbor.ref | 36 ++++++++++++------ .../r3/show_ip_ospf_neighbor.ref-no-neigh | 18 +++++++++ .../ldp-vpls-topo1/test_ldp_vpls_topo1.py | 12 ++++-- 7 files changed, 136 insertions(+), 39 deletions(-) create mode 100644 tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref-no-neigh create mode 100644 tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref-no-neigh create mode 100644 tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref-no-neigh diff --git a/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref index 7c4d0ab58c..fb193265be 100644 --- a/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref +++ b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref @@ -1,18 +1,31 @@ { - "2.2.2.2":[ + "neighbors":[ { - "priority":1, - "state":"Full/DR", - "address":"10.0.1.2", - "ifaceName":"r1-eth1:10.0.1.1" - } - ], - "3.3.3.3":[ + "2.2.2.2":[ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.1.2", + "ifaceName":"r1-eth1:10.0.1.1", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ] + }, { - "priority":1, - "state":"Full/DR", - "address":"10.0.2.3", - "ifaceName":"r1-eth2:10.0.2.1" + "3.3.3.3":[ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.2.3", + "ifaceName":"r1-eth2:10.0.2.1", + "retransmitCounter":0, + "requestCounter":0, + "dbSummaryCounter":0 + } + ] } ] } + diff --git a/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref-no-neigh b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref-no-neigh new file mode 100644 index 0000000000..7c4d0ab58c --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r1/show_ip_ospf_neighbor.ref-no-neigh @@ -0,0 +1,18 @@ +{ + "2.2.2.2":[ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.1.2", + "ifaceName":"r1-eth1:10.0.1.1" + } + ], + "3.3.3.3":[ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.2.3", + "ifaceName":"r1-eth2:10.0.2.1" + } + ] +} diff --git a/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref index a982c1cbd3..1376579757 100644 --- a/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref +++ b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref @@ -1,18 +1,30 @@ { - "1.1.1.1":[ + "neighbors":[ { - "priority":1, - "state":"Full/Backup", - "address":"10.0.1.1", - "ifaceName":"r2-eth1:10.0.1.2" - } - ], - "3.3.3.3":[ + "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 + } + ] + }, { - "priority":1, - "state":"Full/DR", - "address":"10.0.3.3", - "ifaceName":"r2-eth2:10.0.3.2" + "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/r2/show_ip_ospf_neighbor.ref-no-neigh b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref-no-neigh new file mode 100644 index 0000000000..a982c1cbd3 --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r2/show_ip_ospf_neighbor.ref-no-neigh @@ -0,0 +1,18 @@ +{ + "1.1.1.1":[ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.1.1", + "ifaceName":"r2-eth1:10.0.1.2" + } + ], + "3.3.3.3":[ + { + "priority":1, + "state":"Full/DR", + "address":"10.0.3.3", + "ifaceName":"r2-eth2:10.0.3.2" + } + ] +} diff --git a/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref index d7e0e42405..41de304b2b 100644 --- a/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref +++ b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref @@ -1,18 +1,30 @@ { - "1.1.1.1":[ + "neighbors":[ { - "priority":1, - "state":"Full/Backup", - "address":"10.0.2.1", - "ifaceName":"r3-eth1:10.0.2.3" - } - ], - "2.2.2.2":[ + "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 + } + ] + }, { - "priority":1, - "state":"Full/Backup", - "address":"10.0.3.2", - "ifaceName":"r3-eth2:10.0.3.3" + "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/r3/show_ip_ospf_neighbor.ref-no-neigh b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref-no-neigh new file mode 100644 index 0000000000..d7e0e42405 --- /dev/null +++ b/tests/topotests/ldp-vpls-topo1/r3/show_ip_ospf_neighbor.ref-no-neigh @@ -0,0 +1,18 @@ +{ + "1.1.1.1":[ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.2.1", + "ifaceName":"r3-eth1:10.0.2.3" + } + ], + "2.2.2.2":[ + { + "priority":1, + "state":"Full/Backup", + "address":"10.0.3.2", + "ifaceName":"r3-eth2:10.0.3.3" + } + ] +} 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 1218a6ca72..32e958fa56 100755 --- a/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py +++ b/tests/topotests/ldp-vpls-topo1/test_ldp_vpls_topo1.py @@ -186,9 +186,15 @@ def test_ospf_convergence(): router = tgen.gears['r1'] output = router.vtysh_cmd("show ip ospf neighbor json", isjson=True) - if isinstance(output["2.2.2.2"], dict): - reffile = "show_ip_ospf_neighbor.ref-old-nolist" - else: + # 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: + 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']: -- 2.39.5