mirror of https://github.com/ansible/ansible.git
Fix nxos_interface_ospf idempotence issue (#27783)
* Add tests and fix 27167 * Add modify testpull/26323/head
parent
2571fc061e
commit
65cf31e1ce
@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_nxos_tests
|
@ -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'] }
|
@ -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: "{{ role_path }}/tests/common/sanity.yaml"
|
@ -0,0 +1,119 @@
|
||||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_interface_ospf sanity test"
|
||||
|
||||
- set_fact: testint="{{ nxos_int1 }}"
|
||||
|
||||
- name: "Setup - Disable feature OSPF"
|
||||
nxos_feature: &disable
|
||||
feature: ospf
|
||||
state: disabled
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Setup - Enable feature OSPF"
|
||||
nxos_feature: &enable
|
||||
feature: ospf
|
||||
state: enabled
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Put interface into default state"
|
||||
nxos_config: &intdefault
|
||||
lines:
|
||||
- "default interface {{ testint }}"
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Remove switchport config"
|
||||
nxos_config: &removeswitchport
|
||||
commands:
|
||||
- no switchport
|
||||
parents:
|
||||
- "interface {{ testint }}"
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- block:
|
||||
- name: configure ospf interface
|
||||
nxos_interface_ospf: &configure
|
||||
interface: "{{ testint }}"
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
passive_interface: true
|
||||
hello_interval: 15
|
||||
dead_interval: 75
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_interface_ospf: *configure
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Modify properties
|
||||
nxos_interface_ospf: &modify
|
||||
interface: "{{ testint }}"
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 66
|
||||
passive_interface: false
|
||||
hello_interval: 17
|
||||
dead_interval: 70
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_interface_ospf: *modify
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: remove ospf interface config
|
||||
nxos_interface_ospf: &removeconfig
|
||||
interface: "{{ testint }}"
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
passive_interface: true
|
||||
hello_interval: 15
|
||||
dead_interval: 75
|
||||
state: absent
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_interface_ospf: *removeconfig
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: "Disable feature OSPF"
|
||||
nxos_feature: *disable
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Interface cleanup"
|
||||
nxos_config: *intdefault
|
||||
|
||||
rescue:
|
||||
- name: "Disable feature OSPF"
|
||||
nxos_feature: *disable
|
||||
|
||||
- name: "Interface cleanup"
|
||||
nxos_config: *intdefault
|
||||
|
||||
always:
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_interface_ospf sanity test"
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
- set_fact: connection="{{ nxapi }}"
|
||||
|
||||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml"
|
Loading…
Reference in New Issue