Skip to content

Commit

Permalink
Merge pull request #16348 from opensourcerouting/feature/test_bgp_rem…
Browse files Browse the repository at this point in the history
…ote_as_unnumberred

tests: Extended bgp_remote_as_auto topotest with unnumbered case
  • Loading branch information
riw777 authored Jul 9, 2024
2 parents 893ba83 + cd9bb4d commit f13f3cc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r1/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
int r1-eth0
ip address 192.168.1.1/24
!
int r1-eth1
ip address 192.168.14.1/24
!
router bgp 65001
no bgp ebgp-requires-policy
no bgp network import-check
Expand All @@ -11,6 +14,9 @@ router bgp 65001
neighbor 192.168.1.3 remote-as auto
neighbor 192.168.1.3 timers 1 3
neighbor 192.168.1.3 timers connect 1
neighbor r1-eth1 interface remote-as auto
neighbor r1-eth1 timers 1 3
neighbor r1-eth1 timers connect 1
address-family ipv4 unicast
network 10.0.0.1/32
exit-address-family
Expand Down
10 changes: 10 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r4/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!
int r4-eth0
ip address 192.168.14.4/24
!
router bgp 65004
no bgp ebgp-requires-policy
neighbor r4-eth0 interface remote-as auto
neighbor r4-eth0 timers 1 3
neighbor r4-eth0 timers connect 1
!
33 changes: 32 additions & 1 deletion tests/topotests/bgp_remote_as_auto/test_bgp_remote_as_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def setup_module(mod):
topodef = {"s1": ("r1", "r2", "r3")}
topodef = {"s1": ("r1", "r2", "r3"), "s2": ("r1", "r4")}
tgen = Topogen(topodef, mod.__name__)
tgen.start_topology()

Expand All @@ -49,11 +49,18 @@ def test_bgp_remote_as_auto():
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
r3 = tgen.gears["r3"]
r4 = tgen.gears["r4"]

def _bgp_converge():
output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast summary json"))
expected = {
"peers": {
"r1-eth1": {
"hostname": "r4",
"remoteAs": 65004,
"localAs": 65001,
"state": "Established",
},
"192.168.1.2": {
"hostname": "r2",
"remoteAs": 65001,
Expand Down Expand Up @@ -124,6 +131,30 @@ def _bgp_converge_external():
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Can't see automatic eBGP peering"

def _bgp_converge_external_unnumbered():
output = json.loads(r4.vtysh_cmd("show bgp ipv4 unicast 10.0.0.1/32 json"))
expected = {
"paths": [
{
"aspath": {
"string": "65001",
},
"valid": True,
"peer": {
"hostname": "r1",
"type": "external",
},
}
]
}
return topotest.json_cmp(output, expected)

test_func = functools.partial(
_bgp_converge_external_unnumbered,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Can't see automatic unnumbered eBGP peering"


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
Expand Down

0 comments on commit f13f3cc

Please sign in to comment.