Skip to content

Commit

Permalink
Fix Integration tests (#1060)
Browse files Browse the repository at this point in the history
* Fix Integtaion tests

* remove only loopback in lacp

* add back the purge in lacp

* Added false condition for l2 appliance tests

* Add false condition for evpn tests

* vlans intergation test condition

* fix evpn_global intergration test issues

* skip vxlan_vtep l2 tests

* Fix l3 interface test issuesss

* fix lacp int test issue

* fix test

* vxlan fix

* evpn global

* bgp address family fix

* lint fix

* Remove vlans

* Remove debug statement
  • Loading branch information
roverflow authored May 6, 2024
1 parent 0c5ee86 commit 39af3bc
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Set a fact for 'skip_test'
ansible.builtin.set_fact:
skip_test: false

- name: Main task for bgp_address_family module
ansible.builtin.include_tasks: cli.yaml
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
cisco.ios.ios_bgp_address_family: &id001
config:
address_family:
- afi: l2vpn
safi: evpn
neighbor:
- address: 198.51.100.1
activate: true
inherit: LEAF-EVPN-PEER-POLICY
- afi: ipv4
vrf: green
redistribute:
- static:
set: true
- connected:
set: true
advertise:
afi: l2vpn
safi: evpn
# L2 specific configuration
# - afi: l2vpn
# safi: evpn
# neighbor:
# - address: 198.51.100.1
# activate: true
# inherit: LEAF-EVPN-PEER-POLICY
# - afi: ipv4
# vrf: green
# redistribute:
# - static:
# set: true
# - connected:
# set: true
# advertise:
# afi: l2vpn
# safi: evpn
- afi: ipv4
redistribute:
- connected:
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/targets/ios_bgp_address_family/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ 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 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
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/ios_evpn_evi/tasks/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
delegate_to: localhost

- name: Run test case (connection=ansible.netcommon.network_cli)
when: skip_test
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.network_cli
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/targets/ios_evpn_evi/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Set a fact for 'skip_test'
ansible.builtin.set_fact:
skip_test: false

- name: Main task for EVPN EVI module
ansible.builtin.include_tasks: cli.yaml
tags:
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/ios_evpn_global/tasks/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
delegate_to: localhost

- name: Run test case (connection=ansible.netcommon.network_cli)
when: skip_test
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.network_cli
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/targets/ios_evpn_global/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Set a fact for 'skip_test'
ansible.builtin.set_fact:
skip_test: false

- name: Main task for evpn_global module
ansible.builtin.include_tasks: cli.yaml
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- name: Ios_evpn_global deleted - play (idempotent)
register: result
cisco.ios.ios_evpn_global: *id001

- name: Ios_evpn_global deleted - assert above task was idempotent
ansible.builtin.assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- name: Ios_evpn_global merged - play (idempotent)
register: result
cisco.ios.ios_evpn_global: *id001

- name: Ios_evpn_global merged - assert above task was idempotent
ansible.builtin.assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- name: Ios_evpn_global replaced - play (idempotent)
register: result
cisco.ios.ios_evpn_global: *id001

- name: Ios_evpn_global replaced - assert above task was idempotent
ansible.builtin.assert:
that:
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/targets/ios_facts/tests/cli/all_facts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
- result.ansible_facts.ansible_net_memfree_mb > 1
- result.ansible_facts.ansible_net_memtotal_mb > 1

- ansible.builtin.assert:
that: "{{ my_var.value.spacetotal_kb }} > {{ my_var.value.spacefree_kb }}"
- name: Assert that free spacee is less than total space
ansible.builtin.assert:
that: "my_var.value.spacetotal_kb > my_var.value.spacefree_kb"
loop: "{{ lookup('dict', result.ansible_facts.ansible_net_filesystems_info, wantlist=True) }}"
loop_control:
loop_var: my_var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
- name: Port-channel11
- name: Port-channel22
- name: Port-channel40
- name: Loopback1
state: purged
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@
\ ipv6 address\n"
ansible.netcommon.cli_config:
config: "{{ lines }}"

- name: Delete attributes of all configured interfaces
register: result
cisco.ios.ios_interfaces:
config:
- name: Loopback1
- name: Vlan101
- name: Vlan901
- name: Vlan902
state: purged
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
- address: 198.51.100.2/24
ipv6:
- address: 2001:db8:0:3::/64
- name: Vlan101
ipv4:
- address: 198.51.100.2/24
mac_address: dead:beef:abcd
- name: Vlan901
autostate: false
ipv4:
Expand All @@ -38,6 +34,8 @@
autostate: true
ipv6:
- enable: true
- name: Vlan101
autostate: false
state: merged

- name: L3_interface merged - assert that correct set of commands were generated
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/targets/ios_l3_interfaces/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ merged:
- ipv6 enable
- interface Vlan902
- ipv6 enable
- interface Vlan101
- no autostate
after:
- name: Loopback888
- ipv4:
Expand All @@ -46,10 +48,7 @@ merged:
- address: 2001:DB8:0:3::/64
name: GigabitEthernet3
- name: GigabitEthernet4
- name: Vlan101
ipv4:
- address: 198.51.100.2/24
mac_address: dead:beef:abcd
- name: Loopback1
- name: Vlan901
ipv4:
- source_interface:
Expand All @@ -61,6 +60,8 @@ merged:
ipv6:
- enable: true
autostate: true
- name: Vlan101
autostate: false

replaced:
before:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
register: result
cisco.ios.ios_interfaces:
config:
- name: Loopback1
- name: Port-channel10
- name: Port-channel11
- name: Port-channel22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
register: result
cisco.ios.ios_interfaces:
config:
- name: Loopback1
- name: Port-channel10
- name: Port-channel11
- name: Port-channel22
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/targets/ios_vlans/tasks/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
cisco.ios.ios_facts:
gather_subset: all

- name: Set filtered paths to run only non l2 tests
ansible.builtin.set_fact:
filtered_file_paths: "{{ test_items | reject('search', 'vlan_config') | list }}"

- name: Run test case (connection=ansible.netcommon.network_cli)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.network_cli
with_items: "{{ test_items }}"
with_items: "{{ filtered_file_paths }}"
loop_control:
loop_var: test_case_to_run
4 changes: 4 additions & 0 deletions tests/integration/targets/ios_vlans/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Set a fact for 'skip_test'
ansible.builtin.set_fact:
skip_test: false

- name: Main task for vlans module
ansible.builtin.include_tasks: cli.yaml
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- name: Delete vlans attributes for all configured vlans (idempotent)
register: result
cisco.ios.ios_vlans: *id001

- name: Assert that the previous task was idempotent
ansible.builtin.assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- name: Merge provided configuration with device configuration (idempotent)
register: result
cisco.ios.ios_vlans: *id001

- name: Assert that the previous task was idempotent
ansible.builtin.assert:
that:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- name: Override device configuration of all interfaces with provided configuration (idempotent)
register: result
cisco.ios.ios_vlans: *id001

- name: Assert that task was idempotent
ansible.builtin.assert:
that:
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/targets/ios_vlans/tests/cli/rendered.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
shutdown: enabled
state: rendered

- ansible.builtin.assert:
- name: Assert that correct set of commands were generated
ansible.builtin.assert:
that:
- result.changed == false
- result.rendered|symmetric_difference(rendered.commands) == []
- "{{ rendered['commands'] | symmetric_difference(result['rendered']) | length == 0 }}"
when: ansible_net_version != "15.6(2)T"
4 changes: 2 additions & 2 deletions tests/integration/targets/ios_vlans/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ rendered:
- name Vlan_20
- state active
- mtu 610
- shutdown
- no shutdown
- vlan 30
- name Vlan_30
- state suspend
- shutdown
- no shutdown

rendered_vlan_config:
commands:
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/ios_vxlan_vtep/tasks/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
delegate_to: localhost

- name: Run test case (connection=ansible.netcommon.network_cli)
when: skip_test
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.network_cli
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/targets/ios_vxlan_vtep/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
- name: Set a fact for 'skip_test'
ansible.builtin.set_fact:
skip_test: false

- name: Main task for VXLAN VTEP module
ansible.builtin.include_tasks: cli.yaml
tags:
Expand Down

0 comments on commit 39af3bc

Please sign in to comment.