Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/integration/labs/inventory.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ ansible_host={{ ansible_host }}
ansible_network_os={{ ansible_network_os | default('cisco.nxos.nxos') }}
ansible_user={{ ansible_user | default('ansible') }}
ansible_ssh_pass={{ ansible_ssh_pass | default('ansible') }}
ansible_connection=ansible.netcommon.network_cli
ansible_network_cli_ssh_type={{ ansible_network_cli_ssh_type | default('libssh') }}
ansible_ssh_port={{ ansible_ssh_port }}
ansible_httpapi_port={{ ansible_http_port }}
ansible_become={{ ansible_become | default(true) }}
ansible_become_password={{ ansible_become_password | default('cisco') }}
ansible_command_timeout=120
ansible_httpapi_con_timeout=120
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
- result.ansible_facts.ansible_net_config is defined
- result.ansible_facts.ansible_net_cpu_utilization is defined
- result.ansible_facts.ansible_net_model is defined
- result.ansible_facts.ansible_net_memfree_mb > 1
- result.ansible_facts.ansible_net_memtotal_mb > 1
- (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0
- (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0

- name: Collect list of available network resources for nxos
register: result
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/nxos_facts/tests/common/sanity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
- "'config' not in result.ansible_facts.ansible_net_gather_subset"
- "'interfaces' not in result.ansible_facts.ansible_net_gather_subset"
- result.ansible_facts.ansible_net_filesystems is defined
- result.ansible_facts.ansible_net_memfree_mb > 1
- result.ansible_facts.ansible_net_memtotal_mb > 1
- (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0
- (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0

- name: Nxos_facts gather configuration facts
register: result
Expand Down Expand Up @@ -45,8 +45,8 @@
- "'interfaces' not in result.ansible_facts.ansible_net_gather_subset"
- result.ansible_facts.ansible_net_filesystems is defined
- result.ansible_facts.ansible_net_config is defined
- result.ansible_facts.ansible_net_memfree_mb > 1
- result.ansible_facts.ansible_net_memtotal_mb > 1
- (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0
- (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0

- name: Nxos_facts gather features facts
register: result
Expand Down
17 changes: 7 additions & 10 deletions tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@

- ansible.builtin.assert:
that:
- result.changed == false
- result.failed == True
- "'Could not resolve hostname' in result.module_stderr"
- result.failed == true
- "'Could not resolve hostname' in result.msg"

# file_pull_timeout > 30s has no effect in this case, since the device
# shell gives up connecting to the bad IP after 30s and the response
Expand All @@ -72,8 +71,8 @@

- ansible.builtin.assert:
that:
- result.changed == false
- result.failed == True
- result.failed == true
- "'Connection timed out' in result.msg"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot call this a fixed test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the result.msg addition in tc.


- ansible.builtin.pause:
seconds: 10
Expand All @@ -94,9 +93,8 @@

- ansible.builtin.assert:
that:
- result.changed == false
- result.failed == True
- "'Too many authentication failures' in result.module_stderr"
- result.failed == true
- "'Too many authentication failures' in result.msg"

- name: Try and copy file using an invalid password
register: result
Expand All @@ -114,9 +112,8 @@

- ansible.builtin.assert:
that:
- result.changed == false
- result.failed == True
- "'Too many authentication failures' in result.module_stderr"
- "'Too many authentication failures' in result.msg"

- ansible.builtin.debug:
msg: END nxos_file_copy negative test
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- "'ip unreachables' in result.commands"
- "'ip address 192.168.10.2/24' in result.commands"
- result.commands|length == 5
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces facts
cisco.nxos.nxos_facts:
Expand All @@ -51,6 +52,7 @@
- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - merged
register: result
Expand All @@ -60,6 +62,7 @@
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'
always:
- name: Teardown sub-interface
ignore_errors: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
- "'no ip address 192.168.10.2/24' in result.commands"
- "'no evpn multisite dci-tracking' in result.commands"
- result.commands|length == 5
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - deleted
register: result
Expand All @@ -83,6 +84,7 @@
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.include_tasks: _remove_config.yaml

Expand Down Expand Up @@ -116,6 +118,7 @@
- "'ip address 192.168.10.2/24' in result.commands"
- "'evpn multisite fabric-tracking' in result.commands"
- result.commands|length == 5
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces facts - merged
cisco.nxos.nxos_facts:
Expand All @@ -127,6 +130,7 @@
- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - merged
register: result
Expand All @@ -136,6 +140,7 @@
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.include_tasks: _remove_config.yaml

Expand Down Expand Up @@ -178,6 +183,7 @@
- address: 192.168.200.2/24
secondary: true
state: replaced
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
Expand All @@ -191,22 +197,26 @@
- "'no ip address 192.168.10.2/24' in result.commands"
- "'no ipv6 redirects' in result.commands"
- result.commands|length == 7
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces post facts
cisco.nxos.nxos_facts: *id003

- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - replaced
register: result
cisco.nxos.nxos_l3_interfaces: *id004
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.include_tasks: _remove_config.yaml

Expand Down Expand Up @@ -254,6 +264,7 @@
cisco.nxos.nxos_l3_interfaces: &id006
config: "{{ overriden_config + mgmt }}"
state: overridden
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
Expand All @@ -270,23 +281,26 @@
- "'evpn multisite dci-tracking' in result.commands"
- "'no ipv6 redirects' in result.commands"
- "'no ip redirects' in result.commands"
- result.commands|length == 14
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces post facts
cisco.nxos.nxos_facts: *id005

- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - overridden
register: result
cisco.nxos.nxos_l3_interfaces: *id006
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Teardown - overdidden
ignore_errors: true
Expand Down Expand Up @@ -325,6 +339,7 @@

- ansible.builtin.assert:
that: "{{ rendered_multi | symmetric_difference(result['rendered']) |length==0 }}"
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces facts from the device and assert that its empty
register: result
Expand All @@ -334,6 +349,7 @@
- name: Make sure that rendered task actually did not make any changes to the device
ansible.builtin.assert:
that: "{{ result['gathered']|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] }}"
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.include_tasks: _remove_config.yaml

Expand All @@ -358,6 +374,7 @@

- ansible.builtin.assert:
that: "{{ parsed_multi | symmetric_difference(result['parsed']) |length==0 }}"
when: ansible_connection != 'ansible.netcommon.httpapi'

when: multiout is not search("Invalid command")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@
- "'ip address 10.1.1.3/24' in result.commands"
- "'no ipv6 redirects' in result.commands"
- "'no ip redirects' in result.commands"
- result.commands|length == 8
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces post facts
cisco.nxos.nxos_facts: *id001

- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - overridden
register: result
Expand All @@ -82,6 +83,7 @@
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'
always:
- name: Teardown
ignore_errors: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- address: 192.168.200.2/24
secondary: true
state: replaced
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
Expand All @@ -73,42 +74,47 @@
- "'ipv6 dhcp relay address 2001:db8::1:abcd' in result.commands"
- "'ip address 192.168.200.2/24 secondary' in result.commands"
- "'no ip address 192.168.10.2/24' in result.commands"
- result.commands|length == 9
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Gather l3_interfaces post facts
cisco.nxos.nxos_facts: *id001

- ansible.builtin.assert:
that:
- result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == []
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Idempotence - replaced
register: result
cisco.nxos.nxos_l3_interfaces: *id002
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- result.changed == false
- result.commands|length == 0
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Replaced with no optional attrs specified
register: result
cisco.nxos.nxos_l3_interfaces: &id003
config:
- name: "{{ subint3 }}"
state: replaced
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- result.changed == true
- "'interface {{ subint3 }}' in result.commands"
- "'no encapsulation dot1q 442' in result.commands"
- "'no ip address 192.168.20.2/24 tag 5' in result.commands"
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- "'ip redirects' in result.commands"
when: platform is match('N[3567]')
when: platform is match('N[3567]') and ansible_connection != 'ansible.netcommon.httpapi'

always:
- name: Teardown sub-interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
ipv4:
- address: 192.0.2.81/28
state: merged
when: ansible_connection != 'ansible.netcommon.httpapi'
tags: base_config

- name: Gather interfaces facts
Expand Down Expand Up @@ -62,16 +63,19 @@
ipv6:
- address: 2001:db8::20/32
tag: 6
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Apply the provided configuration (config to be reverted)
register: result
cisco.nxos.nxos_l3_interfaces:
config: "{{ config_to_revert + mgmt }}"
state: overridden
when: ansible_connection != 'ansible.netcommon.httpapi'

- ansible.builtin.assert:
that:
- result.changed == true
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Revert back to base configuration using facts round trip
register: revert
Expand All @@ -95,13 +99,15 @@
| map('rejectattr', 'key', 'in', ['redirects', 'ipv6_redirects'])
| map('items2dict')
| list }}
when: ansible_connection != 'ansible.netcommon.httpapi'

- name: Assert base and revert configs match for Ethernet1/1 and 1/2 (ignoring redirects)
ansible.builtin.assert:
that:
- base_normalized | symmetric_difference(revert_normalized) == []
fail_msg: "Mismatch found for Ethernet1/1 or Ethernet1/2 (excluding redirect fields)"
success_msg: "Configs match for Ethernet1/1 and 1/2 as expected"
when: ansible_connection != 'ansible.netcommon.httpapi'

always:
- ansible.builtin.include_tasks: _remove_config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

- ansible.builtin.assert:
that:
- result.failed and result.msg is search('Transport')
- result.failed == true

- ansible.builtin.debug:
msg: END nxapi/badtransport.yaml
Loading
Loading