mirror of https://github.com/ansible/ansible.git
Added Integration tests
parent
dafdd92d43
commit
129dc87682
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
testcase: "[^_].*"
|
||||||
|
test_items: []
|
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- prepare_eos_tests
|
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
- name: collect all cli test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/cli"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
use_regex: true
|
||||||
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test cases (connection=network_cli)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: collect all eapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/eapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
delegate_to: localhost
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: run test cases (connection=httpapi)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=httpapi"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
- { include: eapi.yaml, tags: ['eapi'] }
|
@ -0,0 +1,7 @@
|
|||||||
|
ip route 10.1.1.0/24 Management1
|
||||||
|
ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200
|
||||||
|
ip route 10.50.0.0/16 Management1
|
||||||
|
ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42
|
||||||
|
ip route vrf testvrf 120.1.1.0/24 Ethernet1 23
|
||||||
|
ip route vrf vrftest1 77.77.1.0/24 33.1.1.1
|
||||||
|
ipv6 route 1000:10::/64 Ethernet1 67 tag 98
|
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: Setup
|
||||||
|
cli_config:
|
||||||
|
config: "{{ lines }}"
|
||||||
|
vars:
|
||||||
|
lines: |
|
||||||
|
vrf definition testvrf
|
||||||
|
vrf definition vrftest1
|
||||||
|
ip route 10.1.1.0/24 Management1
|
||||||
|
ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200
|
||||||
|
ip route 10.50.0.0/16 Management1
|
||||||
|
ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42
|
||||||
|
ip route vrf testvrf 120.1.1.0/24 Ethernet1 23
|
||||||
|
ip route vrf vrftest1 77.77.1.0/24 33.1.1.1
|
||||||
|
ipv6 route 1000:10::/64 Ethernet1 67 tag 98
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
- name: Setup
|
||||||
|
cli_config:
|
||||||
|
config: "{{ lines }}"
|
||||||
|
vars:
|
||||||
|
lines: |
|
||||||
|
no vrf definition testvrf
|
||||||
|
no vrf definition vrftest1
|
||||||
|
no ip route 10.1.1.0/24 Management1
|
||||||
|
no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200
|
||||||
|
no ip route 10.50.0.0/16 Management1
|
||||||
|
no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42
|
||||||
|
no ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100
|
||||||
|
no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23
|
||||||
|
no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1
|
||||||
|
no ipv6 route 1000:10::/64 Ethernet1 67 tag 98
|
||||||
|
no ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "Start eos_static_routes deleted integration tests ansible_connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
config:
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 10.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- admin_distance: 200
|
||||||
|
forward_router_address: 20.1.1.3
|
||||||
|
interface: Ethernet1
|
||||||
|
track: bfd
|
||||||
|
- dest: 10.50.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- dest: 23.1.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 42
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 77.77.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: 33.1.1.1
|
||||||
|
vrf: vrftest1
|
||||||
|
|
||||||
|
- name: Delete attributes of given static routes.
|
||||||
|
eos_static_routes: &deleted
|
||||||
|
config:
|
||||||
|
- vrf: "testvrf"
|
||||||
|
address_families:
|
||||||
|
- afi: 'ipv4'
|
||||||
|
routes:
|
||||||
|
- dest: '120.1.1.0/24'
|
||||||
|
- address_families:
|
||||||
|
- afi: 'ipv6'
|
||||||
|
routes:
|
||||||
|
- dest: '1000:10::/64'
|
||||||
|
state: deleted
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- eos_facts:
|
||||||
|
gather_network_resources: static_routes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []"
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Idempotency check
|
||||||
|
eos_static_routes: *deleted
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands|length == 0"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START eos_static_routes gathered integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Gathered the provided configuration with the exisiting running configuration
|
||||||
|
eos_static_routes: &gathered
|
||||||
|
config:
|
||||||
|
state: gathered
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
config:
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 10.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- admin_distance: 200
|
||||||
|
forward_router_address: 20.1.1.3
|
||||||
|
interface: Ethernet1
|
||||||
|
track: bfd
|
||||||
|
- dest: 10.50.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- dest: 23.1.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 42
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1000:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 67
|
||||||
|
interface: Ethernet1
|
||||||
|
tag: 98
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 77.77.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: 33.1.1.1
|
||||||
|
vrf: vrftest1
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 120.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 23
|
||||||
|
interface: Ethernet1
|
||||||
|
vrf: testvrf
|
||||||
|
|
||||||
|
- name: Assert that gathered dicts was correctly generated
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- " config | symmetric_difference(result['gathered']) == []"
|
||||||
|
|
||||||
|
- name: Gather the existing running configuration (IDEMPOTENT)
|
||||||
|
eos_static_routes: *gathered
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that the previous task was idempotent
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "result['changed'] == false"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,98 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "Start eos_static_routes merged integration tests ansible_connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
config:
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 10.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- admin_distance: 200
|
||||||
|
forward_router_address: 20.1.1.3
|
||||||
|
interface: Ethernet1
|
||||||
|
track: bfd
|
||||||
|
- dest: 10.50.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- dest: 23.1.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 42
|
||||||
|
- dest: 155.55.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 100
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1000:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 67
|
||||||
|
interface: Ethernet1
|
||||||
|
tag: 98
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 77.77.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: 33.1.1.1
|
||||||
|
vrf: vrftest1
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 120.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 23
|
||||||
|
interface: Ethernet1
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1120:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 55
|
||||||
|
interface: Ethernet1
|
||||||
|
vrf: testvrf
|
||||||
|
|
||||||
|
- name: merge attributes of given static routes.
|
||||||
|
eos_static_routes: &merged
|
||||||
|
config:
|
||||||
|
- vrf: "testvrf"
|
||||||
|
address_families:
|
||||||
|
- afi: 'ipv6'
|
||||||
|
routes:
|
||||||
|
- dest: '1120:10::/64'
|
||||||
|
next_hops:
|
||||||
|
- interface: Ethernet1
|
||||||
|
admin_distance: 55
|
||||||
|
- address_families:
|
||||||
|
- afi: 'ipv4'
|
||||||
|
routes:
|
||||||
|
- dest: '155.55.1.0/24'
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 100
|
||||||
|
state: merged
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- eos_facts:
|
||||||
|
gather_network_resources: static_routes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []"
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Idempotency check
|
||||||
|
eos_static_routes: *merged
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands|length == 0"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,50 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "Start eos_static_routes merged integration tests ansible_connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
config:
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1120:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 55
|
||||||
|
interface: Ethernet1
|
||||||
|
vrf: testvrf
|
||||||
|
|
||||||
|
- name: Override attributes of given static routes.
|
||||||
|
eos_static_routes: &overridden
|
||||||
|
config:
|
||||||
|
- vrf: "testvrf"
|
||||||
|
address_families:
|
||||||
|
- afi: 'ipv6'
|
||||||
|
routes:
|
||||||
|
- dest: '1120:10::/64'
|
||||||
|
next_hops:
|
||||||
|
- interface: Ethernet1
|
||||||
|
admin_distance: 55
|
||||||
|
state: overridden
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- eos_facts:
|
||||||
|
gather_network_resources: static_routes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []"
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Idempotency check
|
||||||
|
eos_static_routes: *overridden
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands|length == 0"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START eos_static_routes parsed integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- name: Gather static_routes facts
|
||||||
|
eos_facts:
|
||||||
|
gather_subset:
|
||||||
|
- default
|
||||||
|
gather_network_resources:
|
||||||
|
- static_routes
|
||||||
|
register: static_routes_facts
|
||||||
|
|
||||||
|
- name: Provide the running configuration for parsing (config to be parsed)
|
||||||
|
eos_static_routes: &parsed
|
||||||
|
running_config:
|
||||||
|
"{{ lookup('file', '_parsed.cfg') }}"
|
||||||
|
state: parsed
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed']) |length == 0 }}"
|
||||||
|
|
||||||
|
- name: Gather the existing running configuration (IDEMPOTENT)
|
||||||
|
eos_static_routes: *parsed
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result['changed'] == false"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,52 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START eos_static_routes rendered integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Structure provided configuration into device specific commands
|
||||||
|
eos_static_routes: &rendered
|
||||||
|
config:
|
||||||
|
- vrf: "testvrf"
|
||||||
|
address_families:
|
||||||
|
- afi: 'ipv6'
|
||||||
|
routes:
|
||||||
|
- dest: '1120:10::/64'
|
||||||
|
next_hops:
|
||||||
|
- interface: Ethernet1
|
||||||
|
admin_distance: 55
|
||||||
|
- address_families:
|
||||||
|
- afi: 'ipv4'
|
||||||
|
routes:
|
||||||
|
- dest: '155.55.1.0/24'
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 100
|
||||||
|
state: rendered
|
||||||
|
register: result
|
||||||
|
|
||||||
|
|
||||||
|
- name: Assert that correct set of commands were generated
|
||||||
|
vars:
|
||||||
|
lines:
|
||||||
|
- ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55
|
||||||
|
- ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100
|
||||||
|
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "{{ lines | symmetric_difference(result['rendered']) |length == 0 }}"
|
||||||
|
|
||||||
|
- name: Structure provided configuration into device specific commands (IDEMPOTENT)
|
||||||
|
eos_static_routes: *rendered
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that the previous task was idempotent
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "result['changed'] == false"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- include_tasks: _remove_config.yaml
|
@ -0,0 +1,81 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "Start eos_static_routes merged integration tests ansible_connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- include_tasks: _populate.yaml
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
config:
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 10.1.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- admin_distance: 200
|
||||||
|
forward_router_address: 20.1.1.3
|
||||||
|
interface: Ethernet1
|
||||||
|
track: bfd
|
||||||
|
- dest: 10.50.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- interface: Management1
|
||||||
|
- dest: 23.1.0.0/16
|
||||||
|
next_hops:
|
||||||
|
- nexthop_grp: testgrp
|
||||||
|
tag: 42
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1000:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 67
|
||||||
|
interface: Ethernet1
|
||||||
|
tag: 98
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv4
|
||||||
|
routes:
|
||||||
|
- dest: 77.77.1.0/24
|
||||||
|
next_hops:
|
||||||
|
- interface: 33.1.1.1
|
||||||
|
vrf: vrftest1
|
||||||
|
- address_families:
|
||||||
|
- afi: ipv6
|
||||||
|
routes:
|
||||||
|
- dest: 1120:10::/64
|
||||||
|
next_hops:
|
||||||
|
- admin_distance: 55
|
||||||
|
interface: Ethernet1
|
||||||
|
vrf: testvrf
|
||||||
|
|
||||||
|
- name: Replace attributes of given static routes.
|
||||||
|
eos_static_routes: &replaced
|
||||||
|
config:
|
||||||
|
- vrf: "testvrf"
|
||||||
|
address_families:
|
||||||
|
- afi: 'ipv6'
|
||||||
|
routes:
|
||||||
|
- dest: '1120:10::/64'
|
||||||
|
next_hops:
|
||||||
|
- interface: Ethernet1
|
||||||
|
admin_distance: 55
|
||||||
|
state: replaced
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- eos_facts:
|
||||||
|
gather_network_resources: static_routes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []"
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Idempotency check
|
||||||
|
eos_static_routes: *replaced
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
- "result.commands|length == 0"
|
||||||
|
|
||||||
|
- include_tasks: _remove_config.yaml
|
Loading…
Reference in New Issue