nxos: merge nxapi/cli tests - acl, acl_interface, banner, bgp (#28234)

* refactored nxos_acl

* refactor nxos_acl_interface

* refactor nxos_banner

* refactor nxos_bgp

* fix typo
This commit is contained in:
David Newswanger 2017-08-17 04:40:54 -04:00 committed by Trishna Guha
parent 2f7f23c9ab
commit 9556e945eb
20 changed files with 139 additions and 492 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:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
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:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,48 +0,0 @@
---
- debug: msg="START TRANSPORT:CLI nxos_acl sanity test"
- name: "Setup: Cleanup possibly existing acl."
nxos_acl: &remove
name: TEST_ACL
seq: 10
state: absent
provider: "{{ cli }}"
ignore_errors: yes
- name: "Configure ACL"
nxos_acl: &configure
name: TEST_ACL
seq: 10
action: permit
proto: tcp
src: 1.1.1.1/24
dest: any
state: present
provider: "{{ cli }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_acl: *configure
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove ACL"
nxos_acl: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_acl: *remove
register: result
- assert: *false
- debug: msg="END TRANSPORT:CLI nxos_acl sanity test"

View file

@ -1,12 +1,12 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_acl sanity test"
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_acl sanity test"
- name: "Setup: Cleanup possibly existing acl."
nxos_acl: &remove
name: TEST_ACL
seq: 10
state: absent
provider: "{{ nxapi }}"
provider: "{{ connection }}"
ignore_errors: yes
- name: "Configure ACL"
@ -31,7 +31,7 @@
syn: 'enable'
time_range: 'ans-range'
state: present
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- assert: &true
@ -58,4 +58,4 @@
- assert: *false
- debug: msg="END TRANSPORT:NXAPI nxos_acl sanity test"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_acl 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:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
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:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
---
- debug: msg="START TRANSPORT:CLI nxos_acl_interface sanity test"
- debug: msg="START TRANSPORT:{{ connection.transport}} nxos_acl_interface sanity test"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
@ -11,7 +11,7 @@
nxos_config: &default
lines:
- "default interface {{ intname }}"
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes
- name: "Setup: Cleanup possibly existing acl"
@ -19,7 +19,7 @@
name: ANSIBLE_ACL
seq: 10
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes
- name: Configure Supporting ACL
@ -30,7 +30,7 @@
proto: tcp
src: 1.1.1.1/24
dest: any
provider: "{{ cli }}"
provider: "{{ connection }}"
- block:
- name: Configure acl interface egress
@ -39,7 +39,7 @@
interface: "{{ intname }}"
direction: egress
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: &true
@ -60,7 +60,7 @@
interface: "{{ intname }}"
direction: ingress
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: *true
@ -77,7 +77,7 @@
interface: "{{ intname }}"
direction: egress
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: *true
@ -94,7 +94,7 @@
interface: "{{ intname }}"
direction: ingress
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: *true
@ -115,4 +115,4 @@
ignore_errors: yes
always:
- debug: msg="END TRANSPORT:CLI nxos_acl_interface sanity test"
- debug: msg="END TRANSPORT:{{ connection.transport}} nxos_acl_interface sanity test"

View file

@ -1,118 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_acl_interface sanity test"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: "Interface selected for this test"
debug: msg="{{ intname }}"
- name: "Setup: Put interface into a default state"
nxos_config: &default
lines:
- "default interface {{ intname }}"
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Setup: Cleanup possibly existing acl"
nxos_acl: &remove
name: ANSIBLE_ACL
seq: 10
state: absent
provider: "{{ nxapi }}"
ignore_errors: yes
- name: Configure Supporting ACL
nxos_acl:
name: ANSIBLE_ACL
seq: 10
action: permit
proto: tcp
src: 1.1.1.1/24
dest: any
provider: "{{ nxapi }}"
- block:
- name: Configure acl interface egress
nxos_acl_interface: &configure_egr
name: ANSIBLE_ACL
interface: "{{ intname }}"
direction: egress
state: present
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence egress"
nxos_acl_interface: *configure_egr
register: result
- assert: &false
that:
- "result.changed == false"
- name: Configure acl interface ingress
nxos_acl_interface: &configure_ingr
name: ANSIBLE_ACL
interface: "{{ intname }}"
direction: ingress
state: present
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence ingress"
nxos_acl_interface: *configure_ingr
register: result
- assert: *false
- name: Cleanup acl interface egress
nxos_acl_interface: &cleanup_egr
name: ANSIBLE_ACL
interface: "{{ intname }}"
direction: egress
state: absent
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence egress cleanup"
nxos_acl_interface: *cleanup_egr
register: result
- assert: *false
- name: Cleanup acl interface ingress
nxos_acl_interface: &cleanup_ingr
name: ANSIBLE_ACL
interface: "{{ intname }}"
direction: ingress
state: absent
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence ingress cleanup"
nxos_acl_interface: *cleanup_ingr
register: result
- assert: *false
rescue:
- name: Put test interface into default state.
nxos_config: *default
ignore_errors: yes
- name: Remove possible configured ACL
nxos_acl: *remove
ignore_errors: yes
always:
- debug: msg="END TRANSPORT:NXAPI nxos_acl_interface 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:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
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:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,45 +0,0 @@
---
- name: setup - remove exec
nxos_banner:
banner: exec
state: absent
provider: "{{ cli }}"
- name: Set exec
nxos_banner:
banner: exec
text: |
this is my exec banner
that has a multiline
string
state: present
provider: "{{ cli }}"
register: result
- debug:
msg: "{{ result }}"
- assert:
that:
- "result.changed == true"
- "'banner exec @\nthis is my exec banner\nthat has a multiline\nstring\n@' in result.commands"
- name: Set exec again (idempotent)
nxos_banner:
banner: exec
text: |
this is my exec banner
that has a multiline
string
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.commands | length == 0"
# FIXME add in tests for everything defined in docs
# FIXME Test state:absent + test:
# FIXME Without powers ensure "privileged mode required"

View file

@ -1,46 +0,0 @@
---
- name: setup - remove motd
nxos_banner:
banner: motd
state: absent
provider: "{{ cli }}"
- name: Set motd
nxos_banner:
banner: motd
text: |
this is my motd banner
that has a multiline
string
state: present
provider: "{{ cli }}"
register: result
- debug:
msg: "{{ result }}"
- assert:
that:
- "result.changed == true"
- "'banner motd @\nthis is my motd banner\nthat has a multiline\nstring\n@' in result.commands"
- name: Set motd again (idempotent)
nxos_banner:
banner: motd
text: |
this is my motd banner
that has a multiline
string
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.commands | length == 0"
# FIXME add in tests for everything defined in docs
# FIXME Test state:absent + test:
# FIXME Without powers ensure "privileged mode required"

View file

@ -3,7 +3,7 @@
nxos_banner:
banner: exec
state: absent
provider: "{{ nxapi }}"
provider: "{{ connection }}"
- name: Set exec
nxos_banner:
@ -13,7 +13,7 @@
that has a multiline
string
state: present
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- debug:
@ -32,7 +32,7 @@
that has a multiline
string
state: present
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- assert:

View file

@ -3,7 +3,7 @@
nxos_banner:
banner: motd
state: absent
provider: "{{ nxapi }}"
provider: "{{ connection }}"
- name: Set motd
nxos_banner:
@ -13,7 +13,7 @@
that has a multiline
string
state: present
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- debug:
@ -32,7 +32,7 @@
that has a multiline
string
state: present
provider: "{{ nxapi }}"
provider: "{{ connection }}"
register: result
- assert:

View file

@ -6,13 +6,13 @@
Junk exec banner
over multiple lines
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
- name: remove exec
nxos_banner:
banner: exec
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- debug:
@ -27,7 +27,7 @@
nxos_banner:
banner: exec
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:

View file

@ -1,41 +0,0 @@
---
- name: Setup
nxos_banner:
banner: exec
text: |
Junk exec banner
over multiple lines
state: present
provider: "{{ nxapi }}"
- name: remove exec
nxos_banner:
banner: exec
state: absent
provider: "{{ nxapi }}"
register: result
- debug:
msg: "{{ result }}"
- assert:
that:
- "result.changed == true"
- "'no banner exec' in result.commands"
- name: remove exec (idempotent)
nxos_banner:
banner: exec
state: absent
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.commands | length == 0"
# FIXME add in tests for everything defined in docs
# FIXME Test state:absent + test:
# FIXME Without powers ensure "privileged mode required"

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:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}"
loop_control:
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:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: test_cases
register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
---
- debug: msg="START TRANSPORT:CLI nxos_bgp sanity test"
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_bgp sanity test"
- set_fact: neighbor_down_fib_accelerate="true"
when: (titanium is defined) and not ((titanium | search('true')))
@ -8,17 +8,17 @@
when: (titanium is defined) and not ((titanium | search('true')))
- name: "Enable feature BGP"
nxos_feature:
nxos_feature:
feature: bgp
state: enabled
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes
- name: "Setup"
nxos_bgp: &remove
asn: 65535
state: absent
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes
register: result
@ -28,7 +28,7 @@
asn: 65535
router_id: 1.1.1.1
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: &true
@ -54,7 +54,7 @@
register: result
- assert: *false
- name: "Configure BGP non defaults"
nxos_bgp: &configure_non_default
asn: 65535
@ -90,9 +90,9 @@
event_history_periodic: size_small
suppress_fib_pending: true
state: present
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence"
@ -106,18 +106,18 @@
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ cli }}"
provider: "{{ connection }}"
rescue:
- name: "Cleanup BGP"
@ -128,8 +128,8 @@
nxos_feature:
feature: bgp
state: disabled
provider: "{{ cli }}"
provider: "{{ connection }}"
ignore_errors: yes
always:
- debug: msg="END TRANSPORT:CLI nxos_bgp sanity test"
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_bgp sanity test"

