Merge pull request #16348 from opensourcerouting/feature/test_bgp_remote_as_unnumberred

tests: Extended bgp_remote_as_auto topotest with unnumbered case
This commit is contained in:
Russ White 2024-07-08 23:15:04 -04:00 committed by GitHub
commit f13f3cc76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 1 deletions

View File

@ -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
@ -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

View File

@ -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
!

View File

@ -23,7 +23,7 @@ pytestmark = [pytest.mark.bgpd]
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()
@ -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,
@ -124,6 +131,30 @@ def test_bgp_remote_as_auto():
_, 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:]