Skip to content

Commit

Permalink
tests: Check if GR settings are inherited for peer-groups
Browse files Browse the repository at this point in the history
Convert to unified config also.

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Nov 25, 2024
1 parent ee5893f commit a4bfa8c
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 63 deletions.
12 changes: 0 additions & 12 deletions tests/topotests/bgp_peer_group/r1/bgpd.conf

This file was deleted.

21 changes: 21 additions & 0 deletions tests/topotests/bgp_peer_group/r1/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
!
interface r1-eth0
ip address 192.168.255.1/24
!
interface r1-eth1
ip address 192.168.251.1/30
!
ip forwarding
!
router bgp 65001
neighbor PG peer-group
neighbor PG remote-as external
neighbor PG timers 3 10
neighbor 192.168.255.3 peer-group PG
neighbor r1-eth0 interface peer-group PG
neighbor PG1 peer-group
neighbor PG1 remote-as external
neighbor PG1 timers 3 20
neighbor PG1 graceful-restart-disable
neighbor 192.168.251.2 peer-group PG1
!
9 changes: 0 additions & 9 deletions tests/topotests/bgp_peer_group/r1/zebra.conf

This file was deleted.

11 changes: 0 additions & 11 deletions tests/topotests/bgp_peer_group/r2/bgpd.conf

This file was deleted.

19 changes: 19 additions & 0 deletions tests/topotests/bgp_peer_group/r2/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!
interface r2-eth0
ip address 192.168.255.2/24
!
interface r2-eth1
ip address 192.168.251.2/30
!
ip forwarding
!
router bgp 65002
neighbor PG peer-group
neighbor PG remote-as external
neighbor PG timers 3 10
neighbor r2-eth0 interface peer-group PG
neighbor PG1 peer-group
neighbor PG1 remote-as external
neighbor PG1 timers 3 20
neighbor 192.168.251.1 peer-group PG1
!
9 changes: 0 additions & 9 deletions tests/topotests/bgp_peer_group/r2/zebra.conf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
!
interface r3-eth0
ip address 192.168.255.3/24
!
ip forwarding
!
router bgp 65003
no bgp ebgp-requires-policy
neighbor PG peer-group
Expand Down
6 changes: 0 additions & 6 deletions tests/topotests/bgp_peer_group/r3/zebra.conf

This file was deleted.

41 changes: 25 additions & 16 deletions tests/topotests/bgp_peer_group/test_bgp_peer-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
# SPDX-License-Identifier: ISC

#
# Copyright (c) 2021 by
# Copyright (c) 2021-2024 by
# Donatas Abraitis <[email protected]>
# Donatas Abraitis <[email protected]>
#

"""
Test if peer-group works for numbered and unnumbered configurations.
Test if various random settings with peer-group works for
numbered and unnumbered configurations.
"""

import os
Expand All @@ -21,7 +23,7 @@

# pylint: disable=C0413
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topogen import Topogen, get_topogen
from lib.topolog import logger

pytestmark = [pytest.mark.bgpd]
Expand All @@ -48,12 +50,7 @@ def setup_module(mod):
router_list = tgen.routers()

for _, (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))
)
router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))

tgen.start_router()

Expand All @@ -72,14 +69,26 @@ def test_bgp_peer_group():
def _bgp_peer_group_configured():
output = json.loads(tgen.gears["r1"].vtysh_cmd("show ip bgp neighbor json"))
expected = {
"r1-eth0": {"peerGroup": "PG", "bgpState": "Established"},
"192.168.255.3": {"peerGroup": "PG", "bgpState": "Established"},
"192.168.251.2": {"peerGroup": "PG1", "bgpState": "Established"},
"r1-eth0": {
"peerGroup": "PG",
"bgpState": "Established",
"neighborCapabilities": {"gracefulRestart": "advertisedAndReceived"},
},
"192.168.255.3": {
"peerGroup": "PG",
"bgpState": "Established",
"neighborCapabilities": {"gracefulRestart": "advertisedAndReceived"},
},
"192.168.251.2": {
"peerGroup": "PG1",
"bgpState": "Established",
"neighborCapabilities": {"gracefulRestart": "received"},
},
}
return topotest.json_cmp(output, expected)

test_func = functools.partial(_bgp_peer_group_configured)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"

def _bgp_peer_group_check_advertised_routes():
Expand All @@ -97,7 +106,7 @@ def _bgp_peer_group_check_advertised_routes():
return topotest.json_cmp(output, expected)

test_func = functools.partial(_bgp_peer_group_check_advertised_routes)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed checking advertised routes from r3"


Expand All @@ -122,7 +131,7 @@ def _bgp_peer_group_remoteas_del():
return topotest.json_cmp(output, expected)

test_func = functools.partial(_bgp_peer_group_remoteas_del)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"

logger.info("Re-add bgp peer-group PG1 remote-as neighbor should be established")
Expand All @@ -139,7 +148,7 @@ def _bgp_peer_group_remoteas_add():
return topotest.json_cmp(output, expected)

test_func = functools.partial(_bgp_peer_group_remoteas_add)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Failed bgp convergence in r1"


Expand Down

0 comments on commit a4bfa8c

Please sign in to comment.