View file

@ -1,135 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_bgp sanity test"
- set_fact: neighbor_down_fib_accelerate="true"
when: (titanium is defined) and not ((titanium | search('true')))
- set_fact: reconnect_interval="55"
when: (titanium is defined) and not ((titanium | search('true')))
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Setup"
nxos_bgp: &remove
asn: 65535
state: absent
provider: "{{ nxapi }}"
ignore_errors: yes
register: result
- block:
- name: "Configure BGP defaults"
nxos_bgp: &configure_default
asn: 65535
router_id: 1.1.1.1
state: present
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_bgp: *configure_default
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
- name: "Configure BGP non defaults"
nxos_bgp: &configure_non_default
asn: 65535
router_id: 1.1.1.1
bestpath_always_compare_med: true
bestpath_aspath_multipath_relax: true
bestpath_compare_routerid: true
bestpath_cost_community_ignore: true
bestpath_med_confed: true
bestpath_med_missing_as_worst: true
bestpath_med_non_deterministic: true
cluster_id: 10.0.0.1
confederation_id: 99
disable_policy_batching: true
enforce_first_as: false
fast_external_fallover: false
flush_routes: true
graceful_restart_helper: true
graceful_restart_timers_restart: 130
graceful_restart_timers_stalepath_time: 310
isolate: false
log_neighbor_changes: true
maxas_limit: 50
neighbor_down_fib_accelerate: "{{neighbor_down_fib_accelerate|default(omit)}}"
reconnect_interval: "{{reconnect_interval|default(omit)}}"
shutdown: true
timer_bestpath_limit: 255
timer_bgp_hold: 110
timer_bgp_keepalive: 45
event_history_cli: size_medium
event_history_detail: size_large
event_history_events: size_medium
event_history_periodic: size_small
suppress_fib_pending: true
state: present
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *configure_non_default
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
rescue:
- name: "Cleanup BGP"
nxos_bgp: *remove
ignore_errors: yes
- name: "Disable feature bgp"
nxos_feature:
feature: bgp
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
always:
- debug: msg="END TRANSPORT:NXAPI nxos_bgp sanity test"