From 589e9f8fb7cf20ce69d0705078c66996c7d6567c Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 31 Aug 2021 10:48:04 +0300 Subject: [PATCH] tests: Test if IEEE floating-point encoding for bw works with older format Just check if backward-compatibility works fine between uint32 / IEEE encodings. Signed-off-by: Donatas Abraitis --- tests/topotests/bgp_link_bw_ip/r1/bgpd.conf | 1 + .../bgp_link_bw_ip/r3/bgp-route-1.json | 29 +++++++++++++++++++ tests/topotests/bgp_link_bw_ip/r3/bgpd.conf | 1 + tests/topotests/bgp_link_bw_ip/r6/bgpd.conf | 1 + .../bgp_link_bw_ip/test_bgp_linkbw_ip.py | 14 +++++++++ 5 files changed, 46 insertions(+) create mode 100644 tests/topotests/bgp_link_bw_ip/r3/bgp-route-1.json diff --git a/tests/topotests/bgp_link_bw_ip/r1/bgpd.conf b/tests/topotests/bgp_link_bw_ip/r1/bgpd.conf index 0e46687100..b1ec70d60b 100644 --- a/tests/topotests/bgp_link_bw_ip/r1/bgpd.conf +++ b/tests/topotests/bgp_link_bw_ip/r1/bgpd.conf @@ -8,4 +8,5 @@ router bgp 65101 neighbor 11.1.1.2 timers 3 10 neighbor 11.1.1.6 remote-as external neighbor 11.1.1.6 timers 3 10 + neighbor 11.1.1.6 disable-link-bw-encoding-ieee ! diff --git a/tests/topotests/bgp_link_bw_ip/r3/bgp-route-1.json b/tests/topotests/bgp_link_bw_ip/r3/bgp-route-1.json new file mode 100644 index 0000000000..cddf127b86 --- /dev/null +++ b/tests/topotests/bgp_link_bw_ip/r3/bgp-route-1.json @@ -0,0 +1,29 @@ +{ + "prefix":"198.10.1.1/32", + "paths":[ + { + "aspath":{ + "string":"65303 65354", + "segments":[ + { + "type":"as-sequence", + "list":[ + 65303, + 65354 + ] + } + ], + "length":2 + }, + "valid":true, + "extendedCommunity":{ + "string":"LB:65303:125000 (1.000 Mbps)" + }, + "nexthops":[ + { + "ip":"11.1.3.2" + } + ] + } + ] +} diff --git a/tests/topotests/bgp_link_bw_ip/r3/bgpd.conf b/tests/topotests/bgp_link_bw_ip/r3/bgpd.conf index 3f20eb10a3..cfd394936c 100644 --- a/tests/topotests/bgp_link_bw_ip/r3/bgpd.conf +++ b/tests/topotests/bgp_link_bw_ip/r3/bgpd.conf @@ -8,4 +8,5 @@ router bgp 65202 neighbor 11.1.1.5 timers 3 10 neighbor 11.1.3.2 remote-as external neighbor 11.1.3.2 timers 3 10 + neighbor 11.1.3.2 disable-link-bw-encoding-ieee ! diff --git a/tests/topotests/bgp_link_bw_ip/r6/bgpd.conf b/tests/topotests/bgp_link_bw_ip/r6/bgpd.conf index 18e7eb9285..89de8eeeb5 100644 --- a/tests/topotests/bgp_link_bw_ip/r6/bgpd.conf +++ b/tests/topotests/bgp_link_bw_ip/r6/bgpd.conf @@ -14,6 +14,7 @@ router bgp 65303 no bgp ebgp-requires-policy neighbor 11.1.3.1 remote-as external neighbor 11.1.3.1 timers 3 10 + neighbor 11.1.3.1 disable-link-bw-encoding-ieee neighbor 11.1.6.2 remote-as external neighbor 11.1.6.2 timers 3 10 ! diff --git a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py index 3fcc3bec9a..a9b4b6b031 100644 --- a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py +++ b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py @@ -270,6 +270,7 @@ def test_weighted_ecmp(): r1 = tgen.gears["r1"] r2 = tgen.gears["r2"] + r3 = tgen.gears["r3"] # Configure anycast IP on additional server r9 logger.info("Configure anycast IP on server r9") @@ -304,6 +305,19 @@ def test_weighted_ecmp(): tgen.net["r10"].cmd("ip addr add 198.10.1.1/32 dev r10-eth1") + # Check if bandwidth is properly encoded with non IEEE floatig-point (uint32) format on r3 + logger.info( + "Check if bandwidth is properly encoded with non IEEE floatig-point (uint32) format on r3" + ) + json_file = "{}/r3/bgp-route-1.json".format(CWD) + expected = json.loads(open(json_file).read()) + test_func = partial( + topotest.router_json_cmp, r3, "show bgp ipv4 uni 198.10.1.1/32 json", expected + ) + _, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5) + assertmsg = "JSON output mismatch on r3" + assert result is None, assertmsg + # Check multipath on super-spine router r1 logger.info("Check multipath on super-spine router r1") json_file = "{}/r1/bgp-route-2.json".format(CWD) -- 2.39.5