From 2d706c4e250fcb84401b6d4904c7c68e446a53cb Mon Sep 17 00:00:00 2001 From: Pat Ruddy Date: Tue, 2 Jun 2020 11:47:24 +0100 Subject: [PATCH] tests: remove ifindex from VNI JSON comparison Since the values of ifindices cannot be relied upon across distributions, simpy remove them from the VNI JSON being compared. Signed-off-by: Pat Ruddy --- .../bgp-evpn-vxlan_topo1/PE1/evpn.vni.json | 1 - .../bgp-evpn-vxlan_topo1/PE2/evpn.vni.json | 1 - .../bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py | 17 +++++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/topotests/bgp-evpn-vxlan_topo1/PE1/evpn.vni.json b/tests/topotests/bgp-evpn-vxlan_topo1/PE1/evpn.vni.json index ce16089b89..2937504244 100644 --- a/tests/topotests/bgp-evpn-vxlan_topo1/PE1/evpn.vni.json +++ b/tests/topotests/bgp-evpn-vxlan_topo1/PE1/evpn.vni.json @@ -3,7 +3,6 @@ "type":"L2", "vrf":"default", "vxlanInterface":"vxlan101", - "ifindex":5, "vtepIp":"10.10.10.10", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", diff --git a/tests/topotests/bgp-evpn-vxlan_topo1/PE2/evpn.vni.json b/tests/topotests/bgp-evpn-vxlan_topo1/PE2/evpn.vni.json index 1ac83c495e..0853147a00 100644 --- a/tests/topotests/bgp-evpn-vxlan_topo1/PE2/evpn.vni.json +++ b/tests/topotests/bgp-evpn-vxlan_topo1/PE2/evpn.vni.json @@ -3,7 +3,6 @@ "type":"L2", "vrf":"default", "vxlanInterface":"vxlan101", - "ifindex":5, "vtepIp":"10.30.30.30", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", diff --git a/tests/topotests/bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py index 7ed4c6e7e2..90144f5c66 100755 --- a/tests/topotests/bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py +++ b/tests/topotests/bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py @@ -145,6 +145,15 @@ def teardown_module(mod): tgen.stop_topology() +def show_vni_json_elide_ifindex(pe, vni, expected): + output_json = pe.vtysh_cmd("show evpn vni {} json".format(vni), isjson=True) + + if "ifindex" in output_json: + output_json.pop("ifindex") + + return topotest.json_cmp(output_json, expected) + + def test_pe1_converge_evpn(): "Wait for protocol convergence" @@ -157,9 +166,7 @@ def test_pe1_converge_evpn(): json_file = "{}/{}/evpn.vni.json".format(CWD, pe1.name) expected = json.loads(open(json_file).read()) - test_func = partial( - topotest.router_json_cmp, pe1, "show evpn vni 101 json", expected - ) + test_func = partial(show_vni_json_elide_ifindex, pe1, 101, expected) _, result = topotest.run_and_expect(test_func, None, count=125, wait=1) assertmsg = '"{}" JSON output mismatches'.format(pe1.name) assert result is None, assertmsg @@ -178,9 +185,7 @@ def test_pe2_converge_evpn(): json_file = "{}/{}/evpn.vni.json".format(CWD, pe2.name) expected = json.loads(open(json_file).read()) - test_func = partial( - topotest.router_json_cmp, pe2, "show evpn vni 101 json", expected - ) + test_func = partial(show_vni_json_elide_ifindex, pe2, 101, expected) _, result = topotest.run_and_expect(test_func, None, count=125, wait=1) assertmsg = '"{}" JSON output mismatches'.format(pe2.name) assert result is None, assertmsg -- 2.39.5