Fix for nxos_ospf idempotent issue (#27913)
This commit is contained in:
parent
ef55530d67
commit
14186af558
10 changed files with 127 additions and 1 deletions
|
@ -139,7 +139,7 @@ def main():
|
||||||
existing_list = existing['ospf']
|
existing_list = existing['ospf']
|
||||||
|
|
||||||
candidate = CustomNetworkConfig(indent=3)
|
candidate = CustomNetworkConfig(indent=3)
|
||||||
if state == 'present':
|
if state == 'present' and ospf not in existing_list:
|
||||||
state_present(module, proposed, candidate)
|
state_present(module, proposed, candidate)
|
||||||
if state == 'absent' and ospf in existing_list:
|
if state == 'absent' and ospf in existing_list:
|
||||||
state_absent(module, proposed, candidate)
|
state_absent(module, proposed, candidate)
|
||||||
|
|
|
@ -240,6 +240,15 @@
|
||||||
failed_modules: "{{ failed_modules }} + [ 'nxos_vxlan_vtep' ]"
|
failed_modules: "{{ failed_modules }} + [ 'nxos_vxlan_vtep' ]"
|
||||||
test_failed: true
|
test_failed: true
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- include_role:
|
||||||
|
name: nxos_ospf
|
||||||
|
when: "limit_to in ['*', 'nxos_ospf']"
|
||||||
|
rescue:
|
||||||
|
- set_fact:
|
||||||
|
failed_modules: "{{ failed_modules }} + [ 'nxos_ospf' ]"
|
||||||
|
test_failed: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- include_role:
|
- include_role:
|
||||||
name: nxos_interface_ospf
|
name: nxos_interface_ospf
|
||||||
|
|
2
test/integration/targets/nxos_ospf/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_ospf/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
testcase: "*"
|
2
test/integration/targets/nxos_ospf/meta/main.yml
Normal file
2
test/integration/targets/nxos_ospf/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- prepare_nxos_tests
|
15
test/integration/targets/nxos_ospf/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_ospf/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_ospf/tasks/main.yaml
Normal file
7
test/integration/targets/nxos_ospf/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_ospf/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_ospf/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_ospf/tests/cli/sanity.yaml
Normal file
4
test/integration/targets/nxos_ospf/tests/cli/sanity.yaml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ cli }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml
|
55
test/integration/targets/nxos_ospf/tests/common/sanity.yaml
Normal file
55
test/integration/targets/nxos_ospf/tests/common/sanity.yaml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ospf sanity test"
|
||||||
|
|
||||||
|
- name: "Enable feature OSPF"
|
||||||
|
nxos_feature:
|
||||||
|
feature: ospf
|
||||||
|
state: enabled
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Configure ospf
|
||||||
|
nxos_ospf: &config
|
||||||
|
ospf: 1
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &true
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_ospf: *config
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &false
|
||||||
|
that:
|
||||||
|
- "result.changed == false"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: "Disable feature OSPF"
|
||||||
|
nxos_feature:
|
||||||
|
feature: ospf
|
||||||
|
state: disabled
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Unconfigure ospf
|
||||||
|
nxos_ospf: &unconfig
|
||||||
|
ospf: 1
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_ospf: *unconfig
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ospf sanity test"
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- set_fact: connection="{{ nxapi }}"
|
||||||
|
|
||||||
|
- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml
|
Loading…
Reference in a new issue