diff options
author | GomathiselviS <gomathiselvi@gmail.com> | 2020-02-25 07:50:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 07:50:27 -0500 |
commit | 726d6455d813e40f37e1298f0dce8a2f76709de4 (patch) | |
tree | c6ebaf453ae69bc0e7951a69746d2fe09bb9d42a /test/integration | |
parent | 6f0924a8924496ada176fb4b23500e78cb486730 (diff) | |
download | ansible-726d6455d813e40f37e1298f0dce8a2f76709de4.tar.gz |
eos static_routes module added (#65480)
* Adding files for RM static_routes
* Added Integration tests
* Added Unit testcases
* Addressed review comments
* corrected lint errors
* corrected documentation errors
* Lint errors
* corrected test/sanity
* corrected documentation for deprecation
* corrected case sensitivity
* Again Documentation eroor
* Lint errors again
* corrected deprecated module in ignoretxt
* added new gethered,rendered,parsed state checks to unit test
* New code broke the old flow-fixed
* Lint errs
* Added check for running_config
* Add rtt testcase
* Fixed unit tcs
* lint errors
* lint errors
* Modified replaced operation behavior
* updated documentation and tests for delete opration
* fixed shippable errors
* review comments and flake8 error fix
* syntax errors fixed
Diffstat (limited to 'test/integration')
16 files changed, 903 insertions, 0 deletions
diff --git a/test/integration/targets/eos_static_routes/defaults/main.yaml b/test/integration/targets/eos_static_routes/defaults/main.yaml new file mode 100644 index 0000000000..164afead28 --- /dev/null +++ b/test/integration/targets/eos_static_routes/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/test/integration/targets/eos_static_routes/meta/main.yaml b/test/integration/targets/eos_static_routes/meta/main.yaml new file mode 100644 index 0000000000..e5c8cd02f0 --- /dev/null +++ b/test/integration/targets/eos_static_routes/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_eos_tests diff --git a/test/integration/targets/eos_static_routes/tasks/cli.yaml b/test/integration/targets/eos_static_routes/tasks/cli.yaml new file mode 100644 index 0000000000..5b16f46bde --- /dev/null +++ b/test/integration/targets/eos_static_routes/tasks/cli.yaml @@ -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 diff --git a/test/integration/targets/eos_static_routes/tasks/eapi.yaml b/test/integration/targets/eos_static_routes/tasks/eapi.yaml new file mode 100644 index 0000000000..1109c6bf6a --- /dev/null +++ b/test/integration/targets/eos_static_routes/tasks/eapi.yaml @@ -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 diff --git a/test/integration/targets/eos_static_routes/tasks/main.yaml b/test/integration/targets/eos_static_routes/tasks/main.yaml new file mode 100644 index 0000000000..970e74171e --- /dev/null +++ b/test/integration/targets/eos_static_routes/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_static_routes/tests/cli/_parsed.cfg b/test/integration/targets/eos_static_routes/tests/cli/_parsed.cfg new file mode 100644 index 0000000000..a4bb4d6549 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/_parsed.cfg @@ -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 diff --git a/test/integration/targets/eos_static_routes/tests/cli/_populate.yaml b/test/integration/targets/eos_static_routes/tests/cli/_populate.yaml new file mode 100644 index 0000000000..98f1ff9725 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/_populate.yaml @@ -0,0 +1,16 @@ +--- +- name: Setup + cli_config: + config: "{{ lines }}" + become: yes + 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 diff --git a/test/integration/targets/eos_static_routes/tests/cli/_remove_config.yaml b/test/integration/targets/eos_static_routes/tests/cli/_remove_config.yaml new file mode 100644 index 0000000000..aa95912d80 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/_remove_config.yaml @@ -0,0 +1,20 @@ +--- +- name: Setup + cli_config: + config: "{{ lines }}" + become: yes + 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 122.1.19.0/24 Nexthop-Group testgrp 21 + 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 + no ipv6 route 1000:10::/64 Ethernet1 55 diff --git a/test/integration/targets/eos_static_routes/tests/cli/deleted.yaml b/test/integration/targets/eos_static_routes/tests/cli/deleted.yaml new file mode 100644 index 0000000000..3b5dcb5739 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/deleted.yaml @@ -0,0 +1,224 @@ +--- +- 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 + +- set_fact: + config1: + - 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 + - address_families: + - afi: ipv4 + routes: + - dest: 120.1.1.0/24 + next_hops: + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + +- set_fact: + config2: + - 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: 120.1.1.0/24 + next_hops: + - admin_distance: 23 + interface: Ethernet1 + vrf: testvrf + +- set_fact: + config3: + - address_families: + - afi: ipv4 + routes: + - dest: 10.1.1.0/24 + next_hops: + - 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: 120.1.1.0/24 + next_hops: + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + + +- name: Delete attributes of given static routes - dest specific. + 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 + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []" + - '"no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" in result.commands' + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + become: yes + +- name: Idempotency check + eos_static_routes: *deleted + become: yes + register: result + +- assert: + that: + - "result.changed == false" + - "result.commands|length == 0" + +- include_tasks: _populate.yaml + +- name: Delete attributes of given static routes - afi specific. + eos_static_routes: + config: + - address_families: + - afi: 'ipv6' + state: deleted + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config1) == []" + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + become: yes + +- name: Delete attributes of given static routes - vrf specific. + eos_static_routes: + config: + - vrf: vrftest1 + state: deleted + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config2) == []" + - '"no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" in result.commands' + become: yes + +- name: Delete attributes of given static routes - nexthop specific. + eos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 10.1.1.0/24 + next_hops: + - interface: Management1 + state: deleted + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config3) == []" + - '"no ip route 10.1.1.0/24 Management1" in result.commands' + become: yes + +- include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/gathered.yaml b/test/integration/targets/eos_static_routes/tests/cli/gathered.yaml new file mode 100644 index 0000000000..f89a6c0809 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/gathered.yaml @@ -0,0 +1,75 @@ +--- +- 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 + become: yes + 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 + become: yes + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/merged.yaml b/test/integration/targets/eos_static_routes/tests/cli/merged.yaml new file mode 100644 index 0000000000..55ecdb5b84 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/merged.yaml @@ -0,0 +1,102 @@ +--- +- 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 + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []" + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + - '"ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100" in result.commands' + become: yes + +- name: Idempotency check + eos_static_routes: *merged + become: yes + register: result + +- assert: + that: + - "result.changed == false" + - "result.commands|length == 0" + +- include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/overridden.yaml b/test/integration/targets/eos_static_routes/tests/cli/overridden.yaml new file mode 100644 index 0000000000..5af837fdf0 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/overridden.yaml @@ -0,0 +1,61 @@ +--- +- 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 + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []" + - "result.commands|length == 8" + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + - '"no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" in result.commands' + - '"no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" in result.commands' + - '"no ip route 10.50.0.0/16 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" in result.commands' + - '"no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" in result.commands' + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + become: yes + +- name: Idempotency check + eos_static_routes: *overridden + become: yes + register: result + +- assert: + that: + - "result.changed == false" + - "result.commands|length == 0" + +- include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/parsed.yaml b/test/integration/targets/eos_static_routes/tests/cli/parsed.yaml new file mode 100644 index 0000000000..aaaabb449a --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/parsed.yaml @@ -0,0 +1,37 @@ +--- +- 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 + become: yes + 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 + become: yes + 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 + become: yes + register: result + +- assert: + that: + - "result['changed'] == false" + +- include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/rendered.yaml b/test/integration/targets/eos_static_routes/tests/cli/rendered.yaml new file mode 100644 index 0000000000..d188702d48 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/rendered.yaml @@ -0,0 +1,53 @@ +--- +- 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 + become: yes + 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 diff --git a/test/integration/targets/eos_static_routes/tests/cli/replaced.yaml b/test/integration/targets/eos_static_routes/tests/cli/replaced.yaml new file mode 100644 index 0000000000..1a8353803e --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/replaced.yaml @@ -0,0 +1,90 @@ +--- +- 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: ipv4 + routes: + - dest: 120.1.1.0/24 + next_hops: + - admin_distance: 23 + interface: Ethernet1 + - afi: ipv6 + routes: + - dest: 1000: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: '1000:10::/64' + next_hops: + - interface: Ethernet1 + admin_distance: 55 + state: replaced + become: yes + register: result + +- eos_facts: + gather_network_resources: static_routes + become: yes + +- assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []" + - '"ipv6 route vrf testvrf 1000:10::/64 Ethernet1 55" in result.commands' + become: yes + +- name: Idempotency check + eos_static_routes: *replaced + become: yes + register: result + +- assert: + that: + - "result.changed == false" + - "result.commands|length == 0" + +- include_tasks: _remove_config.yaml diff --git a/test/integration/targets/eos_static_routes/tests/cli/rtt.yaml b/test/integration/targets/eos_static_routes/tests/cli/rtt.yaml new file mode 100644 index 0000000000..1890b1f833 --- /dev/null +++ b/test/integration/targets/eos_static_routes/tests/cli/rtt.yaml @@ -0,0 +1,177 @@ +--- +- 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 + + + revert_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: 122.1.19.0/24 + next_hops: + - admin_distance: 21 + nexthop_grp: testgrp + - 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 + +- block: + - name: merge attributes of given static routes. + eos_static_routes: + 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 + become: yes + register: base_config + + - eos_facts: + gather_network_resources: static_routes + become: yes + + - assert: + that: + - "ansible_facts.network_resources.static_routes|symmetric_difference(config) == []" + + - name: Apply the provided configuration (config to be reverted) + eos_static_routes: + config: + - address_families: + - afi: 'ipv4' + routes: + - dest: '122.1.19.0/24' + next_hops: + - nexthop_grp: testgrp + admin_distance: 21 + state: merged + become: yes + register: result + + - assert: + that: + - "result.after|symmetric_difference(revert_config) == []" + + - name: Revert back to base config using facts round trip + eos_static_routes: + config: "{{ ansible_facts['network_resources']['static_routes'] }}" + state: overridden + become: yes + register: revert + + - name: Assert that config was reverted + assert: + that: + - "ansible_facts.network_resources.static_routes | symmetric_difference(revert.after) == []" + + always: + - include_tasks: _remove_config.yaml |