From bc51ce681068076cdee50e6e5f232a8ba4d8dd4a Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Sun, 18 Jul 2021 18:03:53 +0000 Subject: [PATCH] tests: improve vxlan test determinism Signed-off-by: Christian Hopps --- .../bgp_evpn_vxlan_topo1/PE1/evpn.vni.json | 2 - .../bgp_evpn_vxlan_topo1/PE2/evpn.vni.json | 2 - .../test_bgp_evpn_vxlan.py | 37 ++++++++++++++++--- 3 files changed, 32 insertions(+), 9 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 e500a1d85c..ce7915c4af 100644 --- a/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json +++ b/tests/topotests/bgp_evpn_vxlan_topo1/PE1/evpn.vni.json @@ -6,8 +6,6 @@ "vtepIp":"10.10.10.10", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", - "numMacs":6, - "numArpNd":6, "numRemoteVteps":[ "10.30.30.30" ] 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 0a56a235bd..6c69202642 100644 --- a/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json +++ b/tests/topotests/bgp_evpn_vxlan_topo1/PE2/evpn.vni.json @@ -6,8 +6,6 @@ "vtepIp":"10.30.30.30", "mcastGroup":"0.0.0.0", "advertiseGatewayMacip":"No", - "numMacs":6, - "numArpNd":6, "numRemoteVteps":[ "10.10.10.10" ] 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 fd5bb38b98..763cf9c156 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 @@ -28,6 +28,7 @@ test_bgp_evpn_vxlan.py: Test VXLAN EVPN MAC a route signalling over BGP. import os import sys import json +import re from functools import partial from time import sleep import pytest @@ -156,6 +157,17 @@ def show_vni_json_elide_ifindex(pe, vni, 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(): "Wait for protocol convergence" @@ -169,10 +181,17 @@ def test_pe1_converge_evpn(): expected = json.loads(open(json_file).read()) 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) - 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(): @@ -188,10 +207,18 @@ def test_pe2_converge_evpn(): expected = json.loads(open(json_file).read()) 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) 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): -- 2.39.5