-
Notifications
You must be signed in to change notification settings - Fork 105
Add Validation functions BGP BFD for FRR/EOS #3534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
| 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 )') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noted |
||
|
|
||
| return f'All specified BGP neighbor parameters have the expected values' | ||
|
|
||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,20 +9,20 @@ defaults.sources.extra: [ ../wait_times.yml, ../warnings.yml ] | |
|
|
||
| groups: | ||
| probes: | ||
| device: eos | ||
| device: frr | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is only 1 peer in the |
||
| x1: | ||
| bgp.as: 65100 | ||
| config: [ static_bfd ] | ||
| bgp.bfd: True | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
|
@@ -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: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
There was a problem hiding this comment.
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.