NXOS Commit Integration tests to Ansible (part 2) (#28939)

* add nxos_aaa_server IT

* add nxos_aaa_server_host ITs

* Add nxos_gir IT

* Add nxos_gir_profile_management IT

* add newly added tests to nxos.yaml

* fix nxos.yaml indentation

* fix indentation again

* skip nxos_git_profile_management IT for titanium

* change idempotency to non-idempotency check
This commit is contained in:
rahushen 2017-12-15 23:11:49 -05:00 committed by Trishna Guha
parent 571f878817
commit a130549ead
27 changed files with 991 additions and 0 deletions

View file

@ -374,6 +374,42 @@
failed_modules: "{{ failed_modules }} + [ 'nxos_ip_interface' ]"
test_failed: true
- block:
- include_role:
name: nxos_aaa_server
when: "limit_to in ['*', 'nxos_aaa_server']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_aaa_server' ]"
test_failed: true
- block:
- include_role:
name: nxos_aaa_server_host
when: "limit_to in ['*', 'nxos_aaa_server_host']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_aaa_server_host' ]"
test_failed: true
- block:
- include_role:
name: nxos_gir
when: "limit_to in ['*', 'nxos_gir']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_gir' ]"
test_failed: true
- block:
- include_role:
name: nxos_gir_profile_management
when: "limit_to in ['*', 'nxos_gir_profile_management']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_gir_profile_management' ]"
test_failed: true
- block:
- include_role:
name: nxos_file_copy

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,25 @@
---
- 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: 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 }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -0,0 +1,38 @@
---
- 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: 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 }}"
- name: enable nxapi
nxos_config:
lines:
- feature nxapi
- nxapi http port 80
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable nxapi
nxos_config:
lines:
- no feature nxapi
provider: "{{ cli }}"

View file

@ -0,0 +1,95 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_aaa_server radius.yaml sanity test"
- name: "Setup"
nxos_aaa_server: &remove
server_type: radius
deadtime: default
server_timeout: default
directed_request: default
state: default
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: "Configure radius server defaults"
nxos_aaa_server: &configure_default_radius
server_type: radius
state: present
provider: "{{ connection }}"
register: result
- name: "Check Idempotence"
nxos_aaa_server: *configure_default_radius
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Configure radius server non defaults"
nxos_aaa_server: &configure_radius_non_default
server_type: radius
server_timeout: 9
deadtime: 20
directed_request: enabled
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_aaa_server: *configure_radius_non_default
register: result
- assert: *false
- name: "Remove radius server configuration"
nxos_aaa_server: *remove
register: result
- assert: *true
- name: "Configure radius server with global key"
nxos_aaa_server: &configure_radius_global_key
server_type: radius
encrypt_type: 7
global_key: test_key
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server: *configure_radius_global_key
register: result
- assert: *false
- name: "Remove radius server configuration"
nxos_aaa_server:
server_type: radius
deadtime: default
server_timeout: default
global_key: default
directed_request: default
state: default
provider: "{{ connection }}"
register: result
- assert: *true
rescue:
- debug: msg="TRANSPORT:{{ connection.transport }} nxos_aaa_server failure detected"
always:
- name: "Remove radius server configuration"
nxos_aaa_server: *remove
register: result
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_aaa_server radius.yaml sanity test"

View file

@ -0,0 +1,101 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_aaa_server tacacs.yaml sanity test"
- name: "Enable feature tacacs+"
nxos_feature:
feature: tacacs+
state: enabled
provider: "{{ connection }}"
- name: "Setup"
nxos_aaa_server: &remove
server_type: tacacs
deadtime: default
server_timeout: default
directed_request: default
state: default
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: "Configure tacacs server defaults"
nxos_aaa_server: &configure_default_tacacs
server_type: tacacs
state: present
provider: "{{ connection }}"
register: result
- name: "Check Idempotence"
nxos_aaa_server: *configure_default_tacacs
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Configure tacacs server non defaults"
nxos_aaa_server: &configure_tacacs_non_default
server_type: tacacs
server_timeout: 9
deadtime: 20
directed_request: enabled
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_aaa_server: *configure_tacacs_non_default
register: result
- assert: *false
- name: "Remove tacacs server configuration"
nxos_aaa_server: *remove
register: result
- assert: *true
- name: "Configure tacacs server with global key"
nxos_aaa_server: &configure_tacacs_global_key
server_type: tacacs
encrypt_type: 7
global_key: test_key
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server: *configure_tacacs_global_key
register: result
- assert: *false
- name: "Remove tacacs server configuration"
nxos_aaa_server: *remove
register: result
- assert: *true
rescue:
- debug: msg="TRANSPORT:{{ connection.transport }} nxos_aaa_server failure detected"
always:
- name: "Remove tacacs server configuration"
nxos_aaa_server: *remove
register: result
- name: "Disable feature tacacs+"
nxos_feature:
feature: tacacs+
state: disabled
provider: "{{ connection }}"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_aaa_server tacacs.yaml sanity test"

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,25 @@
---
- 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: 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 }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -0,0 +1,38 @@
---
- 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: 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 }}"
- name: enable nxapi
nxos_config:
lines:
- feature nxapi
- nxapi http port 80
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable nxapi
nxos_config:
lines:
- no feature nxapi
provider: "{{ cli }}"

