nxos: merge nxapi/cli tests - interface, interface_ospf, logging, mtu (#28239)

* refactor nxos_interface

* refactor nxos_interface_ospf

* refactor nxos_logging

* refactor nxos_mtu
pull/26558/merge
David Newswanger 7 years ago committed by Trishna Guha
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,10 +1,20 @@
---
- name: collect all nxapi test cases
- name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -1,17 +1,17 @@
---
- debug: msg="START cli/set_state_absent.yaml"
- debug: msg="START {{ connection.transport }}/set_state_absent.yaml"
- name: setup
nxos_config:
lines:
- interface Loopback1
provider: "{{ cli }}"
provider: "{{ connection }}"
- name: set state=absent
nxos_interface:
interface: Loopback1
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -22,11 +22,11 @@
nxos_interface:
interface: Loopback1
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END cli/set_state_absent.yaml"
- debug: msg="END {{ connection.transport }}/set_state_absent.yaml"

@ -1,18 +1,18 @@
---
- debug: msg="START cli/set_state_present.yaml"
- debug: msg="START {{ connection.transport }}/set_state_present.yaml"
- name: setup
nxos_config:
lines:
- no interface Loopback1
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes # Fails if the interface is already absent
- name: set state=present
nxos_interface:
interface: Loopback1
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -23,11 +23,11 @@
nxos_interface:
interface: Loopback1
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END cli/set_state_present.yaml"
- debug: msg="END {{ connection.transport }}/set_state_present.yaml"

@ -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,10 +1,20 @@
---
- name: collect all nxapi test cases
- name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
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,10 +1,20 @@
---
- name: collect all nxapi test cases
- name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -4,7 +4,7 @@
dest: console
dest_level: 0
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -17,7 +17,7 @@
dest: console
dest_level: 0
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -29,7 +29,7 @@
dest: console
dest_level: 0
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -42,7 +42,7 @@
dest: console
dest_level: 0
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -55,7 +55,7 @@
name: test
dest_level: 0
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -67,7 +67,7 @@
nxos_logging:
facility: daemon
facility_level: 0
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -80,7 +80,7 @@
aggregate:
- { dest: logfile, name: test, dest_level: 0, state: absent }
- { facility: daemon, facility_level: 0, state: absent }
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:

@ -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,10 +1,20 @@
---
- name: collect all nxapi test cases
- name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
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,5 +1,5 @@
---
- debug: msg="START nxapi/set_mtu.yaml"
- debug: msg="START {{ connection.transport }}/set_mtu.yaml"
- name: setup
nxos_config:
@ -8,13 +8,13 @@
- no mtu
parents: interface Ethernet3/1
match: none
provider: "{{ nxapi }}"
provider: "{{ connection }}"
- name: configure interface mtu
nxos_mtu:
interface: Ethernet3/1
mtu: 2000
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- assert:
@ -25,7 +25,7 @@
nxos_mtu:
interface: Ethernet3/1
mtu: 2000
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- assert:
@ -36,7 +36,7 @@
nxos_mtu:
interface: Ethernet3/1
mtu: 2001
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
ignore_errors: yes
@ -48,7 +48,7 @@
nxos_mtu:
interface: Ethernet3/1
mtu: 100000
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
ignore_errors: yes
@ -61,6 +61,6 @@
lines: no mtu
parents: interface Ethernet3/1
match: none
provider: "{{ nxapi }}"
provider: "{{ connection }}"
- debug: msg="END nxapi/set_mtu.yaml"
- debug: msg="END {{ connection.transport }}/set_mtu.yaml"

@ -1,16 +1,16 @@
---
- debug: msg="START cli/sysmtu.yaml"
- debug: msg="START {{ connection.transport }}/sysmtu.yaml"
- name: setup
nxos_config:
lines: no system jumbomtu
match: none
provider: "{{ cli }}"
provider: "{{ connection }}"
- name: configure system mtu
nxos_mtu:
sysmtu: 2000
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -20,7 +20,7 @@
- name: verify system mtu
nxos_mtu:
sysmtu: 2000
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -30,7 +30,7 @@
- name: configure invalid (odd) system mtu
nxos_mtu:
sysmtu: 2001
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
ignore_errors: yes
@ -41,7 +41,7 @@
- name: configure invalid (large) system mtu setting
nxos_mtu:
sysmtu: 10000
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
ignore_errors: yes
@ -53,6 +53,6 @@
nxos_config:
lines: no system jumbomtu
match: none
provider: "{{ cli }}"
provider: "{{ connection }}"
- debug: msg="END cli/sysmtu.yaml"
- debug: msg="END {{ connection.transport }}/sysmtu.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…
Cancel
Save