mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
Migrate Network Tests into ansible/ansible (#18233)
* Docs Networking tests * Copy networking tests from test-network-modules * Networking transport settings - group_vars * Network playbooks * Debug should be off by default * Update nxos.yaml * Remove items from top level * Use dependencies, not pre-tasks * Remove trailing blank lines * Remove backup files * newlines
This commit is contained in:
parent
4a067c3f50
commit
e0cc7b3415
489 changed files with 13144 additions and 2 deletions
3
test/integration/targets/nxos_nxapi/defaults/main.yaml
Normal file
3
test/integration/targets/nxos_nxapi/defaults/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
|
2
test/integration/targets/nxos_nxapi/meta/main.yml
Normal file
2
test/integration/targets/nxos_nxapi/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
17
test/integration/targets/nxos_nxapi/tasks/cli.yaml
Normal file
17
test/integration/targets/nxos_nxapi/tasks/cli.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
|
4
test/integration/targets/nxos_nxapi/tasks/main.yaml
Normal file
4
test/integration/targets/nxos_nxapi/tasks/main.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- debug: msg="START cli/badtransport.yaml"
|
||||
|
||||
- name: Sending transport other than cli should fail
|
||||
nxos_nxapi:
|
||||
enable_http: no
|
||||
enable_sandbox: no
|
||||
https_port: 9443
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.failed and result.msg | search('transport')
|
||||
|
||||
- debug: msg="END cli/badtransport.yaml"
|
87
test/integration/targets/nxos_nxapi/tests/cli/config.yaml
Normal file
87
test/integration/targets/nxos_nxapi/tests/cli/config.yaml
Normal file
|
@ -0,0 +1,87 @@
|
|||
- debug: msg="START cli/config.yaml"
|
||||
|
||||
|
||||
#----
|
||||
- name: Setup
|
||||
nxos_config:
|
||||
lines: no feature nxapi
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
connection: local
|
||||
|
||||
- name: Get running-config
|
||||
nxos_command:
|
||||
commands: show running-config
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
- name: Set config
|
||||
nxos_nxapi:
|
||||
config: "{{ config.stdout[0] }}"
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
# Triggers the following changes:
|
||||
# "updates": [
|
||||
# "feature nxapi",
|
||||
# "nxapi http port 80",
|
||||
# "no nxapi https",
|
||||
# "no nxapi sandbox"
|
||||
# ],
|
||||
|
||||
- name: Ensure that this triggered a change
|
||||
assert:
|
||||
that:
|
||||
- "config.changed == true"
|
||||
|
||||
#---
|
||||
- name: Get running-config again
|
||||
nxos_command:
|
||||
commands: show running-config
|
||||
provider: "{{ cli }}"
|
||||
register: runningconfig
|
||||
connection: local
|
||||
|
||||
- name: Set config
|
||||
nxos_nxapi:
|
||||
config: "{{ runningconfig.stdout[0] }}"
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
# BUG: The above shouldn't trigger the following updates
|
||||
# Triggers the following changes:
|
||||
# "updates": [
|
||||
# "nxapi http port 80",
|
||||
# "no nxapi https",
|
||||
# "no nxapi sandbox"
|
||||
# ],
|
||||
|
||||
|
||||
|
||||
# DEBUG: Try another time
|
||||
- name: Set config - FIXME, shouldn't need this
|
||||
nxos_nxapi:
|
||||
config: "{{ runningconfig.stdout[0] }}"
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
# BUG: We are still getting changes
|
||||
# Triggers the following changes:
|
||||
# "updates": [
|
||||
# "nxapi http port 80",
|
||||
# "no nxapi https",
|
||||
# "no nxapi sandbox"
|
||||
# ],
|
||||
|
||||
- name: Idempotency check
|
||||
assert:
|
||||
that:
|
||||
- "config.changed == false"
|
||||
# FIXME: https://github.com/ansible/ansible-modules-core/issues/4955
|
||||
ignore_erros: yes
|
||||
|
||||
- debug: msg="END cli/config.yaml"
|
45
test/integration/targets/nxos_nxapi/tests/cli/configure.yaml
Normal file
45
test/integration/targets/nxos_nxapi/tests/cli/configure.yaml
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
- debug: msg="START cli/configure.yaml"
|
||||
|
||||
- name: Setup - put NXAPI in stopped state
|
||||
nxos_nxapi:
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Configure NXAPI
|
||||
nxos_nxapi:
|
||||
enable_http: no
|
||||
enable_sandbox: no
|
||||
enable_https: yes
|
||||
https_port: 9443
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- nxos_command:
|
||||
commands:
|
||||
- show nxapi | json
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Assert configuration changes
|
||||
assert:
|
||||
that:
|
||||
- result.stdout[0].http_port is not defined
|
||||
- result.stdout[0].https_port == 9443
|
||||
- result.stdout[0].sandbox_status == 'Disabled'
|
||||
|
||||
- name: Configure NXAPI again
|
||||
nxos_nxapi:
|
||||
enable_http: no
|
||||
enable_sandbox: no
|
||||
enable_https: yes
|
||||
https_port: 9443
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Assert configuration is idempotent
|
||||
assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
|
||||
- debug: msg="END cli/configure.yaml"
|
46
test/integration/targets/nxos_nxapi/tests/cli/disable.yaml
Normal file
46
test/integration/targets/nxos_nxapi/tests/cli/disable.yaml
Normal file
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
- debug: msg="START cli/disable.yaml"
|
||||
|
||||
- name: Disable NXAPI
|
||||
nxos_nxapi:
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
# delegate_to: "{{ delegate_to }}"
|
||||
|
||||
- debug: var=result
|
||||
when: debug
|
||||
|
||||
- name: Check NXAPI state
|
||||
nxos_command:
|
||||
commands:
|
||||
- show feature | grep nxapi
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
# delegate_to: "{{ delegate_to }}"
|
||||
|
||||
- debug: var=result
|
||||
when: debug
|
||||
|
||||
- name: Assert NXAPI is disabled
|
||||
assert:
|
||||
that:
|
||||
result.stdout[0] | search('disabled')
|
||||
|
||||
- name: Disable NXAPI again
|
||||
nxos_nxapi:
|
||||
state:
|
||||
absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
# delegate_to: "{{ delegate_to }}"
|
||||
|
||||
|
||||
- name: Assert idempotence
|
||||
assert:
|
||||
that:
|
||||
result.changed == false
|
||||
# FIXME https://github.com/ansible/ansible-modules-core/issues/4955
|
||||
ignore_errors: yes
|
||||
|
||||
- debug: msg="END cli/disable.yaml"
|
39
test/integration/targets/nxos_nxapi/tests/cli/enable.yaml
Normal file
39
test/integration/targets/nxos_nxapi/tests/cli/enable.yaml
Normal file
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
- debug: msg="START cli/enable.yaml"
|
||||
|
||||
- name: Setup - put NXAPI in stopped state
|
||||
nxos_nxapi:
|
||||
state: absent
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Enable NXAPI
|
||||
nxos_nxapi:
|
||||
state: started
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Check NXAPI state
|
||||
nxos_command:
|
||||
commands:
|
||||
- show feature | grep nxapi
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Assert NXAPI is enabled
|
||||
assert:
|
||||
that: result.result[0] | search('enabled')
|
||||
|
||||
- name: Enable NXAPI again
|
||||
nxos_nxapi:
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- name: Assert idempotence
|
||||
assert:
|
||||
that:
|
||||
result.changed == false
|
||||
|
||||
|
||||
- debug: msg="END cli/enable.yaml"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue