summaryrefslogtreecommitdiff
path: root/tests/topotests/bgp_vpnv4_noretain
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2023-01-23 18:03:58 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2023-01-24 10:20:19 +0100
commit6c13bd57440bc06b1a083209ce2af04054f12765 (patch)
treea3f1c01b8dabcc4819d965dc9d4f5f7043c4e9d6 /tests/topotests/bgp_vpnv4_noretain
parentde2e2d5ef09477ff03c17c18eeb1b2cb8da80f84 (diff)
topotests: fix bgp_vpnv4_noretain
Fix the following issues: - two tests are done in one function. Dispatch the tests in two functions to help the test debug. - the first test passes even if a third prefix is not filtered. Match the exact to avoid false positive. - the expected values contains variable like version. Do no check variable values. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'tests/topotests/bgp_vpnv4_noretain')
-rw-r--r--tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json5
-rw-r--r--tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json7
-rw-r--r--tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py49
3 files changed, 39 insertions, 22 deletions
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json
index 903c4603c5..28e153e3de 100644
--- a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json
+++ b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes.json
@@ -1,7 +1,6 @@
{
"vrfId":0,
"vrfName":"default",
- "tableVersion":1,
"routerId":"1.1.1.1",
"defaultLocPrf":100,
"localAS":65500,
@@ -17,7 +16,6 @@
"prefix":"10.201.0.0",
"prefixLen":24,
"network":"10.201.0.0\/24",
- "version":1,
"metric":0,
"weight":32768,
"peerId":"(unspec)",
@@ -28,6 +26,7 @@
"nexthops":[
{
"ip":"0.0.0.0",
+ "hostname":"r1",
"afi":"ipv4",
"used":true
}
@@ -45,7 +44,6 @@
"prefix":"10.200.0.0",
"prefixLen":24,
"network":"10.200.0.0\/24",
- "version":1,
"metric":0,
"locPrf":100,
"weight":0,
@@ -55,6 +53,7 @@
"nexthops":[
{
"ip":"10.125.0.2",
+ "hostname":"r2",
"afi":"ipv4",
"used":true
}
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json
index 3cc0b4a5f5..45f4acce6f 100644
--- a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json
+++ b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_unfiltered.json
@@ -1,7 +1,6 @@
{
"vrfId":0,
"vrfName":"default",
- "tableVersion":1,
"routerId":"1.1.1.1",
"defaultLocPrf":100,
"localAS":65500,
@@ -17,7 +16,6 @@
"prefix":"10.201.0.0",
"prefixLen":24,
"network":"10.201.0.0\/24",
- "version":1,
"metric":0,
"weight":32768,
"peerId":"(unspec)",
@@ -28,6 +26,7 @@
"nexthops":[
{
"ip":"0.0.0.0",
+ "hostname":"r1",
"afi":"ipv4",
"used":true
}
@@ -45,7 +44,6 @@
"prefix":"10.200.0.0",
"prefixLen":24,
"network":"10.200.0.0\/24",
- "version":1,
"metric":0,
"locPrf":100,
"weight":0,
@@ -55,6 +53,7 @@
"nexthops":[
{
"ip":"10.125.0.2",
+ "hostname":"r2",
"afi":"ipv4",
"used":true
}
@@ -72,7 +71,6 @@
"prefix":"10.210.0.0",
"prefixLen":24,
"network":"10.210.0.0\/24",
- "version":1,
"metric":0,
"locPrf":100,
"weight":0,
@@ -82,6 +80,7 @@
"nexthops":[
{
"ip":"10.125.0.2",
+ "hostname":"r2",
"afi":"ipv4",
"used":true
}
diff --git a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
index b4a841d9cf..ed5cc3faf6 100644
--- a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
+++ b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
@@ -133,27 +133,37 @@ def teardown_module(_mod):
tgen.stop_topology()
-def test_protocols_convergence():
+def router_json_cmp_exact_filter(router, cmd, expected):
+ # filter out tableVersion, version and nhVrfID
+ output = router.cmd('vtysh -c "{}" | grep -v ersion | grep -v nhVrfId'.format(cmd))
+ logger.info("{}: {}\n{}".format(router.name, cmd, output))
+
+ json_output = json.loads(output)
+
+ return topotest.json_cmp(json_output, expected, exact=True)
+
+
+def test_bgp_no_retain():
"""
- Assert that all protocols have converged
- statuses as they depend on it.
+ Check bgp no retain route-target all on r1
"""
+
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Check IPv4 VPN routing tables on r1
- logger.info("Checking IPv4 routes for convergence on r1")
- router = tgen.gears['r1']
+ logger.info("Checking VPNv4 routes for convergence on r1")
+ router = tgen.gears["r1"]
json_file = "{}/{}/ipv4_vpn_routes.json".format(CWD, router.name)
if not os.path.isfile(json_file):
logger.info("skipping file {}".format(json_file))
- assert 0, 'ipv4_vpn_routes.json file not found'
+ assert 0, "{} file not found".format(json_file)
return
expected = json.loads(open(json_file).read())
test_func = partial(
- topotest.router_json_cmp,
+ router_json_cmp_exact_filter,
router,
"show bgp ipv4 vpn json",
expected,
@@ -162,23 +172,31 @@ def test_protocols_convergence():
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
- # Check BGP IPv4 routing tables after unsetting no retain flag
- logger.info("Checking BGP IPv4 routes for convergence on r2")
- router = tgen.gears['r1']
- router.vtysh_cmd("configure\nrouter bgp 65500\naddress-family ipv4 vpn\nbgp retain route-target all\n")
+
+def test_bgp_retain():
+ """
+ Apply and check bgp retain route-target all on r1
+ """
+
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
# Check IPv4 VPN routing tables on r1
- logger.info("Checking IPv4 routes for convergence on r1")
- router = tgen.gears['r1']
+ logger.info("Checking VPNv4 routes on r1 after bgp no retain")
+ router = tgen.gears["r1"]
+ router.vtysh_cmd(
+ "configure\nrouter bgp 65500\naddress-family ipv4 vpn\nbgp retain route-target all\n"
+ )
json_file = "{}/{}/ipv4_vpn_routes_unfiltered.json".format(CWD, router.name)
if not os.path.isfile(json_file):
logger.info("skipping file {}".format(json_file))
- assert 0, 'ipv4_vpn_routes_unfiltered.json file not found'
+ assert 0, "{} file not found".format(json_file)
return
expected = json.loads(open(json_file).read())
test_func = partial(
- topotest.router_json_cmp,
+ router_json_cmp_exact_filter,
router,
"show bgp ipv4 vpn json",
expected,
@@ -187,6 +205,7 @@ def test_protocols_convergence():
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
+
def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()