mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
Integration Tests only: add static route, snmp_user, snapshot and hsrp it cases (#28933)
* add static route and hsrp it cases * add snmp_user and snapshot it * password strength correction * fix typo * add compare snapshot as it is fixed in the code now * skip snapshot tests for titanium * titanium and nxapi conditions added
This commit is contained in:
parent
8ab4412684
commit
c822292347
36 changed files with 525 additions and 4 deletions
|
@ -222,6 +222,42 @@
|
||||||
failed_modules: "{{ failed_modules }} + [ 'nxos_vtp_version' ]"
|
failed_modules: "{{ failed_modules }} + [ 'nxos_vtp_version' ]"
|
||||||
test_failed: true
|
test_failed: true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_snmp_user
|
||||||
|
when: "limit_to in ['*', 'nxos_snmp_user']"
|
||||||
|
rescue:
|
||||||
|
- set_fact:
|
||||||
|
failed_modules: "{{ failed_modules }} + [ 'nxos_snmp_user' ]"
|
||||||
|
test_failed: true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_snapshot
|
||||||
|
when: "limit_to in ['*', 'nxos_snapshot']"
|
||||||
|
rescue:
|
||||||
|
- set_fact:
|
||||||
|
failed_modules: "{{ failed_modules }} + [ 'nxos_snapshot' ]"
|
||||||
|
test_failed: true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_hsrp
|
||||||
|
when: "limit_to in ['*', 'nxos_hsrp']"
|
||||||
|
rescue:
|
||||||
|
- set_fact:
|
||||||
|
failed_modules: "{{ failed_modules }} + [ 'nxos_hsrp' ]"
|
||||||
|
test_failed: true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_static_route
|
||||||
|
when: "limit_to in ['*', 'nxos_static_route']"
|
||||||
|
rescue:
|
||||||
|
- set_fact:
|
||||||
|
failed_modules: "{{ failed_modules }} + [ 'nxos_static_route' ]"
|
||||||
|
test_failed: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- include_role:
|
- include_role:
|
||||||
name: nxos_rollback
|
name: nxos_rollback
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_bgp sanity test"
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_bgp sanity test"
|
||||||
|
|
||||||
- set_fact: neighbor_down_fib_accelerate="true"
|
- set_fact: neighbor_down_fib_accelerate="true"
|
||||||
when: (titanium is defined) and not ((titanium | search('true')))
|
when: not titanium
|
||||||
|
|
||||||
- set_fact: reconnect_interval="55"
|
- set_fact: reconnect_interval="55"
|
||||||
when: (titanium is defined) and not ((titanium | search('true')))
|
when: not titanium
|
||||||
|
|
||||||
- name: "Enable feature BGP"
|
- name: "Enable feature BGP"
|
||||||
nxos_feature:
|
nxos_feature:
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
- set_fact: intname="{{ nxos_int1 }}"
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- set_fact: log_neighbor_changes="enable"
|
- set_fact: log_neighbor_changes="enable"
|
||||||
when: (titanium is defined) and not ((titanium | search('true')))
|
when: not titanium
|
||||||
|
|
||||||
- set_fact: remove_private_as="all"
|
- set_fact: remove_private_as="all"
|
||||||
when: (titanium is defined) and not ((titanium | search('true')))
|
when: not titanium
|
||||||
|
|
||||||
- name: "Enable feature BGP"
|
- name: "Enable feature BGP"
|
||||||
nxos_feature:
|
nxos_feature:
|
||||||
|
|
2
test/integration/targets/nxos_hsrp/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_hsrp/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_hsrp/meta/main.yml
Normal file
2
test/integration/targets/nxos_hsrp/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_hsrp/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_hsrp/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- 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
|
7
test/integration/targets/nxos_hsrp/tasks/main.yaml
Normal file
7
test/integration/targets/nxos_hsrp/tasks/main.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# Use block to ensure that both cli and nxapi tests
|
||||||
|
# will run even if there are failures or errors.
|
||||||
|
- block:
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
always:
|
||||||
|
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_hsrp/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_hsrp/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: collect all nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
4
test/integration/targets/nxos_hsrp/tests/cli/sanity.yaml
Normal file
4
test/integration/targets/nxos_hsrp/tests/cli/sanity.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_hsrp/tests/common/sanity.yaml
|
92
test/integration/targets/nxos_hsrp/tests/common/sanity.yaml
Normal file
92
test/integration/targets/nxos_hsrp/tests/common/sanity.yaml
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_hsrp sanity test"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: "Enable feature hsrp"
|
||||||
|
nxos_feature:
|
||||||
|
feature: hsrp
|
||||||
|
state: enabled
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: "change interface mode"
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- no switchport
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: "configure nxos_hsrp"
|
||||||
|
nxos_hsrp: &configure
|
||||||
|
group: 10
|
||||||
|
version: 2
|
||||||
|
vip: 10.1.1.1
|
||||||
|
priority: 150
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
preempt: enabled
|
||||||
|
auth_type: text
|
||||||
|
auth_string: CISCO
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: "Conf Idempotence"
|
||||||
|
nxos_hsrp: *configure
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- name: "remove nxos_hsrp"
|
||||||
|
nxos_hsrp: &remove
|
||||||
|
group: 10
|
||||||
|
version: 2
|
||||||
|
vip: 10.1.1.1
|
||||||
|
priority: 150
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
preempt: enabled
|
||||||
|
auth_type: text
|
||||||
|
auth_string: CISCO
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Remove Idempotence"
|
||||||
|
nxos_hsrp: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: "remove nxos_hsrp"
|
||||||
|
nxos_hsrp:
|
||||||
|
group: 10
|
||||||
|
version: 2
|
||||||
|
vip: 10.1.1.1
|
||||||
|
priority: 150
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
preempt: enabled
|
||||||
|
auth_type: text
|
||||||
|
auth_string: CISCO
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
state: absent
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: "Disable feature hsrp"
|
||||||
|
nxos_feature:
|
||||||
|
feature: hsrp
|
||||||
|
state: disabled
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_hsrp sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_hsrp/tests/common/sanity.yaml
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_snapshot/meta/main.yml
Normal file
2
test/integration/targets/nxos_snapshot/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_snapshot/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_snapshot/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- 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
|
3
test/integration/targets/nxos_snapshot/tasks/main.yaml
Normal file
3
test/integration/targets/nxos_snapshot/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_snapshot/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_snapshot/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: collect all nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_snapshot/tests/common/sanity.yaml
|
|
@ -0,0 +1,46 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snapshot sanity test"
|
||||||
|
|
||||||
|
- set_fact: snapshot_run="true"
|
||||||
|
- set_fact: snapshot_run="false"
|
||||||
|
when: titanium and (connection.transport | match('nxapi'))
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: create snapshot
|
||||||
|
nxos_snapshot:
|
||||||
|
action: create
|
||||||
|
snapshot_name: test_snapshot1
|
||||||
|
description: Ansible
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: create another snapshot
|
||||||
|
nxos_snapshot:
|
||||||
|
action: create
|
||||||
|
snapshot_name: test_snapshot2
|
||||||
|
description: row
|
||||||
|
section: myshow
|
||||||
|
show_command: show ip interface brief
|
||||||
|
row_id: ROW_intf
|
||||||
|
element_key1: intf-name
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: compare snapshots
|
||||||
|
nxos_snapshot:
|
||||||
|
action: compare
|
||||||
|
snapshot1: test_snapshot1
|
||||||
|
snapshot2: test_snapshot2
|
||||||
|
comparison_results_file: compare_snapshots.txt
|
||||||
|
compare_option: summary
|
||||||
|
path: '.'
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
when: snapshot_run
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: delete snapshot
|
||||||
|
nxos_snapshot:
|
||||||
|
action: delete_all
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snapshot sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_snapshot/tests/common/sanity.yaml
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_snmp_user/meta/main.yml
Normal file
2
test/integration/targets/nxos_snmp_user/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_snmp_user/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_snmp_user/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- 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
|
7
test/integration/targets/nxos_snmp_user/tasks/main.yaml
Normal file
7
test/integration/targets/nxos_snmp_user/tasks/main.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# Use block to ensure that both cli and nxapi tests
|
||||||
|
# will run even if there are failures or errors.
|
||||||
|
- block:
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
always:
|
||||||
|
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_snmp_user/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_snmp_user/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: collect all nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_snmp_user/tests/common/sanity.yaml
|
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_snmp_user sanity test"
|
||||||
|
|
||||||
|
- name: Create snmp user
|
||||||
|
nxos_snmp_user: &create
|
||||||
|
user: ntc
|
||||||
|
group: network-operator
|
||||||
|
authentication: md5
|
||||||
|
pwd: N$tOpe%1
|
||||||
|
privacy: HelloU$er1
|
||||||
|
encrypt: true
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: delete snmp user
|
||||||
|
nxos_snmp_user: &remove
|
||||||
|
user: ntc
|
||||||
|
group: network-operator
|
||||||
|
authentication: md5
|
||||||
|
pwd: Testing1%
|
||||||
|
privacy: HelloU$er1
|
||||||
|
encrypt: true
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Remove Idempotence"
|
||||||
|
nxos_snmp_user: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_snmp_user sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_snmp_user/tests/common/sanity.yaml
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_static_route/meta/main.yml
Normal file
2
test/integration/targets/nxos_static_route/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_static_route/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_static_route/tasks/cli.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- 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
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# Use block to ensure that both cli and nxapi tests
|
||||||
|
# will run even if there are failures or errors.
|
||||||
|
- block:
|
||||||
|
- { include: cli.yaml, tags: ['cli'] }
|
||||||
|
always:
|
||||||
|
- { include: nxapi.yaml, tags: ['nxapi'] }
|
28
test/integration/targets/nxos_static_route/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_static_route/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: collect all nxapi test cases
|
||||||
|
find:
|
||||||
|
paths: "{{ role_path }}/tests/nxapi"
|
||||||
|
patterns: "{{ testcase }}.yaml"
|
||||||
|
register: test_cases
|
||||||
|
|
||||||
|
- name: set test_items
|
||||||
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
|
- name: run test case
|
||||||
|
include: "{{ test_case_to_run }}"
|
||||||
|
with_items: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_static_route/tests/common/sanity.yaml
|
|
@ -0,0 +1,61 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_static_route sanity test"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: create static route
|
||||||
|
nxos_static_route: &configure
|
||||||
|
prefix: "192.168.20.64/24"
|
||||||
|
next_hop: "3.3.3.3"
|
||||||
|
route_name: testing
|
||||||
|
pref: 100
|
||||||
|
tag: 5500
|
||||||
|
vrf: testing
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: "Conf Idempotence"
|
||||||
|
nxos_static_route: *configure
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- name: remove static route
|
||||||
|
nxos_static_route: &remove
|
||||||
|
prefix: "192.168.20.64/24"
|
||||||
|
next_hop: "3.3.3.3"
|
||||||
|
route_name: testing
|
||||||
|
pref: 100
|
||||||
|
tag: 5500
|
||||||
|
vrf: testing
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Remove Idempotence"
|
||||||
|
nxos_static_route: *remove
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: remove static route
|
||||||
|
nxos_static_route:
|
||||||
|
prefix: "192.168.20.64/24"
|
||||||
|
next_hop: "3.3.3.3"
|
||||||
|
route_name: testing
|
||||||
|
pref: 100
|
||||||
|
tag: 5500
|
||||||
|
vrf: testing
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_static_route sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_static_route/tests/common/sanity.yaml
|
|
@ -66,6 +66,7 @@
|
||||||
when: (platform | match("N9K")) and (fretta | search("true"))
|
when: (platform | match("N9K")) and (fretta | search("true"))
|
||||||
|
|
||||||
# Check if platform is titanium
|
# Check if platform is titanium
|
||||||
|
- set_fact: titanium="false"
|
||||||
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
|
- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %}
|
||||||
when: platform | match("N7K")
|
when: platform | match("N7K")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue