mirror of https://github.com/ansible/ansible.git
nxos: merge nxapi/cli tests - interface, interface_ospf, logging, mtu (#28239)
* refactor nxos_interface * refactor nxos_interface_ospf * refactor nxos_logging * refactor nxos_mtupull/26558/merge
parent
c810a62db9
commit
2f7f23c9ab
@ -1,15 +1,25 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
@ -1,32 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/set_state_absent.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- interface Loopback1
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: set state=absent
|
||||
nxos_interface:
|
||||
interface: Loopback1
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify state=absent
|
||||
nxos_interface:
|
||||
interface: Loopback1
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- debug: msg="END nxapi/set_state_absent.yaml"
|
@ -1,33 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/set_state_present.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- no interface Loopback1
|
||||
provider: "{{ nxapi }}"
|
||||
ignore_errors: yes # Fails if the interface is already absent
|
||||
|
||||
- name: set state=present
|
||||
nxos_interface:
|
||||
interface: Loopback1
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify state=present
|
||||
nxos_interface:
|
||||
interface: Loopback1
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- debug: msg="END nxapi/set_state_present.yaml"
|
@ -1,15 +1,25 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
- set_fact: connection="{{ cli }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
@ -1,15 +1,25 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
@ -1,90 +0,0 @@
|
||||
---
|
||||
- name: Set up console logging
|
||||
nxos_logging:
|
||||
dest: console
|
||||
dest_level: 0
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"logging console 0" in result.commands'
|
||||
|
||||
- name: Set up console logging again (idempotent)
|
||||
nxos_logging:
|
||||
dest: console
|
||||
dest_level: 0
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Delete/disable console logging
|
||||
nxos_logging:
|
||||
dest: console
|
||||
dest_level: 0
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"no logging console" in result.commands'
|
||||
|
||||
- name: Delete/disable console logging (idempotent)
|
||||
nxos_logging:
|
||||
dest: console
|
||||
dest_level: 0
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == false'
|
||||
|
||||
- name: Logfile logging with level
|
||||
nxos_logging:
|
||||
dest: logfile
|
||||
name: test
|
||||
dest_level: 0
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"logging logfile test 0" in result.commands'
|
||||
|
||||
- name: Configure facility with level
|
||||
nxos_logging:
|
||||
facility: daemon
|
||||
facility_level: 0
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"logging level daemon 0" in result.commands'
|
||||
|
||||
- name: remove logging as collection tearDown
|
||||
nxos_logging:
|
||||
aggregate:
|
||||
- { dest: logfile, name: test, dest_level: 0, state: absent }
|
||||
- { facility: daemon, facility_level: 0, state: absent }
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"no logging logfile" in result.commands'
|
||||
- '"no logging level daemon" in result.commands'
|
@ -1,15 +1,25 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
include: "{{ test_case_to_run }} connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
@ -1,66 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/set_mtu.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- no switchport
|
||||
- no mtu
|
||||
parents: interface Ethernet3/1
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure interface mtu
|
||||
nxos_mtu:
|
||||
interface: Ethernet3/1
|
||||
mtu: 2000
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify interface mtu
|
||||
nxos_mtu:
|
||||
interface: Ethernet3/1
|
||||
mtu: 2000
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure invalid (odd) interface mtu
|
||||
nxos_mtu:
|
||||
interface: Ethernet3/1
|
||||
mtu: 2001
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: configure invalid (large) mtu setting
|
||||
nxos_mtu:
|
||||
interface: Ethernet3/1
|
||||
mtu: 100000
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: no mtu
|
||||
parents: interface Ethernet3/1
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/set_mtu.yaml"
|
@ -1,58 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/sysmtu.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: no system jumbomtu
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: configure system mtu
|
||||
nxos_mtu:
|
||||
sysmtu: 2000
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify system mtu
|
||||
nxos_mtu:
|
||||
sysmtu: 2000
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure invalid (odd) system mtu
|
||||
nxos_mtu:
|
||||
sysmtu: 2001
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: configure invalid (large) system mtu setting
|
||||
nxos_mtu:
|
||||
sysmtu: 10000
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: no system jumbomtu
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- debug: msg="END nxapi/sysmtu.yaml"
|
Loading…
Reference in New Issue