View file

@ -0,0 +1,128 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_aaa_server_host radius.yaml sanity test"
- name: "Setup"
nxos_aaa_server_host: &remove
server_type: radius
address: 8.8.8.8
state: absent
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: "Configure radius server defaults"
nxos_aaa_server_host: &configure_default_radius
server_type: radius
address: 8.8.8.8
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_default_radius
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove radius server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *remove
register: result
- assert: *false
- name: "Configure radius server non defaults"
nxos_aaa_server_host: &configure_radius_non_default
server_type: radius
address: 8.8.8.8
host_timeout: 25
auth_port: 2083
acct_port: 2084
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_radius_non_default
register: result
- assert: *false
- name: "Remove radius server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Configure radius server with clear text pwd"
nxos_aaa_server_host: &configure_radius_clear_text
server_type: radius
address: 8.8.8.8
host_timeout: 25
auth_port: 2083
acct_port: 2084
encrypt_type: 0
key: hello
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check NOT Idempotent"
nxos_aaa_server_host: *configure_radius_clear_text
register: result
- assert: *true
- name: "Remove radius server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Configure radius server with type 7 encryption"
nxos_aaa_server_host: &configure_radius_type7
server_type: radius
address: 8.8.8.8
host_timeout: 25
auth_port: 2083
acct_port: 2084
encrypt_type: 7
key: hello
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_radius_type7
register: result
- assert: *true
rescue:
- debug: msg="TRANSPORT:{{ connection.transport }} nxos_aaa_server_host failure detected"
always:
- name: "Remove radius server configuration"
nxos_aaa_server_host: *remove
register: result
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_aaa_server_host radius.yaml sanity test"

View file

@ -0,0 +1,138 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_aaa_server_host tacacs.yaml sanity test"
- name: "Enable feature tacacs+"
nxos_feature:
feature: tacacs+
state: enabled
provider: "{{ connection }}"
- name: "Setup"
nxos_aaa_server_host: &remove
server_type: tacacs
address: 8.8.8.8
state: absent
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: "Configure tacacs server defaults"
nxos_aaa_server_host: &configure_default_tacacs
server_type: tacacs
address: 8.8.8.8
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_default_tacacs
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove tacacs server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *remove
register: result
- assert: *false
- name: "Configure tacacs server non defaults"
nxos_aaa_server_host: &configure_tacacs_non_default
server_type: tacacs
address: 8.8.8.8
host_timeout: 25
tacacs_port: 89
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_tacacs_non_default
register: result
- assert: *false
- name: "Remove tacacs server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Configure tacacs server with clear text pwd"
nxos_aaa_server_host: &configure_tacacs_clear_text
server_type: tacacs
address: 8.8.8.8
host_timeout: 25
tacacs_port: 89
encrypt_type: 0
key: hello
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check NOT Idempotent"
nxos_aaa_server_host: *configure_tacacs_clear_text
register: result
- assert: *true
- name: "Remove tacacs server configuration"
nxos_aaa_server_host: *remove
register: result
- assert: *true
- name: "Configure tacacs server with type 7 encryption"
nxos_aaa_server_host: &configure_tacacs_type7
server_type: tacacs
address: 8.8.8.8
host_timeout: 25
tacacs_port: 89
encrypt_type: 7
key: hello
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_aaa_server_host: *configure_tacacs_type7
register: result
- assert: *true
rescue:
- debug: msg="TRANSPORT:{{ connection.transport }} nxos_aaa_server_host failure detected"
always:
- name: "Remove tacacs server configuration"
nxos_aaa_server_host: *remove
register: result
- name: "Enable feature tacacs+"
nxos_feature:
feature: tacacs+
state: disabled
provider: "{{ connection }}"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_aaa_server_host tacacs.yaml sanity test"

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,25 @@
---
- 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: 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 }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -0,0 +1,38 @@
---
- 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: 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 }}"
- name: enable nxapi
nxos_config:
lines:
- feature nxapi
- nxapi http port 80
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable nxapi
nxos_config:
lines:
- no feature nxapi
provider: "{{ cli }}"

View file

