Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions netsim/validate/bgp/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,57 @@ def valid_bgp_neighbor(

return f'Neighbor {n_addr} ({n_id}) is in state {data[n_addr].peerState}'

def show_bgp_neighbor_details(ngb: list, n_id: str, af: str='ipv4', *, activate: str = '', bfd: bool = False, **kwargs: typing.Any) -> str:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to specify BFD parameter in the "show" call which only generates the command to execute. kwargs will take care of that.

n_addr = _common.get_bgp_neighbor_id(ngb,n_id,af)
global af_lookup
if not activate:
return f'bgp neighbors {n_addr} | json'

if activate not in af_lookup:
raise Exception(f'Unsupported address family {activate}')

return f'bgp {af_lookup[activate]} neighbors {n_addr} | json'

def valid_bgp_neighbor_details(
ngb: list,
n_id: str,
af: str = 'ipv4',
state: str = 'Established',
vrf: str = 'default',
activate: str = '',
intf: str = '',
bfd: bool = False) -> str:
_result = global_vars.get_result_dict('_result')
n_addr = _common.get_bgp_neighbor_id(ngb,n_id,af)

data = check_vrf_data(_result,vrf,'peerList','BGP peers')

act_err = f' in address family {activate}' if activate else ''
found = next(item for item in data if item.peerAddress == n_addr)

if not found:
result = f'The router has no BGP neighbor with {af} address {n_addr} ({n_id}){act_err}'
if state == 'missing':
return result
else:
raise Exception(result)

if not state == found.state:
result = f'The neighbor {n_addr} ({n_id}){act_err} is in state {found.state}'
if state == 'missing' and data[0].state != 'Established':
return result
else:
raise Exception(f'{result} (expected {state})')

if not bfd:
return result

result = f'The neighbor {n_addr} ({n_id}){act_err} is in BFD state {found.bfdState}'
if not found.bfdState == 3:
raise Exception(f'{result} ( expected 3 - Up )')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no need for spaces within brackets ;)


return result

"""
BGP prefix checks, starting with 'get a BGP prefix from JSON results'
"""
Expand Down
13 changes: 11 additions & 2 deletions netsim/validate/bgp/frr.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ def valid_bgp_neighbor(

return f'Neighbor {n_addr} ({n_id}) is in state {data[n_addr].state}'

def show_bgp_neighbor_details(ngb: list, n_id: str, af: str = 'ipv4', **kwargs: typing.Any) -> str:
def show_bgp_neighbor_details(ngb: list, n_id: str, af: str = 'ipv4', bfd: bool = False, **kwargs: typing.Any) -> str:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, no need for bfd parameter; kwargs will take it.

n_addr = _common.get_bgp_neighbor_id(ngb,n_id,af)
return f'bgp neighbor {n_addr} json'

def valid_bgp_neighbor_details(
ngb: list,
n_id: str,
af: str = 'ipv4',**kwargs: typing.Any) -> str:
af: str = 'ipv4',
bfd: bool = False,
**kwargs: typing.Any) -> str:
_result = global_vars.get_result_dict('_result')

n_addr = _common.get_bgp_neighbor_id(ngb,n_id,af)
Expand All @@ -101,6 +103,13 @@ def valid_bgp_neighbor_details(
if data[k] != v:
raise Exception(f'{k} expected value {v} actual {data[k]}')

if bfd:
if data.peerBfdInfo:
if data.peerBfdInfo.status != "Up":
raise Exception(f'{k} expected value UP actual {data.peerBfdInfo.status}')
else:
raise Exception(f'Neighbor data structure does not contain attribute peerBfdInfo')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reword this along the lines of "No BFD information for BGP peer {n_id}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted


return f'All specified BGP neighbor parameters have the expected values'

"""
Expand Down
30 changes: 27 additions & 3 deletions tests/integration/bgp.session/13-bfd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ defaults.sources.extra: [ ../wait_times.yml, ../warnings.yml ]

groups:
probes:
device: eos
device: frr

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need EOS here. See below...

provider: clab
members: [ x1 ]

nodes:
dut:
bgp.as: 65000
bgp.bfd: True

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong. You see, the point is that DUT runs BFD with one peer but not the other.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is only 1 peer in the bgp.session version of this BFD test topology currently...

x1:
bgp.as: 65100
config: [ static_bfd ]
bgp.bfd: True

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the reason for this tweak (we could easily configure BFD on X1) is to ensure that X1 is willing to run BFD with DUT (it has a BFD neighbor configured), but will not try to initiate it (so we know DUT has to actively run BFD for BGP neighbors).


links:
- dut:
bgp.bfd: True
x1:
pool: p2p # Force addressing to come from the p2p pool, else with host devices like bird it becomes a lan

Expand All @@ -34,13 +34,37 @@ validate:
nodes: [ x1 ]
plugin: bgp_neighbor(node.bgp.neighbors,'dut')

bgp_bfd_v4:
description: Check IPv4 EBGP sessions with DUT
wait_msg: Waiting for BFD EBGP session data
wait: ebgp_session
nodes: [ x1 ]
plugin: bgp_neighbor_details(node.bgp.neighbors,'dut',bfd='True')

bfd_v4:
description: Check BFD peer on X1
wait_msg: Waiting for BFD to start
wait: bfd_init
nodes: [ x1 ]
show:
eos: "bfd peers | json"
frr: "bfd peers json"
valid:
eos: >-
vrfs.default.ipv4Neighbors["10.1.0.1"].peers.Ethernet1.types.normal.peerStats["10.1.0.2"].status == "up"
frr: >-
result[0].status == "up"

bfd_v4_dut:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot check anything on the tested device. It can be any one of the 20 or so platforms we support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems, the test from the DUT was left over, as i wanted to test both at once rather than having re up/down the environment to swap.

description: Check BFD peer on DUT
wait_msg: Waiting for BFD to start
wait: bfd_init
nodes: [ dut ]
show:
eos: "bfd peers | json"
frr: "bfd peers json"
valid:
eos: >-
vrfs.default.ipv4Neighbors["10.1.0.2"].peers.Ethernet1.types.normal.peerStats["10.1.0.1"].status == "up"
frr: >-
result[0].status == "up"