1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

nxos: merge nxapi/cli tests - evpn_global, evpn_vni, facts, feature (#28237)

* refactor nxos_evpn_global

* refactor nxos_evpn_vni

* refactor nxos_facts

* refactor nxos_feature
This commit is contained in:
David Newswanger 2017-08-17 04:17:14 -04:00 committed by Trishna Guha
parent 5a6f3ebed1
commit ffe51bed96
26 changed files with 151 additions and 519 deletions

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,18 +1,18 @@
--- ---
- debug: msg="START TRANSPORT:CLI nxos_evpn_global sanity test" - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test"
- name: "Setup" - name: "Setup"
nxos_config: &remove_evpn_config nxos_config: &remove_evpn_config
lines: no nv overlay evpn lines: no nv overlay evpn
match: none match: none
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Disable feature nv overlay" - name: "Disable feature nv overlay"
nxos_feature: &disable_feature_nv_overlay nxos_feature: &disable_feature_nv_overlay
feature: nv overlay feature: nv overlay
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- block: - block:
@ -20,13 +20,13 @@
nxos_feature: &enable_feature_nv_overlay nxos_feature: &enable_feature_nv_overlay
feature: nv overlay feature: nv overlay
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Enable nv overlay evpn" - name: "Enable nv overlay evpn"
nxos_evpn_global: &enable_evpn nxos_evpn_global: &enable_evpn
nv_overlay_evpn: true nv_overlay_evpn: true
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: &true - assert: &true
@ -44,7 +44,7 @@
- name: "Disable nv overlay evpn" - name: "Disable nv overlay evpn"
nxos_evpn_global: &disable_evpn nxos_evpn_global: &disable_evpn
nv_overlay_evpn: false nv_overlay_evpn: false
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -58,7 +58,7 @@
when: not (platform | search('N3K')) when: not (platform | search('N3K'))
rescue: rescue:
- debug: msg="TRANSPORT:CLI nxos_evpn_global sanity test - FALURE ENCOUNTERED" - debug: msg="TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test - FALURE ENCOUNTERED"
always: always:
@ -70,4 +70,4 @@
nxos_feature: *disable_feature_nv_overlay nxos_feature: *disable_feature_nv_overlay
ignore_errors: yes ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_evpn_global sanity test" - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_evpn_global sanity test"

View file

@ -1,73 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_evpn_global sanity test"
- name: "Setup"
nxos_config: &remove_evpn_config
lines: no nv overlay evpn
match: none
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Disable feature nv overlay"
nxos_feature: &disable_feature_nv_overlay
feature: nv overlay
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
- block:
- name: "Enable feature nv overlay"
nxos_feature: &enable_feature_nv_overlay
feature: nv overlay
state: enabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Enable nv overlay evpn"
nxos_evpn_global: &enable_evpn
nv_overlay_evpn: true
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "CHECK IDEMPOTENCE - enable nv overlay evpn"
nxos_evpn_global: *enable_evpn
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Disable nv overlay evpn"
nxos_evpn_global: &disable_evpn
nv_overlay_evpn: false
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "CHECK DEMPOTENCE - Disable nv overlay evpn"
nxos_evpn_global: *disable_evpn
register: result
- assert: *false
when: not (platform | search('N3K'))
rescue:
- debug: msg="TRANSPORT:NXAPI nxos_evpn_global sanity test - FALURE ENCOUNTERED"
always:
- name: "Cleanup - Disable nv overlay evpn"
nxos_config: *remove_evpn_config
ignore_errors: yes
- name: "Cleanup - Disable feature nv overlay"
nxos_feature: *disable_feature_nv_overlay
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_evpn_global sanity test"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START TRANSPORT:CLI nxos_evpn_vni sanity test" - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_evpn_vni sanity test"
- name: "Setup" - name: "Setup"
nxos_config: &remove_evpn nxos_config: &remove_evpn
lines: no nv overlay evpn lines: no nv overlay evpn
provider: "{{ cli }}" provider: "{{ connection }}"
match: none match: none
ignore_errors: yes ignore_errors: yes
@ -13,12 +13,12 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
- name: "Enable nv overlay evpn" - name: "Enable nv overlay evpn"
nxos_config: nxos_config:
lines: nv overlay evpn lines: nv overlay evpn
provider: "{{ cli }}" provider: "{{ connection }}"
match: none match: none
- name: "Configure nxos_evpn_vni" - name: "Configure nxos_evpn_vni"
@ -29,7 +29,7 @@
- "5000:10" - "5000:10"
- "4100:100" - "4100:100"
route_target_export: auto route_target_export: auto
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: &true - assert: &true
@ -48,7 +48,7 @@
nxos_evpn_vni: &rvni nxos_evpn_vni: &rvni
vni: 6000 vni: 6000
state: absent state: absent
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -68,7 +68,7 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- debug: msg="END TRANSPORT:CLI nxos_evpn_vni sanity test" - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_evpn_vni sanity test"

View file

@ -1,74 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_evpn_vni sanity test"
- name: "Setup"
nxos_config: &remove_evpn
lines: no nv overlay evpn
provider: "{{ nxapi }}"
match: none
ignore_errors: yes
- block:
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
- name: "Enable nv overlay evpn"
nxos_config:
lines: nv overlay evpn
provider: "{{ nxapi }}"
match: none
- name: "Configure nxos_evpn_vni"
nxos_evpn_vni: &evpn_vni
vni: 6000
route_distinguisher: "60:10"
route_target_import:
- "5000:10"
- "4100:100"
route_target_export: auto
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_evpn_vni: *evpn_vni
register: result
- assert: &false
that:
- "result.changed == false"
- name: "remove nxos_evpn_vni"
nxos_evpn_vni: &rvni
vni: 6000
state: absent
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_evpn_vni: *rvni
register: result
- assert: *false
always:
- name: "Remove nv overlay evpn"
nxos_config: *remove_evpn
ignore_errors: yes
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:NXAPI nxos_evpn_vni sanity test"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,35 +0,0 @@
---
- debug: msg="START cli/all_facts.yaml"
- name: test getting all facts
nxos_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"
- "result.ansible_facts.ansible_net_interfaces is defined"
- "result.ansible_facts.ansible_net_config is defined"
- "result.ansible_facts.ansible_net_model 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"

View file

@ -1,31 +0,0 @@
---
- debug: msg="START cli/not_hardware_facts.yaml"
- name: test not hardware
nxos_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
# FIXME
# - "result.ansible_facts.ansible_net_interfaces.['Ethernet2/15'].mtu > 1" # interfaces
# ... and not present
- "result.ansible_facts.ansible_net_filesystems is not defined"
- debug: msg="END cli/not_hardware_facts.yaml"

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START nxapi/all_facts.yaml" - debug: msg="START {{ connection.transport }}/all_facts.yaml"
- name: test getting all facts - name: test getting all facts
nxos_facts: nxos_facts:
provider: "{{ nxapi }}" provider: "{{ connection }}"
gather_subset: gather_subset:
- all - all
timeout: 60 timeout: 60
@ -33,4 +33,4 @@
- "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memfree_mb > 1"
- "result.ansible_facts.ansible_net_memtotal_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1"
- debug: msg="END nxapi/all_facts.yaml" - debug: msg="END {{ connection.transport }}/all_facts.yaml"

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START cli/default_facts.yaml" - debug: msg="START {{ connection.transport }}/default_facts.yaml"
- name: test getting default facts - name: test getting default facts
nxos_facts: nxos_facts:
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START cli/invalid_subset.yaml" - debug: msg="START {{ connection.transport }}/invalid_subset.yaml"
- name: test invalid subset (foobar) - name: test invalid subset (foobar)
nxos_facts: nxos_facts:
provider: "{{ cli }}" provider: "{{ connection }}"
gather_subset: gather_subset:
- "foobar" - "foobar"
register: result register: result
@ -26,7 +26,7 @@
- name: test subset specified multiple times - name: test subset specified multiple times
nxos_facts: nxos_facts:
provider: "{{ cli }}" provider: "{{ connection }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
- "hardware" - "hardware"
@ -45,4 +45,4 @@
- debug: msg="END cli/invalid_subset.yaml" - debug: msg="END {{ connection.transport }}/invalid_subset.yaml"

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START nxapi/not_hardware_facts.yaml" - debug: msg="START {{ connection.transport }}/not_hardware_facts.yaml"
- name: test not hardware - name: test not hardware
nxos_facts: nxos_facts:
provider: "{{ nxapi }}" provider: "{{ connection }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
timeout: 30 timeout: 30
@ -29,4 +29,4 @@
# ... and not present # ... and not present
- "result.ansible_facts.ansible_net_filesystems is not defined" - "result.ansible_facts.ansible_net_filesystems is not defined"
- debug: msg="END nxapi/not_hardware_facts.yaml" - debug: msg="END {{ connection.transport }}/not_hardware_facts.yaml"

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START TRANSPORT:CLI nxos_facts sanity test" - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_facts sanity test"
- name: "nxos_facts gather hardware facts" - name: "nxos_facts gather hardware facts"
nxos_facts: nxos_facts:
gather_subset: hardware gather_subset: hardware
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -29,7 +29,7 @@
- name: "nxos_facts gather config facts" - name: "nxos_facts gather config facts"
nxos_facts: nxos_facts:
gather_subset: config gather_subset: config
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -52,7 +52,7 @@
gather_subset: gather_subset:
- hardware - hardware
- config - config
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -75,4 +75,4 @@
- "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memfree_mb > 1"
- "result.ansible_facts.ansible_net_memtotal_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1"
- debug: msg="END TRANSPORT:CLI nxos_facts sanity test" - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_facts sanity test"

View file

@ -1,34 +0,0 @@
---
- debug: msg="START nxapi/default_facts.yaml"
- name: test getting default facts
nxos_facts:
provider: "{{ nxapi }}"
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_model is defined" #default
- "result.ansible_facts.ansible_net_interfaces is defined" #interfaces
# FIXME
# - "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 nxapi/default.yaml"

View file

@ -1,48 +0,0 @@
---
- debug: msg="START nxapi/invalid_subset.yaml"
- name: test invalid subset (foobar)
nxos_facts:
provider: "{{ nxapi }}"
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
- "result.msg == 'Bad subset'"
###############
# FIXME Future
# We may in the future want to add a test for
- name: test subset specified multiple times
nxos_facts:
provider: "{{ nxapi }}"
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 nxapi/invalid_subset.yaml"

View file

@ -1,78 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_facts sanity test"
- name: "nxos_facts gather hardware facts"
nxos_facts:
gather_subset: hardware
provider: "{{ nxapi }}"
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"
# Other facts are not present
- "'config' not in result.ansible_facts.ansible_net_gather_subset"
- "'interfaces' not 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"
- name: "nxos_facts gather config facts"
nxos_facts:
gather_subset: config
provider: "{{ nxapi }}"
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"
# Other facts are not present
- "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
- "'interfaces' not in result.ansible_facts.ansible_net_gather_subset"
# Items from those subsets are present
- "result.ansible_facts.ansible_net_config is defined"
- name: "nxos_facts gather config and hardware facts"
nxos_facts:
gather_subset:
- hardware
- config
provider: "{{ nxapi }}"
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"
- "'config' in result.ansible_facts.ansible_net_gather_subset"
# Other facts are not present
- "'interfaces' not in result.ansible_facts.ansible_net_gather_subset"
# Items from those subsets are present
- "result.ansible_facts.ansible_net_filesystems is defined"
- "result.ansible_facts.ansible_net_config 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 TRANSPORT:NXAPI nxos_facts sanity test"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,17 +1,17 @@
--- ---
- debug: msg="START cli/configure.yaml" - debug: msg="START {{ connection.transport }}/configure.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
lines: no feature bgp lines: no feature bgp
match: none match: none
provider: "{{ cli }}" provider: "{{ connection }}"
- name: enable bgp - name: enable bgp
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -22,7 +22,7 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -33,7 +33,7 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -44,7 +44,7 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -55,6 +55,6 @@
nxos_config: nxos_config:
lines: no feature bgp lines: no feature bgp
match: none match: none
provider: "{{ cli }}" provider: "{{ connection }}"
- debug: msg="END cli/configure.yaml" - debug: msg="END {{ connection.transport }}/configure.yaml"

View file

@ -1,10 +1,10 @@
--- ---
- debug: msg="START cli/invalid.yaml" - debug: msg="START {{ connection.transport }}/invalid.yaml"
- name: configure invalid feature name - name: configure invalid feature name
nxos_feature: nxos_feature:
feature: invalid feature: invalid
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -12,4 +12,4 @@
that: that:
- result.failed == true - result.failed == true
- debug: msg="END cli/invalid.yaml" - debug: msg="END {{ connection.transport }}/invalid.yaml"

View file

@ -1,60 +0,0 @@
---
- debug: msg="START nxapi/configure.yaml"
- name: setup
nxos_config:
lines: no feature bgp
match: none
provider: "{{ nxapi }}"
- name: enable bgp
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify bgp
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- name: disable bgp
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify bgp
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
nxos_config:
lines: no feature bgp
match: none
provider: "{{ nxapi }}"
- debug: msg="END nxapi/configure.yaml"

View file

@ -1,15 +0,0 @@
---
- debug: msg="START nxapi/invalid.yaml"
- name: configure invalid feature name
nxos_feature:
feature: invalid
provider: "{{ nxapi }}"
register: result
ignore_errors: yes
- assert:
that:
- result.failed == true
- debug: msg="END nxapi/invalid.yaml"