@ -0,0 +1,103 @@
#---
#- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_gir sanity test"
#
#- name: "Setup"
# nxos_gir: &setup
# system_mode_maintenance: false
# provider: "{{ connection }}"
# ignore_errors: yes
#
#- block:
# - name: "Put system in maintenance mode"
# nxos_gir: &configure_system_mode_maintenance
# system_mode_maintenance: true
# provider: "{{ connection }}"
# register: result
#
# - assert: &true
# that:
# - "result.changed == true"
#
# - name: "Check Idempotence"
# nxos_gir: *configure_system_mode_maintenance
# register: result
#
# - assert: &false
# that:
# - "result.changed == false"
#
# - name: "Put system back in normal mode"
# nxos_gir: *setup
# register: result
#
# - assert: *true
#
# - name: "Check Idempotence"
# nxos_gir: *setup
# register: result
#
# - assert: *false
#
# - name: "Put system in maintenance mode with reload reset reason"
# nxos_gir:
# system_mode_maintenance: true
# system_mode_maintenance_on_reload_reset_reason: manual_reload
# register: result
#
# - assert: *true
#
# - name: "Remove reload reason"
# nxos_gir: &remove_reason
# system_mode_maintenance_on_reload_reset_reason: manual_reload
# state: absent
# provider: "{{ connection }}"
# register: result
#
# - assert: *true
#
# - name: "Check Idempotence"
# nxos_gir: *remove_reason
# register: result
#
# - assert: *false
#
# - name: "Put system in maintenance mode with timeout"
# nxos_gir:
# system_mode_maintenance: true
# system_mode_maintenance_timeout: 30
# register: result
#
# - assert: *true
#
# - name: "Remove maintenance mode timeout"
# nxos_gir: &remove_timeout
# system_mode_maintenance_timeout: 30
# state: absent
# provider: "{{ connection }}"
# register: result
#
# - assert: *true
#
# - name: "Check Idempotence"
# nxos_gir: *remove_timeout
# register: result
#
# - assert: *false
#
# - name: "Put system back in normal mode"
# nxos_gir: *setup
# register: result
#
# - assert: *true
#
# rescue:
#
# - debug: msg="TRANSPORT:{{ connection.transport }} nxos_gir failure detected"
#
# always:
#
# - name: "Put system back in normal mode"
# nxos_gir: *setup
# register: result
#
# - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_gir sanity test"

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,25 @@
---
- 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: 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 }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -0,0 +1,38 @@
---
- 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: 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 }}"
- name: enable nxapi
nxos_config:
lines:
- feature nxapi
- nxapi http port 80
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable nxapi
nxos_config:
lines:
- no feature nxapi
provider: "{{ cli }}"

View file

@ -0,0 +1,110 @@
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_gir_profile_management sanity test"
- name: "Setup - Remove maintenace mode profiles"
nxos_gir_profile_management: &remove_maintenance
mode: maintenance
state: absent
provider: "{{ connection }}"
ignore_errors: yes
- name: "Setup - Remove normal mode profiles"
nxos_gir_profile_management: &remove_normal
mode: normal
state: absent
provider: "{{ connection }}"
ignore_errors: yes
- name: "Setup - Turn on feature eigrp"
nxos_feature:
feature: eigrp
state: enabled
provider: "{{ connection }}"
ignore_errors: yes
- block:
- name: "Create maintenace mode profile"
nxos_gir_profile_management: &create_maintenance_profile
mode: maintenance
commands:
- router eigrp 11
- isolate
state: present
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence - Create maintenace mode profile"
nxos_gir_profile_management: *create_maintenance_profile
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Create normal mode profile"
nxos_gir_profile_management: &create_normal_profile
mode: normal
commands:
- router eigrp 11
- isolate
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence - Create normal mode profile"
nxos_gir_profile_management: *create_normal_profile
register: result
- assert: *false
- name: "Remove maintenance mode profile"
nxos_gir_profile_management: *remove_maintenance
register: result
- assert: *true
- name: "Check Idempotence - Remove maintenance mode profile"
nxos_gir_profile_management: *remove_maintenance
register: result
- assert: *false
- name: "Remove normal mode profile"
nxos_gir_profile_management: *remove_normal
register: result
- assert: *true
- name: "Check Idempotence - Remove normal mode profile"
nxos_gir_profile_management: *remove_normal
register: result
- assert: *false
when: not (platform | match('N35')) and not titanium
rescue:
- debug: msg="TRANSPORT:{{ connection.transport }} nxos_gir_profile_management failure detected"
always:
- name: "Remove normal mode profile"
nxos_gir_profile_management: *remove_normal
- name: "Remove maintenance mode profile"
nxos_gir_profile_management: *remove_maintenance
- name: "Turn off feature eigrp"
nxos_feature:
feature: eigrp
state: disabled
provider: "{{ connection }}"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_gir_profile_management sanity test"