Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 12 additions & 5 deletions netsim/validate/ospf/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_ospf_neighbor_data(data: Box, *, id: str, proto: str, vrf: str = 'defaul
ngb_list = [ ngb for ngb in ngb_list if ngb.routerId == id ]
return ngb_list

def show_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default') -> str:
def show_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default', bfd: bool = False) -> str:
try:
ipaddress.IPv4Address(id)
except:
Expand All @@ -41,7 +41,8 @@ def valid_ospf_neighbor(
present: bool = True,
vrf: str = 'default',*,
proto: str='ospf',
proto_name: str = 'OSPFv2') -> bool:
proto_name: str = 'OSPFv2',
bfd: bool = False) -> bool:
_result = global_vars.get_result_dict('_result')
ngb_list = get_ospf_neighbor_data(_result,id=id,proto=proto,vrf=vrf)

Expand All @@ -54,9 +55,15 @@ def valid_ospf_neighbor(
if not present:
raise Exception(f'Unexpected {proto_name} neighbor {id} in state {n_state.adjacencyState}')

_common.report_state(
exit_msg=f'{proto_name} neighbor {id} is in state {n_state.adjacencyState}',
OK=n_state.adjacencyState.startswith('full'))
exit_msg = f'{proto_name} neighbor {id} is in state {n_state.adjacencyState}'
if not n_state.adjacencyState.startswith('full'):
raise Exception(exit_msg)

if not bfd:
raise log.Result(exit_msg)

exit_msg = f'{proto_name} neighbor {id} is in BFD state {n_state.details.bfdState}'
_common.report_state(exit_msg,n_state.details.bfdState == "up")

def show_ospf6_neighbor(id: str, present: bool = True, vrf: str = 'default', **kwargs: typing.Any) -> str:
try:
Expand Down
28 changes: 21 additions & 7 deletions netsim/validate/ospf/frr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from . import OSPF_PREFIX_NAMES


def show_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default') -> str:
def show_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default', bfd: bool = False) -> str:
try:
ipaddress.IPv4Address(id)
except Exception as exc:
raise Exception(f'OSPF router ID {id} is not a valid IPv4 address') from exc
return f'ip ospf vrf {vrf} neighbor {id} json'
return f'ip ospf vrf {vrf} neighbor {id} detail json'

def valid_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default') -> bool:
def valid_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default', bfd: bool = False) -> bool:
_result = global_vars.get_result_dict('_result')

if vrf in _result:
Expand All @@ -36,20 +36,29 @@ def valid_ospf_neighbor(id: str, present: bool = True, vrf: str = 'default') ->
if not present:
raise Exception(f'Unexpected OSPFv2 neighbor {id} in state {n_state.nbrState}')


exit_msg = f'OSPFv2 neighbor {id} is in state {n_state.nbrState}'
if not n_state.nbrState.startswith('Full'):
raise Exception(exit_msg)
else:

if not bfd:
raise log.Result(exit_msg)

exit_msg = f'OSPFv2 neighbor {id} is in BFD state {n_state.peerBfdInfo.status}'
if not n_state.peerBfdInfo.status == "Up":
raise Exception(exit_msg)

raise log.Result(exit_msg)


def show_ospf6_neighbor(id: str, present: bool = True, vrf: str = 'default', **kwargs: typing.Any) -> str:
try:
ipaddress.IPv4Address(id)
except Exception as exc:
raise Exception(f'OSPF router ID {id} is not a valid IPv4 address') from exc
return f'ipv6 ospf6 vrf {vrf} neighbor {id} json'

def valid_ospf6_neighbor(id: str, present: bool = True, vrf: str = 'default') -> bool:
def valid_ospf6_neighbor(id: str, present: bool = True, vrf: str = 'default', bfd: bool = False) -> bool:
_result = global_vars.get_result_dict('_result')
vrf_name = '' if vrf == 'default' else f' in VRF {vrf}'

Expand All @@ -68,10 +77,15 @@ def valid_ospf6_neighbor(id: str, present: bool = True, vrf: str = 'default') ->
if not present:
raise Exception(f'Unexpected OSPFv3 neighbor {id}{vrf_name} in state {n_state.neighborState}')

ngb_msg = f'OSPFv3 neighbor {id}{vrf_name} is in state {n_state.neighborState}'
if n_state.neighborState != 'Full':
raise Exception(f'OSPFv3 neighbor {id}{vrf_name} is in state {n_state.neighborState}')
raise Exception(ngb_msg)

if not bfd:
raise log.Result(ngb_msg)

return True
exit_msg = f'OSPFv3 neighbor {id} is in BFD state {n_state.peerBfdInfo.status}'
_common.report_state(exit_msg,n_state.peerBfdInfo and n_state.peerBfdInfo.status == "Up")

def show_ospf_prefix(pfx: str, **kwargs: typing.Any) -> str:
return 'ip ospf route json'
Expand Down
47 changes: 47 additions & 0 deletions tests/integration/ospf/ospfv2/42-bfd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
message: |
This topology tests the OSPFv2 with BFD

* Multiple OSPF areas on ABR
* BFD enabled on all interfaces

defaults.sources.extra: [ ../../wait_times.yml, ../../warnings.yml ]
module: [ ospf, bfd ]

ospf.bfd.ipv4: True

groups:

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.

A few notes on the integration test (not your fault, you just used what was there).

You have to define the probe devices as FRR (preferably with CLAB provider), otherwise all lab devices use the same device type.

probes:
device: frr
provider: clab
members: [ bb, r1 ]
mtu: 1500

nodes:
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.

The tested device is usually named "dut", so it's easier to figure out what device you have to troubleshoot.

bb:
r1:
ospf.area: 1

links:
- dut-bb
- dut:
r1:
ospf:
area: 1
cost: 42
network_type: broadcast

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 idea why this is here, but let's say it makes sense and we want to check BFD on multiple areas and link types ;)

- dut:

validate:
adj:
description: Check OSPF adjacencies
wait: ospfv2_adj_lan
wait_msg: Waiting for OSPF adjacency process to complete
nodes: [ r1, bb ]
plugin: ospf_neighbor(nodes.dut.ospf.router_id)
ospf_bfd:
description: Check OSPF BFD adjacencies
wait: ospfv2_adj_p2p
wait_msg: Waiting for OSPF BFD adjacency process to complete
nodes: [ r1, bb ]
plugin: ospf_neighbor(nodes.dut.ospf.router_id,bfd=True)
26 changes: 0 additions & 26 deletions tests/integration/ospf/ospfv2/bfd.yml

This file was deleted.

47 changes: 47 additions & 0 deletions tests/integration/ospf/ospfv3/42-bfd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
message: |
This topology tests the OSPFv2 with BFD

* Multiple OSPF areas on ABR
* BFD enabled on all interfaces

defaults.sources.extra: [ ../../wait_times.yml, ../../warnings.yml ]
module: [ ospf, bfd ]

ospf.bfd.ipv6: True

groups:
probes:
device: frr
provider: clab
members: [ bb, r1 ]
mtu: 1500

nodes:
dut:
bb:
r1:
ospf.area: 1

links:
- dut-bb
- dut:
r1:
ospf:
area: 1
cost: 42
network_type: broadcast
- dut:

validate:
adj:
description: Check OSPFv3 adjacencies
wait: ospfv3_adj_lan
wait_msg: Waiting for OSPFv3 adjacency process to complete
nodes: [ r1, bb ]
plugin: ospf6_neighbor(nodes.dut.ospf.router_id)
ospf_bfd:
description: Check OSPFv3 BFD adjacencies
wait: ospfv2_adj_p2p
wait_msg: Waiting for OSPFv3 BFD adjacency process to complete
nodes: [ r1, bb ]
plugin: ospf6_neighbor(nodes.dut.ospf.router_id,bfd=True)
37 changes: 0 additions & 37 deletions tests/integration/ospf/ospfv3/bfd.yml

This file was deleted.