Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KB-perByte committed Sep 10, 2024
1 parent cf93d1a commit e5da466
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
# afi: l2vpn
# safi: evpn
- afi: ipv4
maximum_paths:
paths: 12
maximum_secondary_paths:
eibgp: 2
redistribute:
- connected:
metric: 10
Expand Down Expand Up @@ -101,7 +105,7 @@
metric: 10
route_map: bar
include_connected: true
as_number: "65000"
as_number: '65000'
state: merged

- name: Assert that correct set of commands were generated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,97 @@
msg: Start ios_bgp_address_family rendered integration tests ansible_connection={{ ansible_connection }}

- block:
- name: Render the commands for provided configuration
- name: Render config lines for the provided configuration
register: result
cisco.ios.ios_bgp_address_family:
cisco.ios.ios_bgp_address_family: &id001
config:
as_number: 65000
address_family:
- afi: ipv4
safi: multicast
# vrf: blue
aggregate_address:
- address: 192.0.2.1
netmask: 255.255.255.255
as_confed_set: true
bgp:
aggregate_timer: 10
dampening:
penalty_half_time: 1
reuse_route_val: 1
suppress_route_val: 1
max_suppress: 1
slow_peer:
- detection:
threshold: 150
neighbor:
- address: 198.51.100.1
aigp:
send:
cost_community:
id: 100
poi:
igp_cost: true
transitive: true
slow_peer:
- detection:
threshold: 150
remote_as: 10
route_maps:
- name: test-route
out: true
network:
- address: 198.51.110.10
mask: 255.255.255.255
backdoor: true
- afi: ipv4
safi: mdt
bgp:
dmzlink_bw: true
dampening:
penalty_half_time: 1
reuse_route_val: 10
suppress_route_val: 100
max_suppress: 5
soft_reconfig_backup: true
maximum_paths:
paths: 12
maximum_secondary_paths:
eibgp: 2
redistribute:
- connected:
metric: 10
- ospf:
process_id: 124
- ospf:
process_id: 123
match:
internal: true
externals:
type_1: true
type_2: true
nssa_externals:
type_1: true
type_2: true
metric: 10
route_map: bar
- ospfv3:
process_id: 123
match:
internal: true
externals:
type_1: true
type_2: true
nssa_externals:
type_1: true
type_2: true
metric: 10
route_map: bar
- afi: ipv4
safi: multicast
aggregate_address:
aggregate_addresses:
- address: 192.0.3.1
netmask: 255.255.255.255
as_confed_set: true
netmask: 255.255.255.255
default_metric: 12
distance:
external: 10
internal: 10
local: 100
network:
networks:
- address: 198.51.111.11
mask: 255.255.255.255
route_map: test
safi: multicast
table_map:
name: test_tableMap
filter: true
name: test_tableMap
- afi: ipv4
bgp:
dampening:
max_suppress: 5
penalty_half_time: 1
reuse_route_val: 10
suppress_route_val: 100
dmzlink_bw: true
soft_reconfig_backup: true
safi: mdt
- afi: ipv6
redistribute:
- ospf:
process_id: 124
match:
internal: true
externals:
type_1: true
type_2: true
nssa_externals:
type_1: true
type_2: true
metric: 10
route_map: bar
include_connected: true
as_number: '65000'
state: rendered

- ansible.builtin.assert:
- name: Assert that change was false
ansible.builtin.assert:
that:
- result.changed == false

- name: Assert that correct set of commands were generated
ansible.builtin.assert:
that:
- "{{ rendered['commands'] | symmetric_difference(result['rendered']) | length == 0 }}"
70 changes: 44 additions & 26 deletions tests/integration/targets/ios_bgp_address_family/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,24 @@ merged:

commands:
- router bgp 65000
# - address-family l2vpn evpn
# - neighbor 198.51.100.1 activate
# - neighbor 198.51.100.1 inherit peer-policy LEAF-EVPN-PEER-POLICY
# - address-family ipv4 vrf green
# - advertise l2vpn evpn
# - redistribute connected
# - redistribute static
- address-family ipv4 multicast
- default-metric 12
- distance bgp 10 10 100
- table-map test_tableMap filter
- network 198.51.111.11 mask 255.255.255.255 route-map test
- aggregate-address 192.0.3.1 255.255.255.255 as-confed-set
- address-family ipv6
- redistribute ospf 124 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar include-connected
- address-family ipv4 mdt
- bgp dmzlink-bw
- bgp soft-reconfig-backup
- bgp dampening 1 10 100 5
- address-family ipv6
- redistribute ospf 124 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar include-connected
- address-family ipv4
- maximum-paths 12
- maximum-secondary-paths eibgp 2
- redistribute connected metric 10
- redistribute ospf 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
- redistribute ospf 124
- redistribute ospf 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
- redistribute ospfv3 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar

after:
Expand Down Expand Up @@ -121,7 +116,7 @@ merged:
metric: 10
process_id: 124
route_map: bar
as_number: "65000"
as_number: '65000'

overridden:
commands:
Expand Down Expand Up @@ -179,11 +174,11 @@ overridden:
type_1: true
metric: 15
route_map: foo
- afi: "ipv4"
- afi: 'ipv4'
aggregate_addresses:
- address: "192.0.2.1"
- address: '192.0.2.1'
as_confed_set: true
netmask: "255.255.255.255"
netmask: '255.255.255.255'
bgp:
aggregate_timer: 10
dampening:
Expand All @@ -195,15 +190,15 @@ overridden:
detection:
threshold: 150
networks:
- address: "198.51.110.10"
- address: '198.51.110.10'
backdoor: true
mask: "255.255.255.255"
safi: "multicast"
mask: '255.255.255.255'
safi: 'multicast'
# vrf: "blue"
- afi: "ipv4"
safi: "mdt"
- afi: "ipv6"
- afi: "ipv6"
- afi: 'ipv4'
safi: 'mdt'
- afi: 'ipv6'
- afi: 'ipv6'
bgp:
aggregate_timer: 10
dampening:
Expand All @@ -217,8 +212,8 @@ overridden:
networks:
- address: 2001:DB8:0:3::/64
route_map: test_ipv6
safi: "multicast"
as_number: "65000"
safi: 'multicast'
as_number: '65000'

replaced:
commands:
Expand Down Expand Up @@ -305,7 +300,7 @@ replaced:
metric: 10
route_map: bar
include_connected: true
as_number: "65000"
as_number: '65000'

deleted:
commands:
Expand All @@ -315,9 +310,32 @@ deleted:
- no address-family ipv4
- no address-family ipv6

rendered:
commands:
- router bgp 65000
- address-family ipv4
- maximum-paths 12
- maximum-secondary-paths eibgp 2
- redistribute connected metric 10
- redistribute ospf 124
- redistribute ospf 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
- redistribute ospfv3 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
- address-family ipv4 multicast
- default-metric 12
- distance bgp 10 10 100
- table-map test_tableMap filter
- network 198.51.111.11 mask 255.255.255.255 route-map test
- aggregate-address 192.0.3.1 255.255.255.255 as-confed-set
- address-family ipv4 mdt
- bgp dmzlink-bw
- bgp soft-reconfig-backup
- bgp dampening 1 10 100 5
- address-family ipv6
- redistribute ospf 124 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar include-connected

deleted_all:
after:
as_number: "65000"
as_number: '65000'

parsed:
config:
Expand All @@ -334,4 +352,4 @@ parsed:
- address: 192.0.2.0
- address: 192.0.3.0
- address: 192.0.4.0
as_number: "65536"
as_number: '65536'

0 comments on commit e5da466

Please sign in to comment.