tests: improve vxlan test determinism

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2021-07-18 18:03:53 +00:00
parent 49549fe2d7
commit bc51ce6810
3 changed files with 32 additions and 9 deletions

View File

@ -6,8 +6,6 @@
"vtepIp":"10.10.10.10", "vtepIp":"10.10.10.10",
"mcastGroup":"0.0.0.0", "mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No", "advertiseGatewayMacip":"No",
"numMacs":6,
"numArpNd":6,
"numRemoteVteps":[ "numRemoteVteps":[
"10.30.30.30" "10.30.30.30"
] ]

View File

@ -6,8 +6,6 @@
"vtepIp":"10.30.30.30", "vtepIp":"10.30.30.30",
"mcastGroup":"0.0.0.0", "mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No", "advertiseGatewayMacip":"No",
"numMacs":6,
"numArpNd":6,
"numRemoteVteps":[ "numRemoteVteps":[
"10.10.10.10" "10.10.10.10"
] ]

View File

@ -28,6 +28,7 @@ test_bgp_evpn_vxlan.py: Test VXLAN EVPN MAC a route signalling over BGP.
import os import os
import sys import sys
import json import json
import re
from functools import partial from functools import partial
from time import sleep from time import sleep
import pytest import pytest
@ -156,6 +157,17 @@ def show_vni_json_elide_ifindex(pe, vni, expected):
return topotest.json_cmp(output_json, expected) return topotest.json_cmp(output_json, expected)
def check_vni_macs_present(tgen, router, vni, maclist):
result = router.vtysh_cmd("show evpn mac vni {} json".format(vni), isjson=True)
for rname, ifname in maclist:
m = tgen.net.macs[(rname, ifname)]
if m not in result["macs"]:
return "MAC ({}) for interface {} on {} missing on {} from {}".format(
m, ifname, rname, router.name, json.dumps(result, indent=4)
)
return None
def test_pe1_converge_evpn(): def test_pe1_converge_evpn():
"Wait for protocol convergence" "Wait for protocol convergence"
@ -169,10 +181,17 @@ def test_pe1_converge_evpn():
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial(show_vni_json_elide_ifindex, pe1, 101, expected) test_func = partial(show_vni_json_elide_ifindex, pe1, 101, expected)
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1) _, result = topotest.run_and_expect(test_func, None, count=45, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(pe1.name) assertmsg = '"{}" JSON output mismatches'.format(pe1.name)
assert result is None, assertmsg
# tgen.mininet_cli() test_func = partial(check_vni_macs_present, tgen, pe1, 101, (
("host1", "host1-eth0"),
("host2", "host2-eth0")
))
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
if result:
logger.warning("%s", result)
assert None, '"{}" missing expected MACs'.format(pe1.name)
def test_pe2_converge_evpn(): def test_pe2_converge_evpn():
@ -188,10 +207,18 @@ def test_pe2_converge_evpn():
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial(show_vni_json_elide_ifindex, pe2, 101, expected) test_func = partial(show_vni_json_elide_ifindex, pe2, 101, expected)
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1) _, result = topotest.run_and_expect(test_func, None, count=45, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(pe2.name) assertmsg = '"{}" JSON output mismatches'.format(pe2.name)
assert result is None, assertmsg assert result is None, assertmsg
# tgen.mininet_cli()
test_func = partial(check_vni_macs_present, tgen, pe2, 101, (
("host1", "host1-eth0"),
("host2", "host2-eth0")
))
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
if result:
logger.warning("%s", result)
assert None, '"{}" missing expected MACs'.format(pe2.name)
def mac_learn_test(host, local): def mac_learn_test(host, local):