mirror of https://github.com/ansible/ansible.git
adds eos_system integration tests (#22214)
* adds integration test cases * updates eos_system with minor bug fixespull/22232/head
parent
30b6ed8377
commit
6c8025ce5c
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_eos_tests
|
@ -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
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
- 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
|
||||
nxos_config:
|
||||
lines:
|
||||
- feature eapi
|
||||
- eapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable eapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- no feature eapi
|
||||
provider: "{{ cli }}"
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: eapi.yaml, tags: ['eapi'] }
|
@ -0,0 +1,122 @@
|
||||
---
|
||||
- debug: msg="START cli/set_domain_list.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure domain_list
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list ansible.com' in result.commands"
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify domain_list
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: add one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify add one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: add and remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- eng.ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain-list redhat.com' in result.commands"
|
||||
- "'ip domain-list eng.ansible.com' in result.commands"
|
||||
- result.commands|length == 2
|
||||
|
||||
- name: verify add and remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- eng.ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
- no ip domain-list eng.ansible.com
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_domain_list.yaml"
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
- debug: msg="START cli/set_domain_name.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines: no ip domain-name
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure domain_name
|
||||
eos_system:
|
||||
domain_name: eng.ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify domain_name
|
||||
eos_system:
|
||||
domain_name: eng.ansible.com
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines: no ip domain-name
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_domain_name.yaml"
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
- debug: msg="START cli/set_hostname.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines: hostname switch
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure hostname
|
||||
eos_system:
|
||||
hostname: foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify hostname
|
||||
eos_system:
|
||||
hostname: foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines: "hostname {{ inventory_hostname }}"
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_hostname.yaml"
|
@ -0,0 +1,68 @@
|
||||
---
|
||||
- debug: msg="START cli/set_lookup_source.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure lookup_source
|
||||
eos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain lookup source-interface Management1' in result.commands"
|
||||
|
||||
- name: verify lookup_source
|
||||
eos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: change to vrf
|
||||
eos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain lookup source-interface Management1' in result.commands"
|
||||
- "'ip domain lookup vrf ansible source-interface Management1' in result.commands"
|
||||
- result.commands|length == 2
|
||||
|
||||
- name: verify change to vrf
|
||||
eos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_lookup_source.yaml"
|
@ -0,0 +1,93 @@
|
||||
---
|
||||
- debug: msg="START cli/set_name_servers.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip name-server
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure name_servers
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
- 3.3.3.3
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result.commands|length == 3
|
||||
- "'ip name-server 1.1.1.1' in result.commands"
|
||||
- "'ip name-server 2.2.2.2' in result.commands"
|
||||
- "'ip name-server 3.3.3.3' in result.commands"
|
||||
|
||||
- name: verify name_servers
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
- 3.3.3.3
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
#- name: change to vrf
|
||||
# eos_system:
|
||||
# name_servers:
|
||||
# - 1.1.1.1
|
||||
# - { server: 2.2.2.2, vrf: ansible }
|
||||
# - 3.3.3.3
|
||||
# provider: "{{ cli }}"
|
||||
# register: result
|
||||
|
||||
#- assert:
|
||||
# that:
|
||||
# - result.changed == true
|
||||
# - result.commands|length == 2
|
||||
# - "'no ip name-server 2.2.2.2' in result.commands"
|
||||
# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands"
|
||||
|
||||
#- name: verify change to vrf
|
||||
# eos_system:
|
||||
# name_servers:
|
||||
# - 1.1.1.1
|
||||
# - { server: 2.2.2.2, vrf: ansible }
|
||||
# - 3.3.3.3
|
||||
# provider: "{{ cli }}"
|
||||
# register: result
|
||||
#
|
||||
#- assert:
|
||||
# that:
|
||||
# - result.changed == false
|
||||
|
||||
- name: remove one
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result.commands|length == 1
|
||||
- "'no ip name-server 3.3.3.3' in result.commands"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_name_servers.yaml"
|
@ -0,0 +1,122 @@
|
||||
---
|
||||
- debug: msg="START eapi/set_domain_list.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure domain_list
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list ansible.com' in result.commands"
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify domain_list
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: add one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: verify add one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: add and remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- eng.ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain-list redhat.com' in result.commands"
|
||||
- "'ip domain-list eng.ansible.com' in result.commands"
|
||||
- result.commands|length == 2
|
||||
|
||||
- name: verify add and remove one entry
|
||||
eos_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- eng.ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
- no ip domain-list eng.ansible.com
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eapi/set_domain_list.yaml"
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
- debug: msg="START eapi/set_domain_name.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines: no ip domain-name
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure domain_name
|
||||
eos_system:
|
||||
domain_name: eng.ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify domain_name
|
||||
eos_system:
|
||||
domain_name: eng.ansible.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines: no ip domain-name
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eapi/set_domain_name.yaml"
|
@ -0,0 +1,36 @@
|
||||
---
|
||||
- debug: msg="START eapi/set_hostname.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines: hostname switch
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure hostname
|
||||
eos_system:
|
||||
hostname: foo
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify hostname
|
||||
eos_system:
|
||||
hostname: foo
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines: "hostname {{ inventory_hostname }}"
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eapi/set_hostname.yaml"
|
@ -0,0 +1,68 @@
|
||||
---
|
||||
- debug: msg="START eapi/set_lookup_source.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure lookup_source
|
||||
eos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain lookup source-interface Management1' in result.commands"
|
||||
|
||||
- name: verify lookup_source
|
||||
eos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: change to vrf
|
||||
eos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'no ip domain lookup source-interface Management1' in result.commands"
|
||||
- "'ip domain lookup vrf ansible source-interface Management1' in result.commands"
|
||||
- result.commands|length == 2
|
||||
|
||||
- name: verify change to vrf
|
||||
eos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eapi/set_lookup_source.yaml"
|
@ -0,0 +1,93 @@
|
||||
---
|
||||
- debug: msg="START eapi/set_name_servers.yaml"
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip name-server
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure name_servers
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
- 3.3.3.3
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result.commands|length == 3
|
||||
- "'ip name-server 1.1.1.1' in result.commands"
|
||||
- "'ip name-server 2.2.2.2' in result.commands"
|
||||
- "'ip name-server 3.3.3.3' in result.commands"
|
||||
|
||||
- name: verify name_servers
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
- 3.3.3.3
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
#- name: change to vrf
|
||||
# eos_system:
|
||||
# name_servers:
|
||||
# - 1.1.1.1
|
||||
# - { server: 2.2.2.2, vrf: ansible }
|
||||
# - 3.3.3.3
|
||||
# provider: "{{ eapi }}"
|
||||
# register: result
|
||||
|
||||
#- assert:
|
||||
# that:
|
||||
# - result.changed == true
|
||||
# - result.commands|length == 2
|
||||
# - "'no ip name-server 2.2.2.2' in result.commands"
|
||||
# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands"
|
||||
|
||||
#- name: verify change to vrf
|
||||
# eos_system:
|
||||
# name_servers:
|
||||
# - 1.1.1.1
|
||||
# - { server: 2.2.2.2, vrf: ansible }
|
||||
# - 3.3.3.3
|
||||
# provider: "{{ eapi }}"
|
||||
# register: result
|
||||
|
||||
#- assert:
|
||||
# that:
|
||||
# - result.changed == false
|
||||
|
||||
- name: remove one
|
||||
eos_system:
|
||||
name_servers:
|
||||
- 1.1.1.1
|
||||
- 2.2.2.2
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result.commands|length == 1
|
||||
- "'no ip name-server 3.3.3.3' in result.commands"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eapi/set_name_servers.yaml"
|
Loading…
Reference in New Issue