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 <pat@voltanet.io>
This commit is contained in:
Pat Ruddy 2020-06-02 11:47:24 +01:00
parent 578c52e5c0
commit 2d706c4e25
3 changed files with 11 additions and 8 deletions

View File

@ -3,7 +3,6 @@
"type":"L2",
"vrf":"default",
"vxlanInterface":"vxlan101",
"ifindex":5,
"vtepIp":"10.10.10.10",
"mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No",

View File

@ -3,7 +3,6 @@
"type":"L2",
"vrf":"default",
"vxlanInterface":"vxlan101",
"ifindex":5,
"vtepIp":"10.30.30.30",
"mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No",

View File

@ -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