Fix for nxos_ospf idempotent issue (#27913)

This commit is contained in:
saichint 2017-08-09 08:25:35 -07:00 committed by Nathaniel Case
parent ef55530d67
commit 14186af558
10 changed files with 127 additions and 1 deletions

View file

@ -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)

View file

@ -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

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View 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

View 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'] }

View 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 }}"

View file

@ -0,0 +1,4 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml

View 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"

View file

@ -0,0 +1,4 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_ospf/tests/common/sanity.yaml