mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -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
2
test/integration/targets/eos_facts/defaults/main.yaml
Normal file
2
test/integration/targets/eos_facts/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/eos_facts/meta/main.yml
Normal file
2
test/integration/targets/eos_facts/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_eos_tests
|
17
test/integration/targets/eos_facts/tasks/cli.yaml
Normal file
17
test/integration/targets/eos_facts/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
|
||||
|
||||
|
17
test/integration/targets/eos_facts/tasks/eapi.yaml
Normal file
17
test/integration/targets/eos_facts/tasks/eapi.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: collect all eapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/eapi"
|
||||
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/eos_facts/tasks/main.yaml
Normal file
4
test/integration/targets/eos_facts/tasks/main.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: eapi.yaml, tags: ['eapi'] }
|
||||
|
31
test/integration/targets/eos_facts/tests/cli/all_facts.yaml
Normal file
31
test/integration/targets/eos_facts/tests/cli/all_facts.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- debug: msg="START cli/all_facts.yaml"
|
||||
|
||||
|
||||
- name: test getting all facts
|
||||
eos_facts:
|
||||
provider: "{{ cli }}"
|
||||
gather_subset:
|
||||
- all
|
||||
register: result
|
||||
|
||||
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'config' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'hardware' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined"
|
||||
# Check that these facts not only are present, but are valid (positive integers)
|
||||
- "result.ansible_facts.ansible_net_memfree_mb > 1"
|
||||
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
|
||||
|
||||
- debug: msg="END cli/all_facts.yaml"
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- debug: msg="START cli/default_facts.yaml"
|
||||
|
||||
|
||||
- name: test getting default facts
|
||||
eos_facts:
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'hardware' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined"
|
||||
# ... and not present
|
||||
- "'config' not in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined" #hw
|
||||
- "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
|
||||
- "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
|
||||
|
||||
# ... and not present
|
||||
- "result.ansible_facts.ansible_net_config is not defined" # config
|
||||
|
||||
- debug: msg="END cli/default.yaml"
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
- debug: msg="START cli/invalid_subset.yaml"
|
||||
|
||||
|
||||
- name: test invalid subset (foobar)
|
||||
eos_facts:
|
||||
provider: "{{ cli }}"
|
||||
gather_subset:
|
||||
- "foobar"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# Failures shouldn't return changes
|
||||
- "result.changed == false"
|
||||
# It's a failure
|
||||
- "result.failed == true"
|
||||
# Sensible Failure message
|
||||
- "'Subset must be one of' in result.msg"
|
||||
|
||||
###############
|
||||
# FIXME Future
|
||||
# We may in the future want to add a test for
|
||||
|
||||
- name: test subset specified multiple times
|
||||
eos_facts:
|
||||
provider: "{{ cli }}"
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
- "hardware"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# Failures shouldn't return changes
|
||||
- "result.changed == false"
|
||||
# It's a failure
|
||||
- "result.failed == true"
|
||||
# Sensible Failure message
|
||||
#- "result.msg == 'Bad subset'"
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
|
||||
- debug: msg="END cli/invalid_subset.yaml"
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
- debug: msg="START cli/not_hardware_facts.yaml"
|
||||
|
||||
|
||||
- name: test not hardware
|
||||
eos_facts:
|
||||
provider: "{{ cli }}"
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'config' in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
# ... and not present
|
||||
- "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
|
||||
# ... and not present
|
||||
- "result.ansible_facts.ansible_net_filesystems is not defined"
|
||||
|
||||
- debug: msg="END cli/not_hardware_facts.yaml"
|
31
test/integration/targets/eos_facts/tests/eapi/all_facts.yaml
Normal file
31
test/integration/targets/eos_facts/tests/eapi/all_facts.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- debug: msg="START eapi/all_facts.yaml"
|
||||
|
||||
|
||||
- name: test getting all facts
|
||||
eos_facts:
|
||||
provider: "{{ eapi }}"
|
||||
gather_subset:
|
||||
- all
|
||||
register: result
|
||||
|
||||
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'config' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'hardware' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined"
|
||||
# Check that these facts not only are present, but are valid (positive integers)
|
||||
- "result.ansible_facts.ansible_net_memfree_mb > 1"
|
||||
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
|
||||
|
||||
- debug: msg="END eapi/all_facts.yaml"
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- debug: msg="START eapi/default_facts.yaml"
|
||||
|
||||
|
||||
- name: test getting default facts
|
||||
eos_facts:
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'hardware' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined"
|
||||
# ... and not present
|
||||
- "'config' not in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_filesystems is defined" #hw
|
||||
- "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
|
||||
- "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
|
||||
|
||||
# ... and not present
|
||||
- "result.ansible_facts.ansible_net_config is not defined" # config
|
||||
|
||||
- debug: msg="END eapi/default.yaml"
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
- debug: msg="START eapi/invalid_subset.yaml"
|
||||
|
||||
|
||||
- name: test invalid subset (foobar)
|
||||
eos_facts:
|
||||
provider: "{{ eapi }}"
|
||||
gather_subset:
|
||||
- "foobar"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# Failures shouldn't return changes
|
||||
- "result.changed == false"
|
||||
# It's a failure
|
||||
- "result.failed == true"
|
||||
# Sensible Failure message
|
||||
- "'Subset must be one of' in result.msg"
|
||||
|
||||
###############
|
||||
# FIXME Future
|
||||
# We may in the future want to add a test for
|
||||
|
||||
- name: test subset specified multiple times
|
||||
eos_facts:
|
||||
provider: "{{ eapi }}"
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
- "hardware"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# Failures shouldn't return changes
|
||||
- "result.changed == false"
|
||||
# It's a failure
|
||||
- "result.failed == true"
|
||||
# Sensible Failure message
|
||||
#- "result.msg == 'Bad subset'"
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
|
||||
- debug: msg="END eapi/invalid_subset.yaml"
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
- debug: msg="START eapi/not_hardware_facts.yaml"
|
||||
|
||||
|
||||
- name: test not hardware
|
||||
eos_facts:
|
||||
provider: "{{ eapi }}"
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# _facts modules should never report a change
|
||||
- "result.changed == false"
|
||||
|
||||
# Correct subsets are present
|
||||
- "'config' in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
- "'default' in result.ansible_facts.ansible_net_gather_subset"
|
||||
- "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
|
||||
# ... and not present
|
||||
- "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
|
||||
|
||||
# Items from those subsets are present
|
||||
- "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
|
||||
# ... and not present
|
||||
- "result.ansible_facts.ansible_net_filesystems is not defined"
|
||||
|
||||
- debug: msg="END eapi/not_hardware_facts.yaml"
|
Loading…
Add table
Add a link
Reference in a new issue