1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Nxos fixes (#40117)

* Alter nxos_nxapi tests to test the right thing

* Defend #40027
This commit is contained in:
Nathaniel Case 2018-05-15 11:55:47 -04:00 committed by GitHub
parent caddf863df
commit f04c876ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 8 deletions

View file

@ -43,6 +43,9 @@ class ActionModule(_ActionModule):
socket_path = None
if self._task.args.get('provider', {}).get('transport') == 'nxapi' and self._task.action == 'nxos_nxapi':
return {'failed': True, 'msg': "Transport type 'nxapi' is not valid for '%s' module." % (self._task.action)}
if self._play_context.connection == 'network_cli':
provider = self._task.args.get('provider', {})
if any(provider.values()):

View file

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

View file

@ -1,4 +1,3 @@
---
# Only cli tests for this module since cli is used
# to test nxapi
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -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 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 case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/badtransport.yaml"
- debug: msg="START nxapi/badtransport.yaml"
- name: Sending transport other than cli should fail
nxos_nxapi:
@ -12,6 +12,6 @@
- assert:
that:
- result.failed and result.msg is search('transport')
- result.failed and result.msg is search('Transport')
- debug: msg="END cli/badtransport.yaml"
- debug: msg="END nxapi/badtransport.yaml"

View file

@ -21,7 +21,7 @@
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={}"
include: "{{ test_case_to_run }} ansible_connection=network_cli connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -22,3 +22,9 @@
- assert:
that:
- result.stdout|length == 10
- name: combine with provider
nxos_command:
commands:
- show hostname
provider: "{{ connection | combine({'timeout': 500}) }}"