Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXOS: Integration tests to Ansible (part 3) #29030

Merged
merged 9 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions test/integration/nxos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,60 @@
failed_modules: "{{ failed_modules }} + [ 'nxos_ip_interface' ]"
test_failed: true

- block:
- include_role:
name: nxos_file_copy
when: "limit_to in ['*', 'nxos_file_copy']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_file_copy' ]"
test_failed: true

- block:
- include_role:
name: nxos_igmp_interface
when: "limit_to in ['*', 'nxos_igmp_interface']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_igmp_interface' ]"
test_failed: true

- block:
- include_role:
name: nxos_igmp
when: "limit_to in ['*', 'nxos_igmp']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_igmp' ]"
test_failed: true

- block:
- include_role:
name: nxos_igmp_snooping
when: "limit_to in ['*', 'nxos_igmp_snooping']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_igmp_snooping' ]"
test_failed: true

- block:
- include_role:
name: nxos_ntp_auth
when: "limit_to in ['*', 'nxos_ntp_auth']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_ntp_auth' ]"
test_failed: true

- block:
- include_role:
name: nxos_ntp_options
when: "limit_to in ['*', 'nxos_ntp_options']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_ntp_options' ]"
test_failed: true

- block:
- include_role:
name: nxos_logging
Expand Down
2 changes: 2 additions & 0 deletions test/integration/targets/nxos_file_copy/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
testcase: "*"
2 changes: 2 additions & 0 deletions test/integration/targets/nxos_file_copy/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests
25 changes: 25 additions & 0 deletions test/integration/targets/nxos_file_copy/tasks/cli.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/integration/targets/nxos_file_copy/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }
38 changes: 38 additions & 0 deletions test/integration/targets/nxos_file_copy/tasks/nxapi.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"
84 changes: 84 additions & 0 deletions test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
- debug: msg="START TRANSPORT:CLI nxos_file_copy sanity test"

- name: "Setup - Remove existing file"
nxos_command: &remove_file
commands:
- terminal dont-ask
- delete nxos.yaml
provider: "{{ cli }}"
ignore_errors: yes

- name: "Setup - Turn on feature scp-server"
nxos_feature:
feature: scp-server
state: enabled
provider: "{{ cli }}"

- block:
- name: "Copy nxos.yaml to bootflash"
nxos_file_copy: &copy_file_same_name
local_file: "./nxos.yaml"
file_system: "bootflash:"
provider: "{{ cli }}"
username: "{{ nxos_cli_user | default('admin') }}"
password: "{{ nxos_cli_pass | default('admin') }}"
host: "{{ inventory_hostname }}"
register: result

- assert: &true
that:
- "result.changed == true"

- name: "Check Idempotence - Copy nxos.yaml to bootflash"
nxos_file_copy: *copy_file_same_name
register: result

- assert: &false
that:
- "result.changed == false"

- name: "Setup - Remove existing file"
nxos_command: *remove_file
register: result

- name: "Copy ios.yaml to bootflash as another name"
nxos_file_copy: &copy_file_different_name
local_file: "./ios.yaml"
remote_file: "nxos.yaml"
file_system: "bootflash:"
provider: "{{ cli }}"
username: "{{ nxos_cli_user | default('admin') }}"
password: "{{ nxos_cli_pass | default('admin') }}"
host: "{{ inventory_hostname }}"
register: result

- assert: *true

- name: "Check Idempotence - Copy ios.yaml to bootflash as another name"
nxos_file_copy: *copy_file_different_name
register: result

- assert: *false

- name: "Setup - Remove existing file"
nxos_command: *remove_file
register: result

rescue:

- debug: msg="TRANSPORT:CLI nxos_file_copy failure detected"

always:

- name: "Remove file"
nxos_command: *remove_file
ignore_errors: yes

- name: "Turn off feature scp-server"
nxos_feature:
feature: scp-server
state: disabled
provider: "{{ cli }}"

- debug: msg="END TRANSPORT:CLI nxos_file_copy sanity test"
88 changes: 88 additions & 0 deletions test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_file_copy sanity test"

- name: "Setup - Remove existing file"
nxos_command: &remove_file
commands:
- command: terminal dont-ask
output: text
- command: delete nxos.yaml
output: text
provider: "{{ nxapi }}"
ignore_errors: yes

- name: "Setup - Turn on feature scp-server"
nxos_feature:
feature: scp-server
state: enabled
provider: "{{ nxapi }}"

- block:
- name: "Copy nxos.yaml to bootflash"
nxos_file_copy: &copy_file_same_name
local_file: "./nxos.yaml"
file_system: "bootflash:"
provider: "{{ nxapi }}"
username: "{{ nxos_nxapi_user | default('admin') }}"
password: "{{ nxos_nxapi_pass | default('admin') }}"
host: "{{ inventory_hostname }}"
register: result

- assert: &true
that:
- "result.changed == true"

- name: "Check Idempotence - Copy nxos.yaml to bootflash"
nxos_file_copy: *copy_file_same_name
register: result

- assert: &false
that:
- "result.changed == false"

- name: "Setup - Remove existing file"
nxos_command: *remove_file
register: result
ignore_errors: yes

- name: "Copy ios.yaml to bootflash as another name"
nxos_file_copy: &copy_file_different_name
local_file: "./ios.yaml"
remote_file: "nxos.yaml"
file_system: "bootflash:"
provider: "{{ nxapi }}"
username: "{{ nxos_nxapi_user | default('admin') }}"
password: "{{ nxos_nxapi_pass | default('admin') }}"
host: "{{ inventory_hostname }}"
register: result

- assert: *true

- name: "Check Idempotence - Copy ios.yaml to bootflash as another name"
nxos_file_copy: *copy_file_different_name
register: result

- assert: *false

- name: "Setup - Remove existing file"
nxos_command: *remove_file
register: result
ignore_errors: yes

rescue:

- debug: msg="TRANSPORT:NXAPI nxos_file_copy failure detected"

always:

- name: "Remove file"
nxos_command: *remove_file
ignore_errors: yes

- name: "Turn off feature scp-server"
nxos_feature:
feature: scp-server
state: disabled
provider: "{{ nxapi }}"

- debug: msg="END TRANSPORT:NXAPI nxos_file_copy sanity test"
16 changes: 13 additions & 3 deletions test/integration/targets/nxos_igmp/tasks/cli.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions test/integration/targets/nxos_igmp/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
# Use block to ensure that both cli and nxapi tests
# will run even if there are failures or errors.
- block:
- { include: cli.yaml, tags: ['cli'] }
always:
- { include: nxapi.yaml, tags: ['nxapi'] }
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }
16 changes: 13 additions & 3 deletions test/integration/targets/nxos_igmp/tasks/nxapi.yaml
Original file line number Diff line number Diff line change
@@ -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 }}"

Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions test/integration/targets/nxos_igmp/tests/cli/sanity.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions test/integration/targets/nxos_igmp/tests/nxapi/sanity.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
testcase: "*"
2 changes: 2 additions & 0 deletions test/integration/targets/nxos_igmp_interface/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests