mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
New eos_vrf module (#25427)
* New eos_vrf module * Add CLI integration tests * Check rd only if not None
This commit is contained in:
parent
bf0d0274cf
commit
d83f254bb6
9 changed files with 366 additions and 1 deletions
1
test/integration/targets/eos_vrf/aliases
Normal file
1
test/integration/targets/eos_vrf/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
network/ci
|
2
test/integration/targets/eos_vrf/defaults/main.yaml
Normal file
2
test/integration/targets/eos_vrf/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/eos_vrf/meta/main.yml
Normal file
2
test/integration/targets/eos_vrf/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_eos_tests
|
15
test/integration/targets/eos_vrf/tasks/cli.yaml
Normal file
15
test/integration/targets/eos_vrf/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
33
test/integration/targets/eos_vrf/tasks/eapi.yaml
Normal file
33
test/integration/targets/eos_vrf/tasks/eapi.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: collect all eapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/eapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" #"
|
||||
|
||||
- name: enable eapi
|
||||
eos_eapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
enable_local_http: yes
|
||||
enable_socket: yes
|
||||
provider: "{{ cli }}"
|
||||
# authorize: yes
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable eapi
|
||||
eos_eapi:
|
||||
enable_http: no
|
||||
enable_https: no
|
||||
enable_local_http: no
|
||||
enable_socket: no
|
||||
provider: "{{ cli }}"
|
||||
# authorize: yes
|
3
test/integration/targets/eos_vrf/tasks/main.yaml
Normal file
3
test/integration/targets/eos_vrf/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: eapi.yaml, tags: ['eapi'] }
|
116
test/integration/targets/eos_vrf/tests/cli/basic.yaml
Normal file
116
test/integration/targets/eos_vrf/tests/cli/basic.yaml
Normal file
|
@ -0,0 +1,116 @@
|
|||
---
|
||||
|
||||
- name: setup - remove vrf
|
||||
eos_vrf:
|
||||
name: test
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Create vrf
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:200
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vrf definition test' in result.commands"
|
||||
- "'rd 1:200' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Create vrf again (idempotent)
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:200
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Modify rd
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vrf definition test' in result.commands"
|
||||
- "'rd 1:201' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Modify rd again (idempotent)
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Add Ethernet2 to vrf
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
interfaces:
|
||||
- Ethernet2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface Ethernet2' in result.commands"
|
||||
- "'vrf forwarding test' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Add Ethernet2 to vrf again (idempotent)
|
||||
eos_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
interfaces:
|
||||
- Ethernet2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
Loading…
Add table
Add a link
Reference in a new issue