ansible/test/integration/targets/ios_smoke/tests/cli/common_utils.yaml
David Newswanger 3e8b0487bb
[WIP] Add ios smoke tests (#35972) (#36133)
* added basic ios_smoke files

* added smoke tests for network.common.config

* added tests for network.common.utils

* added remainder of test cases

(cherry picked from commit 01bd9759e3)
2018-02-13 14:06:09 -05:00

160 lines
3.9 KiB
YAML

---
# ios_command -> ComplexList
# ios_interface -> conditional, remove_default_spec
# ios_logging -> validate_ip_address
# ios_l3_interface -> is_netmask, is_masklen, to_subnet, to_netmask, to_masklen
#ComplexList already covered
- debug: msg="START ios_smoke cli/common_utils.yaml on connection={{ ansible_connection }}"
# hit is_netmask(), is_masklen(), to_netmask(), to_masklen()
- name: Delete interface ipv4 and ipv6 address(setup)
ios_l3_interface:
name: "{{ test_interface }}"
state: absent
provider: "{{ cli }}"
register: result
- name: Setup - Ensure interfaces are switchport
ios_config:
lines:
- no shutdown
parents:
- "interface {{ item }}"
provider: "{{ cli }}"
loop:
- "{{ test_interface }}"
- "{{ test_interface2 }}"
- name: Configure interface ipv4 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/24
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 192.168.0.1 255.255.255.0" in result.commands'
- name: test invalid subnet
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/45
state: present
provider: "{{ cli }}"
register: result
ignore_errors: yes
- debug: var=result
- assert:
that:
- 'result.failed == true'
- name: Change ipv4 and ipv6 address using aggregate
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}", ipv4: 193.167.1.1/8, ipv6: "fd5a:12c9:2201:4::4/32" }
- { name: "{{ test_interface2 }}", ipv4: 192.169.2.2/24, ipv6: "fd5b:12c9:2201:5::5/90" }
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 193.167.1.1 255.0.0.0" in result.commands'
- '"ipv6 address fd5a:12c9:2201:4::4/32" in result.commands'
- '"interface {{ test_interface2 }}" in result.commands'
- '"ip address 192.169.2.2 255.255.255.0" in result.commands'
- '"ipv6 address fd5b:12c9:2201:5::5/90" in result.commands'
- name: Delete ipv4 and ipv6 address using aggregate
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}" }
- { name: "{{ test_interface2 }}" }
state: absent
provider: "{{ cli }}"
register: result
# hit validate_ip_address()
- name: Remove host logging - setup
net_logging:
dest: host
name: 172.16.0.1
state: absent
provider: "{{ cli }}"
- name: Remove host logging - teardown
net_logging:
dest: host
name: 172.16.0.1
state: absent
provider: "{{ cli }}"
# hit conditional(), remove_default_spec()
- name: Check intent arguments
ios_interface:
name: "{{ test_interface }}"
state: up
tx_rate: ge(0)
rx_rate: ge(0)
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.failed == false"
- name: Check intent arguments (failed condition)
ios_interface:
name: "{{ test_interface }}"
state: down
tx_rate: gt(0)
rx_rate: lt(0)
provider: "{{ cli }}"
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'state eq(down)' in result.failed_conditions"
- "'tx_rate gt(0)' in result.failed_conditions"
- "'rx_rate lt(0)' in result.failed_conditions"
- name: Config + intent
ios_interface:
name: "{{ test_interface }}"
enabled: False
state: down
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.failed == false"
- name: Config + intent (fail)
ios_interface:
name: "{{ test_interface }}"
enabled: False
provider: "{{ cli }}"
state: up
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'state eq(up)' in result.failed_conditions"
- debug: msg="END ios_smoke cli/common_utils.yaml on connection={{ ansible_connection }}"