forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rel240/fix nxos pim interface (ansible#29885)
* fix nxos_pim_interface * Add integration test coverage and fix unit test * Add clarifying comments * Make ansibot happy
- Loading branch information
Showing
12 changed files
with
230 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/integration/targets/nxos_pim_interface/defaults/main.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
testcase: "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
- prepare_nxos_tests |
15 changes: 15 additions & 0 deletions
15
test/integration/targets/nxos_pim_interface/tasks/cli.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 28 additions & 0 deletions
28
test/integration/targets/nxos_pim_interface/tasks/nxapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 4 additions & 0 deletions
4
test/integration/targets/nxos_pim_interface/tests/cli/sanity.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- set_fact: connection="{{ cli }}" | ||
|
||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml" |
102 changes: 102 additions & 0 deletions
102
test/integration/targets/nxos_pim_interface/tests/common/sanity.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_pim_interface sanity test" | ||
|
||
- name: "Disable feature PIM" | ||
nxos_feature: &disable_feature | ||
feature: pim | ||
state: disabled | ||
provider: "{{ connection }}" | ||
|
||
- name: "Enable feature PIM" | ||
nxos_feature: | ||
feature: pim | ||
state: enabled | ||
provider: "{{ connection }}" | ||
|
||
- set_fact: testint="{{ nxos_int1 }}" | ||
|
||
- name: "Setup: Put interface {{ testint }} into a default state" | ||
nxos_config: | ||
lines: | ||
- "default interface {{ testint }}" | ||
provider: "{{ connection }}" | ||
ignore_errors: yes | ||
|
||
- name: "Ensure {{testint}} is layer3" | ||
nxos_interface: | ||
interface: "{{ testint }}" | ||
mode: layer3 | ||
description: 'Configured by Ansible - Layer3' | ||
admin_state: 'up' | ||
state: present | ||
provider: "{{ connection }}" | ||
|
||
- name: Configure nxos_pim_interface state absent | ||
nxos_pim_interface: | ||
interface: "{{ testint }}" | ||
state: absent | ||
provider: "{{ connection }}" | ||
|
||
- block: | ||
- name: configure pim interface | ||
nxos_pim_interface: &config | ||
interface: "{{ testint }}" | ||
dr_prio: 10 | ||
hello_interval: 40 | ||
border: 'false' | ||
neighbor_policy: 'ansible_policy' | ||
neighbor_type: 'prefix' | ||
state: present | ||
provider: "{{ connection }}" | ||
register: result | ||
|
||
- assert: &true | ||
that: | ||
- "result.changed == true" | ||
|
||
- name: Check idempotence | ||
nxos_pim_interface: *config | ||
register: result | ||
|
||
- assert: &false | ||
that: | ||
- "result.changed == false" | ||
|
||
- name: configure gp policy and type | ||
nxos_pim_interface: &configjp | ||
interface: "{{ testint }}" | ||
jp_policy_in: JPIN | ||
jp_policy_out: JPOUT | ||
jp_type_in: routemap | ||
jp_type_out: routemap | ||
provider: "{{ connection }}" | ||
register: result | ||
|
||
- assert: *true | ||
|
||
- name: Check idempotence | ||
nxos_pim_interface: *configjp | ||
register: result | ||
|
||
- assert: *false | ||
|
||
- name: configure state default | ||
nxos_pim_interface: &configdefault | ||
interface: "{{ testint }}" | ||
state: default | ||
provider: "{{ connection }}" | ||
register: result | ||
|
||
- assert: *true | ||
|
||
- name: Check idempotence | ||
nxos_pim_interface: *configdefault | ||
register: result | ||
|
||
- assert: *false | ||
|
||
always: | ||
- name: "Disable feature PIM" | ||
nxos_feature: *disable_feature | ||
|
||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_pim_interface sanity test" |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/nxos_pim_interface/tests/nxapi/sanity.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- set_fact: connection="{{ nxapi }}" | ||
|
||
- import_tasks: "{{ role_path }}/tests/common/sanity.yaml" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters