Nxos fixes (#40117)
* Alter nxos_nxapi tests to test the right thing * Defend #40027
This commit is contained in:
parent
caddf863df
commit
f04c876ecd
7 changed files with 43 additions and 8 deletions
|
@ -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()):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'] }
|
||||
|
|
27
test/integration/targets/nxos_nxapi/tasks/nxapi.yaml
Normal file
27
test/integration/targets/nxos_nxapi/tasks/nxapi.yaml
Normal 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
|
|
@ -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"
|
|
@ -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
|
||||
|
|
|
@ -22,3 +22,9 @@
|
|||
- assert:
|
||||
that:
|
||||
- result.stdout|length == 10
|
||||
|
||||
- name: combine with provider
|
||||
nxos_command:
|
||||
commands:
|
||||
- show hostname
|
||||
provider: "{{ connection | combine({'timeout': 500}) }}"
|
||||
|
|
Loading…
Reference in a new issue