Skip to content

Commit

Permalink
tests: Check if pfxSnt is adjusted when default-originate is used for…
Browse files Browse the repository at this point in the history
… BGP

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Jul 14, 2021
1 parent fea96c5 commit 5fa869f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 0 additions & 3 deletions tests/topotests/bgp_default_route/r2/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ router bgp 65001
no bgp ebgp-requires-policy
neighbor 192.168.255.1 remote-as 65000
neighbor 192.168.255.1 timers 3 10
address-family ipv4 unicast
redistribute connected
exit-address-family
!
27 changes: 16 additions & 11 deletions tests/topotests/bgp_default_route/test_bgp_default-originate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def test_bgp_default_originate_route_map():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

router = tgen.gears["r2"]

def _bgp_converge(router):
output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
def _bgp_check_if_received():
output = json.loads(
tgen.gears["r2"].vtysh_cmd("show ip bgp neighbor 192.168.255.1 json")
)
expected = {
"192.168.255.1": {
"bgpState": "Established",
Expand All @@ -91,22 +91,27 @@ def _bgp_converge(router):
}
return topotest.json_cmp(output, expected)

def _bgp_check_if_originated():
output = json.loads(tgen.gears["r1"].vtysh_cmd("show ip bgp summary json"))
expected = {"ipv4Unicast": {"peers": {"192.168.255.2": {"pfxSnt": 1}}}}
return topotest.json_cmp(output, expected)

def _bgp_default_route_is_valid(router):
output = json.loads(router.vtysh_cmd("show ip bgp 0.0.0.0/0 json"))
expected = {"paths": [{"valid": True}]}
return topotest.json_cmp(output, expected)

test_func = functools.partial(_bgp_converge, router)
test_func = functools.partial(_bgp_check_if_received)
success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
assert result is None, "No 0.0.0.0/0 at r2 from r1"

assert result is None, 'Failed to see bgp convergence in "{}"'.format(router)

test_func = functools.partial(_bgp_default_route_is_valid, router)
test_func = functools.partial(_bgp_check_if_originated)
success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
assert result is None, "No 0.0.0.0/0 from r1 to r2"

assert (
result is None
), 'Failed to see applied metric for default route in "{}"'.format(router)
test_func = functools.partial(_bgp_default_route_is_valid, tgen.gears["r2"])
success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
assert result is None, "Failed to see 0.0.0.0/0 in r2"


if __name__ == "__main__":
Expand Down

0 comments on commit 5fa869f

Please sign in to comment.