mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20: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
3
test/integration/targets/junos_config/defaults/main.yaml
Normal file
3
test/integration/targets/junos_config/defaults/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
|
3
test/integration/targets/junos_config/tasks/main.yaml
Normal file
3
test/integration/targets/junos_config/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
|
17
test/integration/targets/junos_config/tasks/netconf.yaml
Normal file
17
test/integration/targets/junos_config/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: collect netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
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
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
interfaces {
|
||||
lo0 {
|
||||
unit 0 {
|
||||
family inet {
|
||||
address 1.1.1.1/32;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
- debug: msg="START netconf/backup.yaml"
|
||||
|
||||
- name: setup
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name {{ inventory_hostname }}
|
||||
- delete interfaces lo0
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- name: delete backup files
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
with_items: "{{backup_files.files|default([])}}"
|
||||
|
||||
- name: configure device with config
|
||||
junos_config:
|
||||
src: basic/config.j2
|
||||
backup: yes
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "backup_files.files is defined"
|
||||
|
||||
- debug: msg="END netconf/backup.yaml"
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- debug: msg="START netconf/bad_action.yaml"
|
||||
|
||||
- name: configure single bad_action command
|
||||
junos_config:
|
||||
lines:
|
||||
- 'invalid system foo'
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- debug: msg="END netconf/bad_action.yaml"
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
- debug: msg="START netconf/invalid.yaml"
|
||||
|
||||
- name: configure single invalid command
|
||||
junos_config:
|
||||
lines:
|
||||
- 'set system foo'
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: configure multiple invalid command
|
||||
junos_config:
|
||||
lines:
|
||||
- 'set system host-name {{ inventory_hostname }}'
|
||||
- 'set system foo'
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- debug: msg="END netconf/invalid.yaml"
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
- debug: msg="START netconf/multiple.yaml"
|
||||
|
||||
- name: setup
|
||||
junos_config:
|
||||
lines:
|
||||
- "set system host-name {{ inventory_hostname }}"
|
||||
- "delete interfaces lo0"
|
||||
provider: "{{ netconf }}"
|
||||
register: test
|
||||
|
||||
- name: configure multiple commands
|
||||
junos_config:
|
||||
lines:
|
||||
- 'set system host-name {{ inventory_hostname }}'
|
||||
- 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
# Ensure host-name *hasn't* been updated
|
||||
- "'host-name;' not in result.diff.prepared"
|
||||
# Ensure interface has *been* updated
|
||||
- "'address 1.1.1.1/32' in result.diff.prepared"
|
||||
|
||||
- name: check multiple commands idempotent
|
||||
junos_config:
|
||||
lines:
|
||||
- 'set system host-name {{ inventory_hostname }}'
|
||||
- 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.diff is not defined"
|
||||
|
||||
- name: teardown
|
||||
junos_config:
|
||||
lines:
|
||||
- "set system host-name {{ inventory_hostname }}"
|
||||
- "delete interfaces lo0"
|
||||
provider: "{{ netconf }}"
|
||||
register: test
|
||||
|
||||
- debug: msg="END netconf/multiple.yaml"
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
- debug: msg="START netconf/single.yaml"
|
||||
|
||||
# Ensure that when we change the hostname to `localhost` we cause a change
|
||||
- name: setup
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name {{ inventory_hostname }}
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: configure single command
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name localhost
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'+ host-name localhost;' in result.diff.prepared"
|
||||
|
||||
- name: check single command idempotent
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name localhost
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name {{ inventory_hostname }}
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
|
||||
- debug: msg="END netconf/single.yaml"
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- debug: msg="START netconf/src_basic.yaml"
|
||||
|
||||
- name: setup
|
||||
junos_config:
|
||||
lines:
|
||||
- set system host-name {{ inventory_hostname }}
|
||||
- delete interfaces lo0
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: configure device with config
|
||||
junos_config:
|
||||
src: basic/config.j2
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
# https://github.com/ansible/ansible-modules-core/issues/4807
|
||||
- "result.updates is not defined"
|
||||
|
||||
- name: check device with config
|
||||
junos_config:
|
||||
src: basic/config.j2
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
# https://github.com/ansible/ansible-modules-core/issues/4807
|
||||
- "result.updates is not defined"
|
||||
|
||||
- debug: msg="END netconf/src_basic.yaml"
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- debug: msg="START netconf/src_invalid.yaml"
|
||||
|
||||
|
||||
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
|
||||
- name: configure with invalid src
|
||||
junos_config:
|
||||
src: basic/foobar.j2
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.failed == true"
|
||||
- "result.msg == 'path specified in src not found'"
|
||||
|
||||
- debug: msg="END netconf/src_invalid.yaml"
|
Loading…
Add table
Add a link
Reference in a new issue