summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2022-12-07 14:03:59 +0100
committerGitHub <noreply@github.com>2022-12-07 14:03:59 +0100
commit1b97fa99769bf75752dc1cd898794e82ad11ece8 (patch)
tree2efa77d6c6e7ced676fb04f98f5699443698cdf2 /tests
parentMerge pull request #12339 from anlancs/fix/bgpd-null-show (diff)
parentbgpd: Adopt addpath functionality for labeled-unicast (diff)
downloadfrr-1b97fa99769bf75752dc1cd898794e82ad11ece8.tar.xz
frr-1b97fa99769bf75752dc1cd898794e82ad11ece8.zip
Merge pull request #12456 from opensourcerouting/fix/bgpd_labeled_unicast_rr_addpath
bgpd: Labeled unicast fixes for addpath capability
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/__init__.py0
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r1/bgpd.conf14
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r1/zebra.conf7
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r2/bgpd.conf14
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r2/zebra.conf7
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r3/bgpd.conf30
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r3/zebra.conf10
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r4/bgpd.conf10
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/r4/zebra.conf4
-rw-r--r--tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py142
10 files changed, 238 insertions, 0 deletions
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/__init__.py b/tests/topotests/bgp_labeled_unicast_addpath/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/__init__.py
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r1/bgpd.conf b/tests/topotests/bgp_labeled_unicast_addpath/r1/bgpd.conf
new file mode 100644
index 000000000..ae3812ab9
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r1/bgpd.conf
@@ -0,0 +1,14 @@
+router bgp 65001
+ no bgp ebgp-requires-policy
+ no bgp default ipv4-unicast
+ neighbor 192.168.31.3 remote-as external
+ neighbor 192.168.31.3 timers 1 3
+ neighbor 192.168.31.3 timers connect 1
+ address-family ipv4 unicast
+ redistribute connected
+ exit-address-family
+ !
+ address-family ipv4 labeled-unicast
+ neighbor 192.168.31.3 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r1/zebra.conf b/tests/topotests/bgp_labeled_unicast_addpath/r1/zebra.conf
new file mode 100644
index 000000000..fbaccdafd
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r1/zebra.conf
@@ -0,0 +1,7 @@
+!
+interface lo
+ ip address 10.0.0.1/32
+!
+interface r1-eth0
+ ip address 192.168.31.1/24
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r2/bgpd.conf b/tests/topotests/bgp_labeled_unicast_addpath/r2/bgpd.conf
new file mode 100644
index 000000000..16dc1f3e4
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r2/bgpd.conf
@@ -0,0 +1,14 @@
+router bgp 65002
+ no bgp ebgp-requires-policy
+ no bgp default ipv4-unicast
+ neighbor 192.168.32.3 remote-as external
+ neighbor 192.168.32.3 timers 1 3
+ neighbor 192.168.32.3 timers connect 1
+ address-family ipv4 unicast
+ redistribute connected
+ exit-address-family
+ !
+ address-family ipv4 labeled-unicast
+ neighbor 192.168.32.3 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r2/zebra.conf b/tests/topotests/bgp_labeled_unicast_addpath/r2/zebra.conf
new file mode 100644
index 000000000..8118d56a1
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r2/zebra.conf
@@ -0,0 +1,7 @@
+!
+interface lo
+ ip address 10.0.0.1/32
+!
+interface r2-eth0
+ ip address 192.168.32.2/24
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r3/bgpd.conf b/tests/topotests/bgp_labeled_unicast_addpath/r3/bgpd.conf
new file mode 100644
index 000000000..c38ed7ef6
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r3/bgpd.conf
@@ -0,0 +1,30 @@
+!
+router bgp 65003
+ no bgp default ipv4-unicast
+ no bgp ebgp-requires-policy
+ no bgp suppress-duplicates
+ bgp bestpath as-path multipath-relax
+ neighbor 192.168.31.1 remote-as external
+ neighbor 192.168.31.1 timers 1 3
+ neighbor 192.168.31.1 timers connect 1
+ neighbor 192.168.32.2 remote-as external
+ neighbor 192.168.32.2 timers 1 3
+ neighbor 192.168.32.2 timers connect 1
+ neighbor 192.168.34.4 remote-as external
+ neighbor 192.168.34.4 timers 1 3
+ neighbor 192.168.34.4 timers connect 1
+ address-family ipv4 labeled-unicast
+ neighbor 192.168.31.1 activate
+ neighbor 192.168.32.2 activate
+ neighbor 192.168.34.4 activate
+ neighbor 192.168.34.4 route-map r4 out
+ neighbor 192.168.34.4 addpath-tx-all-paths
+ exit-address-family
+ !
+!
+ip prefix-list r4 seq 5 permit 10.0.0.1/32
+!
+route-map r4 permit 10
+ match ip address prefix-list r4
+exit
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r3/zebra.conf b/tests/topotests/bgp_labeled_unicast_addpath/r3/zebra.conf
new file mode 100644
index 000000000..1cc2ca2ed
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r3/zebra.conf
@@ -0,0 +1,10 @@
+!
+interface r3-eth0
+ ip address 192.168.31.3/24
+!
+interface r3-eth1
+ ip address 192.168.32.3/24
+!
+interface r3-eth2
+ ip address 192.168.34.3/24
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r4/bgpd.conf b/tests/topotests/bgp_labeled_unicast_addpath/r4/bgpd.conf
new file mode 100644
index 000000000..e137156b7
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r4/bgpd.conf
@@ -0,0 +1,10 @@
+router bgp 65004
+ no bgp ebgp-requires-policy
+ no bgp default ipv4-unicast
+ neighbor 192.168.34.3 remote-as external
+ neighbor 192.168.34.3 timers 1 3
+ neighbor 192.168.34.3 timers connect 1
+ address-family ipv4 labeled-unicast
+ neighbor 192.168.34.3 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/r4/zebra.conf b/tests/topotests/bgp_labeled_unicast_addpath/r4/zebra.conf
new file mode 100644
index 000000000..2ec426a51
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/r4/zebra.conf
@@ -0,0 +1,4 @@
+!
+interface r4-eth0
+ ip address 192.168.34.4/24
+!
diff --git a/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py b/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py
new file mode 100644
index 000000000..9e7dd403f
--- /dev/null
+++ b/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+
+#
+# Copyright (c) 2022 by
+# Donatas Abraitis <donatas@opensourcerouting.org>
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+"""
+Check if labeled-unicast works correctly with addpath capability.
+"""
+
+import os
+import sys
+import json
+import pytest
+import functools
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+# pylint: disable=C0413
+from lib import topotest
+from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.common_config import step
+
+pytestmark = [pytest.mark.bgpd]
+
+
+def build_topo(tgen):
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
+
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
+
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
+
+
+def setup_module(mod):
+ tgen = Topogen(build_topo, mod.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+
+ for i, (rname, router) in enumerate(router_list.items(), 1):
+ router.load_config(
+ TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
+ )
+ router.load_config(
+ TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
+ )
+
+ tgen.start_router()
+
+
+def teardown_module(mod):
+ tgen = get_topogen()
+ tgen.stop_topology()
+
+
+def test_bgp_addpath_labeled_unicast():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r3 = tgen.gears["r3"]
+ r4 = tgen.gears["r4"]
+
+ def _bgp_check_advertised_routes():
+ output = json.loads(
+ r3.vtysh_cmd(
+ "show bgp ipv4 labeled-unicast neighbors 192.168.34.4 advertised-routes json"
+ )
+ )
+ expected = {
+ "advertisedRoutes": {
+ "10.0.0.1/32": {
+ "appliedStatusSymbols": {
+ "*": True,
+ ">": True,
+ "=": True,
+ }
+ }
+ },
+ "totalPrefixCounter": 2,
+ }
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(_bgp_check_advertised_routes)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert (
+ result is None
+ ), "Failed to advertise labeled-unicast with addpath (multipath)"
+
+ def _bgp_check_received_routes():
+ output = json.loads(r4.vtysh_cmd("show bgp ipv4 labeled-unicast json"))
+ expected = {
+ "routes": {
+ "10.0.0.1/32": [
+ {
+ "valid": True,
+ "path": "65003 65001",
+ },
+ {
+ "valid": True,
+ "path": "65003 65002",
+ },
+ ]
+ }
+ }
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(_bgp_check_received_routes)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "Failed to receive labeled-unicast with addpath (multipath)"
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))