From dcf133fdf6c4e0e33481cac9a2055f4c44bac912 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 4 Aug 2023 22:34:17 +0300 Subject: [PATCH 1/2] tests: Improve bgp_addpath_best_selected topotest Test everything else only after we have an initial good state. Signed-off-by: Donatas Abraitis --- .../test_bgp_addpath_best_selected.py | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/topotests/bgp_addpath_best_selected/test_bgp_addpath_best_selected.py b/tests/topotests/bgp_addpath_best_selected/test_bgp_addpath_best_selected.py index dfd538f1c6..2a610c901e 100644 --- a/tests/topotests/bgp_addpath_best_selected/test_bgp_addpath_best_selected.py +++ b/tests/topotests/bgp_addpath_best_selected/test_bgp_addpath_best_selected.py @@ -75,6 +75,42 @@ def test_bgp_addpath_best_selected(): r2 = tgen.gears["r2"] + def _bgp_converge(): + output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast 172.16.16.254/32 json")) + expected = { + "paths": [ + { + "aspath": { + "string": "65006", + }, + "weight": 6, + }, + { + "aspath": { + "string": "65005", + }, + "weight": 5, + }, + { + "aspath": { + "string": "65004", + }, + "weight": 4, + }, + { + "aspath": { + "string": "65003", + }, + "weight": 3, + }, + ] + } + return topotest.json_cmp(output, expected) + + test_func = functools.partial(_bgp_converge) + _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) + assert result is None, "Can't converge initially" + def check_bgp_advertised_routes_to_r1(): output = json.loads( r2.vtysh_cmd( @@ -104,7 +140,7 @@ def test_bgp_addpath_best_selected(): return topotest.json_cmp(output, expected) test_func = functools.partial(check_bgp_advertised_routes_to_r1) - success, result = topotest.run_and_expect(test_func, None, count=30, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assert ( result is None ), "Received more/less Add-Path best paths, but should be only 1+1 (real best path)" @@ -143,7 +179,7 @@ def test_bgp_addpath_best_selected(): return topotest.json_cmp(output, expected) test_func = functools.partial(check_bgp_advertised_routes_to_r7) - success, result = topotest.run_and_expect(test_func, None, count=30, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=30, wait=1) assert ( result is None ), "Received more/less Add-Path best paths, but should be only 2+1 (real best path)" From 0ba5225b92dd6cc3ec65caa8cc1126623d4dcf6e Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 4 Aug 2023 23:22:38 +0300 Subject: [PATCH 2/2] tests: Drop duplicate neighbor definition Signed-off-by: Donatas Abraitis --- tests/topotests/bgp_addpath_best_selected/r2/bgpd.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/topotests/bgp_addpath_best_selected/r2/bgpd.conf b/tests/topotests/bgp_addpath_best_selected/r2/bgpd.conf index 0c13824323..cdef611286 100644 --- a/tests/topotests/bgp_addpath_best_selected/r2/bgpd.conf +++ b/tests/topotests/bgp_addpath_best_selected/r2/bgpd.conf @@ -2,7 +2,6 @@ router bgp 65002 timers bgp 3 10 no bgp ebgp-requires-policy neighbor 192.168.1.1 remote-as external - neighbor 192.168.1.1 remote-as external neighbor 192.168.7.7 remote-as external neighbor 192.168.7.7 timers connect 5 neighbor 192.168.2.3 remote-as external