nxos: merge nxapi/cli tests - system, user, vlan, vrf (#28241)
* refactor nxos_system * refactor nxos_user * refactor nxos_vlan * refactor nxos_vrf
This commit is contained in:
parent
ffe51bed96
commit
f2c34d51f2
19 changed files with 137 additions and 241 deletions
|
@ -1,16 +1,25 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
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: test_cases
|
||||
delegate_to: localhost
|
||||
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,19 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
- name: collect common nxapi test cases
|
||||
find:
|
||||
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: test_cases
|
||||
delegate_to: localhost
|
||||
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 }}"
|
||||
|
@ -17,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,16 +1,16 @@
|
|||
---
|
||||
- debug: msg="START cli/set_hostname.yaml"
|
||||
- debug: msg="START {{ connection.transport }}/set_hostname.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: hostname switch
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: configure hostname
|
||||
nxos_system:
|
||||
hostname: foo
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -20,7 +20,7 @@
|
|||
- name: verify hostname
|
||||
nxos_system:
|
||||
hostname: foo
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -31,6 +31,6 @@
|
|||
nxos_config:
|
||||
lines: "hostname {{ inventory_hostname }}"
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- debug: msg="END cli/set_hostname.yaml"
|
||||
- debug: msg="END {{ connection.transport }}/set_hostname.yaml"
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/set_lookup_source.yaml"
|
||||
- debug: msg="START {{ connection.transport }}/set_lookup_source.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
|
@ -7,12 +7,12 @@
|
|||
- no ip domain lookup source-interface
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: configure lookup_source
|
||||
nxos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -23,7 +23,7 @@
|
|||
- name: verify lookup_source
|
||||
nxos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -35,7 +35,7 @@
|
|||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -50,7 +50,7 @@
|
|||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -63,6 +63,6 @@
|
|||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- debug: msg="END cli/set_lookup_source.yaml"
|
||||
- debug: msg="END {{ connection.transport }}/set_lookup_source.yaml"
|
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
- debug: msg="START nxapi/set_hostname.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: hostname switch
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: configure hostname
|
||||
nxos_system:
|
||||
hostname: foo
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: verify hostname
|
||||
nxos_system:
|
||||
hostname: foo
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: "hostname {{ inventory_hostname }}"
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- debug: msg="END nxapi/set_hostname.yaml"
|
|
@ -1,68 +0,0 @@
|
|||
---
|
||||
- debug: msg="START nxapi/set_lookup_source.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: configure lookup_source
|
||||
nxos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain lookup source-interface Management1' in result.commands"
|
||||
|
||||
- name: verify lookup_source
|
||||
nxos_system:
|
||||
lookup_source: Management1
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: change to vrf
|
||||
nxos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ nxapi }}"
|
||||
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
|
||||
nxos_system:
|
||||
lookup_source:
|
||||
- interface: Management1
|
||||
vrf: ansible
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip domain lookup source-interface
|
||||
- no vrf definition ansible
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- debug: msg="END nxapi/set_lookup_source.yaml"
|
|
@ -1,15 +1,25 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
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: test_cases
|
||||
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,9 +1,19 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
- name: collect common nxapi test cases
|
||||
find:
|
||||
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: test_cases
|
||||
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 }}"
|
||||
|
@ -14,10 +24,9 @@
|
|||
- feature nxapi
|
||||
- nxapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
timeout: 100
|
||||
|
||||
- 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
|
||||
|
@ -27,4 +36,3 @@
|
|||
lines:
|
||||
- no feature nxapi
|
||||
provider: "{{ cli }}"
|
||||
timeout: 100
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
|
||||
# Start tests
|
||||
- name: Create user
|
||||
|
@ -14,7 +14,7 @@
|
|||
name: ansibletest1
|
||||
roles: network-operator
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -30,7 +30,7 @@
|
|||
- name: ansibletest3
|
||||
state: present
|
||||
roles: network-admin
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -44,7 +44,7 @@
|
|||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
|
@ -1,53 +0,0 @@
|
|||
---
|
||||
- name: Remove old entries of user
|
||||
nxos_user:
|
||||
aggregate:
|
||||
- name: ansibletest1
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
# Start tests
|
||||
- name: Create user
|
||||
nxos_user:
|
||||
name: ansibletest1
|
||||
roles: network-operator
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"username" in result.commands[0]'
|
||||
- '"role network-operator" in result.commands[1]'
|
||||
|
||||
- name: Collection of users
|
||||
nxos_user:
|
||||
aggregate:
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: present
|
||||
roles: network-admin
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
|
||||
- name: tearDown
|
||||
nxos_user:
|
||||
aggregate:
|
||||
- name: ansibletest1
|
||||
- name: ansibletest2
|
||||
- name: ansibletest3
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"no username" in result.commands[0]'
|
|
@ -1,15 +1,25 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
- name: collect common cli test cases
|
||||
find:
|
||||
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: test_cases
|
||||
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,9 +1,19 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
- name: collect common nxapi test cases
|
||||
find:
|
||||
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: test_cases
|
||||
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: targets/nxos_vlan/tests/common/sanity.yaml
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: targets/nxos_vlan/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/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
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,9 +1,19 @@
|
|||
---
|
||||
- name: collect all nxapi test cases
|
||||
- name: collect common nxapi test cases
|
||||
find:
|
||||
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: test_cases
|
||||
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,15 +0,0 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:CLI nxos_vrf sanity test"
|
||||
|
||||
- name: Ensure ntc VRF exists on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Ensure ntc VRF does not exist on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END TRANSPORT:CLI nxos_vrf sanity test"
|
15
test/integration/targets/nxos_vrf/tests/common/sanity.yaml
Normal file
15
test/integration/targets/nxos_vrf/tests/common/sanity.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vrf sanity test"
|
||||
|
||||
- name: Ensure ntc VRF exists on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: Ensure ntc VRF does not exist on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
state: absent
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vrf sanity test"
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:NXAPI nxos_vrf sanity test"
|
||||
|
||||
- name: Ensure ntc VRF exists on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: Ensure ntc VRF does not exist on switch
|
||||
nxos_vrf:
|
||||
vrf: ntc
|
||||
state: absent
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- debug: msg="END TRANSPORT:NXAPI nxos_vrf sanity test"
|
Loading…
Reference in a new issue