Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios_ping test fix #32342

Merged
merged 9 commits into from
Oct 30, 2017
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Ansible Changes By Release
(https://github.com/ansible/ansible/pull/32282)
* ios_interface testfix:
(https://github.com/ansible/ansible/pull/32335)
* Fix ios integration tests:
(https://github.com/ansible/ansible/pull/32342)


<a id="2.4.1"></a>
Expand Down
29 changes: 25 additions & 4 deletions test/integration/targets/ios_ping/tests/cli/ping.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
---
- debug: msg="START cli/ping.yaml"

- ios_command:
commands: show version
authorize: yes
register: show_version_result

- set_fact: management_interface=GigabitEthernet0/0
when: "'Cisco IOS' in show_version_result.stdout[0]"

- set_fact: management_interface=GigabitEthernet1
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"

- name: Get show ip management interface output
ios_command:
commands:
- "show ip interface {{ management_interface }} | include Internet address"
authorize: yes
register: show_ip_interface_result

- name: Extract the IP address from registered output
set_fact: management_ip="{{ show_ip_interface_result.stdout[0].split()[-1].split('/')[0] }}"

- name: expected successful ping
ios_ping: &valid_ip
dest: '8.8.8.8'
dest: '{{ management_ip }}'
authorize: yes
register: esp

- name: unexpected unsuccessful ping
ios_ping: &invalid_ip
dest: '10.255.255.250'
timeout: 45
authorize: yes
register: uup
ignore_errors: yes

- name: unexpected successful ping
ios_ping:
<<: *valid_ip
state: 'absent'
authorize: yes
register: usp
ignore_errors: yes

- name: expected unsuccessful ping
ios_ping:
<<: *invalid_ip
state: 'absent'
authorize: yes
register: eup

- name: assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
- name: setup
ios_config:
lines:
- no ip domain lookup source-interface
- no ip domain lookup source-interface Loopback888
- vrf definition ansible
match: none
authorize: yes

- name: configure lookup_source
ios_system:
lookup_source: Loopback10
lookup_source: Loopback888
authorize: yes
register: result

- assert:
that:
- result.changed == true
- "'ip domain lookup source-interface Loopback10' in result.commands"
- "'ip domain lookup source-interface Loopback888' in result.commands"

- name: verify lookup_source
ios_system:
lookup_source: Loopback10
lookup_source: Loopback888
authorize: yes
register: result

Expand Down Expand Up @@ -84,7 +84,7 @@
- name: teardown
ios_config:
lines:
- no ip domain lookup source-interface
- no ip domain lookup source-interface Loopback888
- no vrf definition ansible
match: none
authorize: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
- name: teardown
ios_config:
lines:
- no ip domain lookup source-interface
- no ip name-server
match: none
authorize: yes

Expand Down
4 changes: 2 additions & 2 deletions test/integration/targets/ios_user/tests/cli/auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

- name: test login
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no show version"
responses:
(?i)password: "pass123"

- name: test login with invalid password (should fail)
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no show version"
responses:
(?i)password: "badpass"
ignore_errors: yes
Expand Down