Fix ios_interface integration test failure (#33901)

This commit is contained in:
Ganesh Nalawade 2017-12-14 14:17:08 +05:30 committed by GitHub
parent 13937ce772
commit 2a007e2b4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 98 additions and 14 deletions

View file

@ -21,7 +21,7 @@
name: "{{ test_interface }}"
state: up
tx_rate: ge(0)
rx_rate: le(0)
rx_rate: ge(0)
authorize: yes
register: result

View file

@ -1,14 +1,28 @@
---
- debug: msg="START net_interface ios/intent.yaml"
- name: Run show version
ios_command:
commands: show version
authorize: yes
register: show_version_result
- name: Set test interface to GigabitEthernet0/2 if we are on Cisco IOS
set_fact: test_interface=GigabitEthernet0/2
when: "'Cisco IOS' in show_version_result.stdout[0]"
- name: Set test interface to GigabitEthernet2 if we are on Cisco IOS-XE
set_fact: test_interface=GigabitEthernet2
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
- name: Check intent arguments
net_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
state: up
tx_rate: ge(0)
rx_rate: le(0)
rx_rate: ge(0)
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
@ -17,12 +31,11 @@
- name: Check intent arguments (failed condition)
net_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
state: down
tx_rate: gt(0)
rx_rate: lt(0)
authorize: yes
provider: "{{ cli }}"
ignore_errors: yes
register: result
@ -35,11 +48,10 @@
- name: Config + intent
net_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
enabled: False
state: down
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
@ -48,11 +60,10 @@
- name: Config + intent (fail)
net_interface:
name: GigabitEthernet0/2
name: "{{ test_interface }}"
enabled: False
authorize: yes
state: up
provider: "{{ cli }}"
ignore_errors: yes
register: result
@ -61,17 +72,90 @@
- "result.failed == true"
- "'state eq(up)' in result.failed_conditions"
- name: Register show neighbors detail
ios_command:
commands:
- show lldp neighbors
authorize: yes
register: show_lldp_neighbors_result
- block:
- name: Check neighbors intent arguments
net_interface:
name: Gi0/0
neighbors:
- port: eth0
host: netdev
authorize: yes
register: result
- assert:
that:
- "result.failed == false"
- name: Check neighbors intent arguments (failed condition)
net_interface:
name: Gi0/0
neighbors:
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: '"netdev" in show_lldp_neighbors_result.stdout'
- name: Aggregate config + intent (pass)
net_interface:
aggregate:
- name: GigabitEthernet0/2
enabled: True
state: up
- name: "{{ test_interface }}"
enabled: True
state: up
authorize: yes
provider: "{{ cli }}"
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == false"
- block:
- name: Aggregate neighbors intent (pass)
net_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == false"
- name: Aggregate neighbors intent (fail)
net_interface:
aggregate:
- name: Gi0/0
neighbors:
- port: eth0
host: netdev
- port: dummy_port
host: dummy_host
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: "'netdev' in show_lldp_neighbors_result.stdout"