ansible/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml
Trishna Guha a6be3df24c
Fix nxos_linkagg tests (#36175) (#36222)
(cherry picked from commit 787114462e)
2018-02-15 11:07:18 +05:30

197 lines
4.7 KiB
YAML

---
- debug: msg="START connection={{ ansible_connection }} nxos_linkagg sanity test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- set_fact: testint1="{{ nxos_int1 }}"
- set_fact: testint2="{{ nxos_int2 }}"
- name: "Enable feature LACP"
nxos_feature:
feature: lacp
state: enabled
provider: "{{ connection }}"
ignore_errors: yes
- name: setup - remove config used in test(part1)
nxos_config:
lines:
- no interface port-channel 20
- no interface port-channel 100
provider: "{{ connection }}"
- name: setup - remove config used in test(part2)
nxos_config:
lines:
- no channel-group 20
provider: "{{ connection }}"
parents: "{{ item }}"
ignore_errors: yes
loop:
- "interface {{ testint1 }}"
- "interface {{ testint2 }}"
- name: create linkagg
nxos_linkagg: &create
group: 20
state: present
provider: "{{ connection }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface port-channel 20" in result.commands'
- name: create linkagg(Idempotence)
nxos_linkagg: *create
register: result
- assert:
that:
- 'result.changed == false'
- name: set link aggregation group to members declaratively
nxos_linkagg: &configure_member
group: 20
mode: active
force: True
members:
- "{{ testint1 }}"
- "{{ testint2 }}"
provider: "{{ connection }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ testint1 }}" in result.commands'
- '"channel-group 20 force mode active" in result.commands'
- '"interface {{ testint2 }}" in result.commands'
- '"channel-group 20 force mode active" in result.commands'
- name: set link aggregation group to members(Idempotence)
nxos_linkagg: *configure_member
register: result
- assert:
that:
- 'result.changed == false'
- name: remove link aggregation group from member declaratively
nxos_linkagg: &remove_member
group: 20
mode: active
force: True
members:
- "{{ testint2 }}"
provider: "{{ connection }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ testint1 }}" in result.commands'
- '"no channel-group 20" in result.commands'
- name: remove link aggregation group from member(Idempotence)
nxos_linkagg: *remove_member
register: result
- assert:
that:
- 'result.changed == false'
- name: remove linkagg
nxos_linkagg: &remove
group: 20
state: absent
provider: "{{ connection }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"no interface port-channel 20" in result.commands'
- name: remove linkagg(Idempotence)
nxos_linkagg: *remove
register: result
- assert:
that:
- 'result.changed == false'
- name: create aggregate of linkagg definitions
nxos_linkagg: &create_agg
aggregate:
- { group: 20, min_links: 3 }
- { group: 100, min_links: 4 }
provider: "{{ connection }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface port-channel 20" in result.commands'
- '"lacp min-links 3" in result.commands'
- '"interface port-channel 100" in result.commands'
- '"lacp min-links 4" in result.commands'
- name: create aggregate of linkagg definitions(Idempotence)
nxos_linkagg: *create_agg
register: result
- assert:
that:
- 'result.changed == false'
- name: remove aggregate of linkagg definitions
nxos_linkagg: &remove_agg
aggregate:
- { group: 20, min_links: 3 }
- { group: 100, min_links: 4 }
provider: "{{ connection }}"
state: absent
register: result
- assert:
that:
- 'result.changed == true'
- '"no interface port-channel 20" in result.commands'
- '"no interface port-channel 100" in result.commands'
- name: remove aggregate of linkagg definitions(Idempotence)
nxos_linkagg: *remove_agg
register: result
- assert:
that:
- 'result.changed == false'
- name: teardown - remove config used in test(part1)
nxos_config:
lines:
- no interface port-channel 20
- no interface port-channel 100
provider: "{{ connection }}"
- name: teardown - remove config used in test(part2)
nxos_config:
lines:
- no channel-group 20
provider: "{{ connection }}"
parents: "{{ item }}"
ignore_errors: yes
loop:
- "interface {{ testint1 }}"
- "interface {{ testint2 }}"
- name: "Disable feature LACP"
nxos_feature:
feature: lacp
state: disabled
timeout: 60
provider: "{{ connection }}"
- debug: msg="END connection={{ ansible_connection }} nxos_linkagg sanity test"