mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -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
4
test/integration/targets/eos_eapi/defaults/main.yaml
Normal file
4
test/integration/targets/eos_eapi/defaults/main.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
|
2
test/integration/targets/eos_eapi/meta/main.yml
Normal file
2
test/integration/targets/eos_eapi/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_eos_tests
|
17
test/integration/targets/eos_eapi/tasks/cli.yaml
Normal file
17
test/integration/targets/eos_eapi/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
|
||||
|
||||
|
2
test/integration/targets/eos_eapi/tasks/main.yaml
Normal file
2
test/integration/targets/eos_eapi/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
|
@ -0,0 +1,16 @@
|
|||
- debug: msg="START CLI/BADTRANSPORT.YAML"
|
||||
|
||||
- name: Expect transport other than cli to fail
|
||||
eos_eapi:
|
||||
provider: "{{ eapi }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
ignore_errors: yes
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
when: debug
|
||||
|
||||
- assert:
|
||||
that: eos_eapi_output.failed and eos_eapi_output.msg |search('transport')
|
||||
|
||||
- debug: msg="START CLI/BADTRANSPORT.YAML"
|
52
test/integration/targets/eos_eapi/tests/cli/config.yaml
Normal file
52
test/integration/targets/eos_eapi/tests/cli/config.yaml
Normal file
|
@ -0,0 +1,52 @@
|
|||
- debug: msg="START cli/config.yaml"
|
||||
|
||||
|
||||
#----
|
||||
- name: Setup
|
||||
eos_config:
|
||||
lines: no management api http-commands
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
connection: local
|
||||
|
||||
- name: Get running-config
|
||||
eos_command:
|
||||
commands: show running-config
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
- name: Set config
|
||||
eos_eapi:
|
||||
config: "{{ config.stdout[0] }}"
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
- name: Ensure that this triggered a change
|
||||
assert:
|
||||
that:
|
||||
- "config.changed == true"
|
||||
|
||||
#---
|
||||
- name: Get running-config again
|
||||
eos_command:
|
||||
commands: show running-config
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
- name: Set config
|
||||
eos_eapi:
|
||||
config: "{{ config.stdout[0] }}"
|
||||
provider: "{{ cli }}"
|
||||
register: config
|
||||
connection: local
|
||||
|
||||
|
||||
- name: Idempotency check
|
||||
assert:
|
||||
that:
|
||||
- "config.changed == false"
|
||||
|
||||
- debug: msg="END cli/config.yaml"
|
43
test/integration/targets/eos_eapi/tests/cli/configure.yaml
Normal file
43
test/integration/targets/eos_eapi/tests/cli/configure.yaml
Normal file
|
@ -0,0 +1,43 @@
|
|||
- debug: msg="START CLI/CONFIGURE.YAML"
|
||||
|
||||
- name: Change endpoint ports
|
||||
eos_eapi:
|
||||
enable_http: false
|
||||
http_port: 81
|
||||
https_port: 4443
|
||||
enable_local_http: yes
|
||||
local_http_port: 8181
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- name: Expect endpoint ports to be set
|
||||
assert:
|
||||
that:
|
||||
- http_config.stdout[0].httpServer.port == 81
|
||||
- http_config.stdout[0].httpsServer.port == 4443
|
||||
- http_config.stdout[0].localHttpServer.port == 8181
|
||||
|
||||
- name: Change endpoint ports again
|
||||
eos_eapi:
|
||||
http_port: 81
|
||||
https_port: 4443
|
||||
enable_local_http: yes
|
||||
local_http_port: 8181
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="END CLI/CONFIGURE.YAML"
|
50
test/integration/targets/eos_eapi/tests/cli/off.yaml
Normal file
50
test/integration/targets/eos_eapi/tests/cli/off.yaml
Normal file
|
@ -0,0 +1,50 @@
|
|||
- debug: msg="START CLI/OFF.YAML"
|
||||
|
||||
- name: Turn all endpoints off
|
||||
eos_eapi:
|
||||
enable_http: no
|
||||
enable_https: no
|
||||
enable_local_http: no
|
||||
enable_socket: no
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- debug: var=http_config
|
||||
|
||||
- name: Expect all EAPI endpoints to be in off state
|
||||
assert:
|
||||
that:
|
||||
- http_config.stdout[0].httpServer.running == false
|
||||
- http_config.stdout[0].httpsServer.running == false
|
||||
- http_config.stdout[0].localHttpServer.running == false
|
||||
- http_config.stdout[0].unixSocketServer.running == false
|
||||
|
||||
- name: Turn all endpoints off again
|
||||
eos_eapi:
|
||||
enable_http: no
|
||||
enable_https: no
|
||||
enable_local_http: no
|
||||
enable_socket: no
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
when: debug
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="END CLI/OFF.YAML"
|
48
test/integration/targets/eos_eapi/tests/cli/on.yaml
Normal file
48
test/integration/targets/eos_eapi/tests/cli/on.yaml
Normal file
|
@ -0,0 +1,48 @@
|
|||
- debug: msg="START CLI/ON.YAML"
|
||||
|
||||
- name: Turn on all endpoints
|
||||
eos_eapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
enable_local_http: yes
|
||||
enable_socket: yes
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- debug: var=http_config
|
||||
when: debug
|
||||
|
||||
- name: Expect all EAPI endpoints to be in on state
|
||||
assert:
|
||||
that:
|
||||
- http_config.stdout[0].httpServer.running == true
|
||||
- http_config.stdout[0].httpsServer.running == true
|
||||
- http_config.stdout[0].localHttpServer.running == true
|
||||
- http_config.stdout[0].unixSocketServer.running == true
|
||||
|
||||
- name: Turn on all endpoints again
|
||||
eos_eapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
enable_local_http: yes
|
||||
enable_socket: yes
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="START CLI/ON.YAML"
|
39
test/integration/targets/eos_eapi/tests/cli/start.yaml
Normal file
39
test/integration/targets/eos_eapi/tests/cli/start.yaml
Normal file
|
@ -0,0 +1,39 @@
|
|||
- debug: msg="START CLI/START.YAML"
|
||||
|
||||
- name: Set state to started
|
||||
eos_eapi:
|
||||
state: started
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- debug: var=http_config
|
||||
when: debug
|
||||
|
||||
- name: Expect EAPI state is on
|
||||
assert:
|
||||
that: http_config.stdout[0].enabled == true
|
||||
|
||||
- name: Set state to running again
|
||||
eos_eapi:
|
||||
state: started
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
when: debug
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="STOP CLI/START.YAML"
|
39
test/integration/targets/eos_eapi/tests/cli/stop.yaml
Normal file
39
test/integration/targets/eos_eapi/tests/cli/stop.yaml
Normal file
|
@ -0,0 +1,39 @@
|
|||
- debug: msg="START CLI/STOP.YAML"
|
||||
|
||||
- name: Set state to stopped
|
||||
eos_eapi:
|
||||
state: stopped
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- debug: var=http_config
|
||||
when: debug
|
||||
|
||||
- name: Expect EAPI state is off
|
||||
assert:
|
||||
that: http_config.stdout[0].enabled == false
|
||||
|
||||
- name: Set state to stopped again
|
||||
eos_eapi:
|
||||
state: stopped
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- debug: var=eos_eapi_output
|
||||
when: debug
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="STOP CLI/ENABLE.YAML"
|
57
test/integration/targets/eos_eapi/tests/cli/vrf.yaml
Normal file
57
test/integration/targets/eos_eapi/tests/cli/vrf.yaml
Normal file
|
@ -0,0 +1,57 @@
|
|||
- debug: msg="START cli/vrf.yaml"
|
||||
|
||||
|
||||
#----
|
||||
- name: Set invalid VRF
|
||||
eos_eapi:
|
||||
vrf: foobar
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
ignore_errors: true
|
||||
|
||||
- name: Ensure that setting VRF failed
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.failed == true"
|
||||
- "eos_eapi_output.changed == false"
|
||||
- eos_eapi_output.msg == "vrf 'foobar' is not configured"
|
||||
|
||||
#----
|
||||
- name: Set VRF to default
|
||||
eos_eapi:
|
||||
vrf: default
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
- name: Set VRF to default again (idempotent)
|
||||
eos_eapi:
|
||||
vrf: default
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- name: Ensure idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
|
||||
# -----
|
||||
# FIXME Future: Idempotent test
|
||||
# Add in an extra vrt and swap between that and default to ensure idempotency
|
||||
- name: DEBUG show vrf
|
||||
eos_command:
|
||||
commands: show vrf
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
when: false
|
||||
|
||||
#- debug:
|
||||
# msg: "{{ eos_eapi_output }}"
|
||||
|
||||
- debug: msg="END cli/vrf.yaml"
|
36
test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml
Normal file
36
test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml
Normal file
|
@ -0,0 +1,36 @@
|
|||
- debug: msg="START CLI/RESET.YAML"
|
||||
|
||||
- name: Change endpoint ports back to default values
|
||||
eos_eapi:
|
||||
enable_local_http: yes
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- eos_command:
|
||||
commands:
|
||||
- show management api http-commands | json
|
||||
provider: "{{ cli }}"
|
||||
register: http_config
|
||||
connection: local
|
||||
|
||||
- name: Expect endpoint ports to have default port values
|
||||
assert:
|
||||
that:
|
||||
- http_config.stdout[0].httpServer.port == 80
|
||||
- http_config.stdout[0].httpsServer.port == 443
|
||||
- http_config.stdout[0].localHttpServer.port == 8080
|
||||
|
||||
- name: Change endpoint ports back to default values again
|
||||
eos_eapi:
|
||||
enable_local_http: yes
|
||||
provider: "{{ cli }}"
|
||||
register: eos_eapi_output
|
||||
connection: local
|
||||
|
||||
- name: Expect action to be idempotent
|
||||
assert:
|
||||
that:
|
||||
- "eos_eapi_output.changed == false"
|
||||
|
||||
- debug: msg="END CLI/RESET.YAML"
|
Loading…
Add table
Add a link
Reference in a new issue