Fix nxos_reload timeout and add integration tests (#49632)

* Fix timeout and add tests

* Correct module name
pull/49912/head
Mike Wiebe 6 years ago committed by Nathaniel Case
parent b47cde9d4c
commit 0e4a7b0889

@ -58,17 +58,15 @@ rebooted:
sample: true
'''
from ansible.module_utils.network.nxos.nxos import run_commands
from ansible.module_utils.network.nxos.nxos import load_config
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
def reboot(module):
cmds = [
{'command': 'terminal dont-ask', 'output': 'text'},
{'command': 'reload', 'output': 'text'}
]
run_commands(module, cmds)
cmds = 'terminal dont-ask ; reload'
opts = {'ignore_timeout': True}
load_config(module, cmds, False, opts)
def main():

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

@ -0,0 +1,27 @@
---
- name: collect common test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
connection: local
register: test_cases
- name: collect cli test cases
find:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
connection: local
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 cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -0,0 +1,5 @@
---
- include: cli.yaml
tags: cli
- include: nxapi.yaml
tags: nxapi

@ -0,0 +1,35 @@
---
- name: collect common test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
connection: local
register: test_cases
- name: collect nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
connection: local
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: run test cases (connection=httpapi)
include: "{{ test_case_to_run }} ansible_connection=httpapi connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: nxapi_httpapi
- name: run test cases (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: nxapi_local

@ -0,0 +1,26 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_reboot sanity test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- debug: msg="***WARNING*** Remove meta end_play to verify this module ***WARNING***"
- meta: end_play
- block:
- name: Reboot Switch
nxos_reboot:
confirm: True
provider: "{{ connection }}"
ignore_errors: yes
always:
- name: Wait for device to come back up
wait_for:
port: 22
state: started
timeout: 600
delay: 60
host: "{{ inventory_hostname }}"
- debug: msg="END connection={{ ansible_connection }} nxos_reboot sanity test"
Loading…
Cancel
Save