diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/arista/eos/tests | |
parent | Initial commit. (diff) | |
download | ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/arista/eos/tests')
600 files changed, 29266 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/.gitignore b/collections-debian-merged/ansible_collections/arista/eos/tests/.gitignore new file mode 100644 index 00000000..ea1472ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg new file mode 100644 index 00000000..d12c1efe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg @@ -0,0 +1,4 @@ +[persistent_connection] +command_timeout = 100 +connect_timeout = 100 +connect_retry_timeout = 100 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network new file mode 100644 index 00000000..90c4079c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +eos
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml new file mode 100644 index 00000000..aeb94781 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..59e767e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,6 @@ +interface GigabitEthernet0/0 +ip access-group aclv401 in +ip access-group aclv402 out +ipv6 traffic-filter aclv601 out +interface GigabitEthernet0/1 +ipv6 traffic-filter aclv601 in diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml new file mode 100644 index 00000000..12d095c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml @@ -0,0 +1,33 @@ +--- +- name: Setup + become: true + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml new file mode 100644 index 00000000..2423bb74 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + + - name: "{{ Interfaces['int2'] }}" + state: deleted diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..4aa0470f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: Start eos_acl_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given acl_interfaces of an afi. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv6 + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ipv6 traffic-filter aclv601 out' in result.commands" + + - name: Delete attributes of given acl_interfaces configuration. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ip access-group aclv401 in' in result.commands" + + - name: Delete attributes of given acl_interfaces of an interface. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ip access-group aclv402 out' in result.commands" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..f836f086 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START eos_acl_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..209aac3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_acl_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + state: gathered + + - name: Assert + assert: + that: + - gathered['config'] | symmetric_difference(result.gathered) == [] + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..af1967ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml @@ -0,0 +1,59 @@ +--- +- debug: + msg: Start eos_acl_interfaces merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..6dba3e0f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_acl_interfaces overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: overridden + + - assert: + that: + - result.commands|length == 7 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..9bdf029a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_acl_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_acl_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result.parsed) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..354f34a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml @@ -0,0 +1,45 @@ +--- +- debug: + msg: Start eos_acl_interfaces rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: render given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..9746ca34 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_acl_interfaces replced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: replaced + + - assert: + that: + - result.commands|length == 3 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..f66ad3c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml @@ -0,0 +1,82 @@ +--- +- debug: + msg: Start eos_acl_interfaces merged round trip tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given acl interfaces configuration(apply base config) + become: true + register: base_config + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: Assert that changes were applied + assert: + that: + - "{{ round_trip['commands'] | symmetric_difference(result['commands']) == [] }}" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_acl_interfaces: + config: "{{ ansible_facts['network_resources']['acl_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) == [] }}" + + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml new file mode 100644 index 00000000..5dd042bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml @@ -0,0 +1,79 @@ +--- +Interfaces: + int1: GigabitEthernet0/0 + int2: GigabitEthernet0/1 +deleted1: + commands: + - interface GigabitEthernet0/0 + - no ip access-group aclv401 in + - no ip access-group aclv402 out + - no ipv6 traffic-filter aclv601 out +merged: + commands: + - interface GigabitEthernet0/0 + - ip access-group aclv401 in + - ip access-group aclv402 out + - ipv6 traffic-filter aclv601 out + - interface GigabitEthernet0/1 + - ipv6 traffic-filter aclv601 in +replaced: + commands: + - interface GigabitEthernet0/1 + - no ipv6 traffic-filter aclv601 in + - ip access-group aclv401 in +overridden: + commands: + - interface GigabitEthernet0/0 + - no ip access-group aclv401 in + - no ip access-group aclv402 out + - no ipv6 traffic-filter aclv601 out + - interface GigabitEthernet0/1 + - no ipv6 traffic-filter aclv601 in + - ip access-group aclv401 in +roundtrip: + commands: + - interface GigabitEthernet0/1 + - ip access-group aclv401 in +gathered: + config: + - name: Loopback888 + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 + - name: GigabitEthernet0/2 + - name: GigabitEthernet0/3 +parsed: + config: + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml new file mode 100644 index 00000000..2497b2be --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml new file mode 100644 index 00000000..e3f29514 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg new file mode 100644 index 00000000..11758ce5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg @@ -0,0 +1,4 @@ +ip access-list test1 +35 deny tcp 20.0.0.0/8 any log +45 remark Run by ansible +55 permit tcp any any diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml new file mode 100644 index 00000000..4380ec23 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + vars: + arista.eos.eos_config: + lines: + - "ip access-list test1" + - "35 deny tcp 20.0.0.0/8 any log" + - "45 remark Run by ansible" + - "55 permit tcp any any" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml new file mode 100644 index 00000000..ac493189 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml @@ -0,0 +1,59 @@ +--- +- name: Setup + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml new file mode 100644 index 00000000..a3b44aef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + arista.eos.eos_acls: + config: + + - afi: ipv4 + + - afi: ipv6 + state: deleted diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml new file mode 100644 index 00000000..92b9faae --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml @@ -0,0 +1,165 @@ +--- +- debug: + msg: Start eos_acls deleted integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config1: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 55 + grant: permit + protocol: tcp + source: + any: true + destination: + any: true + + - remark: Run by ansible + sequence: 45 + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- set_fact: + config2: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + +- set_fact: + config3: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + +- block: + + - name: Delete afi of given acls. + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv6 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - 'ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] ' + become: true + + - name: Delete attributes of given named acl. + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test4 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - 'ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] ' + become: true + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml new file mode 100644 index 00000000..9fc86f06 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START eos_acls gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_acls: &id001 + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - name: Assert + assert: + that: + - ansible_facts.network_resources.acls | symmetric_difference(result.gathered) + == [] + + - name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_acls: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml new file mode 100644 index 00000000..85f3c2d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml @@ -0,0 +1,176 @@ +--- +- debug: + msg: Start eos_acls merged integration tests ansible_connection={{ ansible_connection + }} + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- block: + + - name: merge attributes of given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + + - name: merge attributes with an existing ace + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + log: true + ttl: + eq: 33 + source: + any: true + state: merged + + - assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'no 35' in result.commands" + - "'35 deny tcp any any ttl eq 33 log' in result.commands" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml new file mode 100644 index 00000000..0114000b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml @@ -0,0 +1,81 @@ +--- +- debug: + msg: Start eos_acls merged integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 10 + grant: permit + protocol: ospf + source: + any: true + destination: + any: true + log: true + +- block: + + - name: overriden attributes with given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - grant: permit + sequence: 10 + protocol: ospf + source: + any: true + destination: + any: true + log: true + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 7 + - result.changed == true + - "'ip access-list test1' in result.commands" + - "'10 permit ospf any any log' in result.commands" + - ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml new file mode 100644 index 00000000..40a4b76f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml @@ -0,0 +1,30 @@ +--- +- debug: + msg: START eos_acls parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _parsed_cfg.yaml + +- name: Gather acls facts + become: true + register: acls_facts + arista.eos.eos_facts: + gather_subset: + - default + gather_network_resources: + - acls + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_acls: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - ansible_facts.network_resources.acls|symmetric_difference(result.parsed) + == [] + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml new file mode 100644 index 00000000..6f36239e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml @@ -0,0 +1,89 @@ +--- +- debug: + msg: START eos_acls rendered integration tests on connection={{ ansible_connection + }} + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: rendered + + - name: Assert that correct set of commands were generated + vars: + lines: + - ip access-list test1 + - 35 deny tcp 20.0.0.0/8 any log + - remark Run by ansible + - permit tcp any any + - ip access-list test4 + - permit tcp any eq smtp any eq www ttl eq 55 + - ipv6 access-list standard test2 + - permit any log + assert: + that: + - "{{ lines | symmetric_difference(result['rendered']) |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + arista.eos.eos_acls: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml new file mode 100644 index 00000000..153985f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml @@ -0,0 +1,109 @@ +--- +- debug: + msg: Start eos_acls replaced integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 10 + grant: permit + protocol: ospf + source: + any: true + destination: + any: true + log: true + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- block: + + - name: replace attributes with given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - grant: permit + sequence: 10 + protocol: ospf + source: + any: true + destination: + any: true + log: true + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 5 + - result.changed == true + - ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml new file mode 100644 index 00000000..84114c68 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml @@ -0,0 +1,118 @@ +--- +- debug: + msg: Start eos_acls round trip integration tests ansible_connection={{ ansible_connection + }} + +- block: + + - name: merge attributes of given acls(apply base config). + become: true + register: base_config + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - base_config.commands|length == 8 + - base_config.changed == true + - ansible_facts.network_resources.acls|symmetric_difference(base_config.after) + == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test3 + aces: + + - sequence: 100 + grant: permit + protocol: icmp + source: + any: true + destination: + any: true + log: true + + - name: Assert that changes were applied + assert: + that: + - "{{ round_trip['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_acls: + config: "{{ ansible_facts['network_resources']['acls'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml new file mode 100644 index 00000000..53447982 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml @@ -0,0 +1,109 @@ +--- +round_trip: + after: + - afi: ipv4 + acls: + - name: test1 + aces: + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + - remark: Run by ansible + sequence: 45 + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + - name: test3 + aces: + - sequence: 100 + grant: permit + protocol: icmp + source: + any: true + destination: + any: true + log: true + - name: test4 + aces: + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + - afi: ipv6 + acls: + - name: test2 + standard: true + aces: + - grant: permit + sequence: 10 + log: true + source: + any: true + commands: + - ip access-list test3 + - 100 permit icmp any any log +base_config: + after: + - afi: ipv4 + acls: + - name: test1 + aces: + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + - remark: Run by ansible + sequence: 45 + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + - name: test4 + aces: + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + - afi: ipv6 + acls: + - name: test2 + standard: true + aces: + - grant: permit + log: 'true' + source: + any: true diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml new file mode 100644 index 00000000..34d500f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml @@ -0,0 +1,56 @@ +--- +- debug: msg="START cli/basic-login.yaml on connection={{ ansible_connection }}" + +- name: Remove previous login banner + become: true + arista.eos.eos_config: + lines: no banner login + +- name: Create login banner + become: true + register: result + arista.eos.eos_banner: &id001 + banner: login + text: "Junk login banner\n \nover multiple lines\n" + state: present + +- assert: + that: + - result.changed == true + - "'banner login' in result.commands[0]" + - "'ansible_1' in result.session_name" + +- name: Create login banner again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id001 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove login + become: true + register: result + arista.eos.eos_banner: &id002 + banner: login + state: absent + +- assert: + that: + - result.changed == true + - "'no banner login' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove login again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id002 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml new file mode 100644 index 00000000..2108e1f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START cli/basic-motd.yaml on connection={{ ansible_connection }}" + +- name: Remove previous motd banner + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: Set motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner' in result.commands" + - "'that has a multiline' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Set motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner motd' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml new file mode 100644 index 00000000..1789b6dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eos cli/net_banner.yaml on connection={{ ansible_connection + }}" + +- name: Remove previous motd banner (setup) + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: create motd + become: true + register: result + ansible.netcommon.net_banner: + banner: motd + text: this is my motd banner configure by net_banner + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner configure by net_banner' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove previous motd banner (teardown) + become: true + arista.eos.eos_config: + lines: no banner motd + +- debug: msg="END eos cli/net_banner.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml new file mode 100644 index 00000000..c3b64861 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml @@ -0,0 +1,57 @@ +--- +- debug: msg="START eapi/basic-login.yaml on connection={{ ansible_connection }}" + +- name: Remove previous login banner + become: true + arista.eos.eos_config: + lines: no banner login + +- name: Create login banner + become: true + register: result + arista.eos.eos_banner: &id001 + banner: login + text: "this is my login banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'banner login' in result.commands[0]" + - "'ansible_1' in result.session_name" + +- name: Create login banner again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id001 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove login + become: true + register: result + arista.eos.eos_banner: &id002 + banner: login + text: "this is my login banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner login' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove login again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id002 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml new file mode 100644 index 00000000..d1027124 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/basic-motd.yaml on connection={{ ansible_connection }}" + +- name: Remove previous motd banner + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: Set motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner' in result.commands" + - "'that has a multiline' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Set motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner motd' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml new file mode 100644 index 00000000..f59f9db9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eos eapi/net_banner.yaml on connection={{ ansible_connection + }}" + +- name: Remove previous motd banner (setup) + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: create motd + become: true + register: result + ansible.netcommon.net_banner: + banner: motd + text: this is my motd banner configure by net_banner + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner configure by net_banner' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove previous motd banner (teardown) + become: true + arista.eos.eos_config: + lines: no banner motd + +- debug: msg="END eos eapi/net_banner.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml new file mode 100644 index 00000000..6e4aa52d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml @@ -0,0 +1,410 @@ +--- +- debug: msg="START eos cli/eos_bgp.yaml on connection={{ ansible_connection }}" + +- name: Clear existing BGP config + become: true + ignore_errors: true + arista.eos.eos_bgp: &id011 + operation: delete + +- name: Configure BGP with AS 64496 and a router-id + become: true + register: result + arista.eos.eos_bgp: &id001 + operation: merge + config: + bgp_as: 64496 + router_id: 192.0.2.2 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'router-id 192.0.2.2' in result.commands" + +- name: Configure BGP with AS 64496 and a router-id (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id001 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors + become: true + register: result + arista.eos.eos_bgp: &id002 + operation: merge + config: + bgp_as: 64496 + neighbors: + + - neighbor: 192.0.2.10 + remote_as: 64496 + description: IBGP_NBR_1 + ebgp_multihop: 100 + timers: + keepalive: 300 + holdtime: 360 + + - neighbor: 192.0.2.15 + remote_as: 64496 + description: IBGP_NBR_2 + ebgp_multihop: 150 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'neighbor 192.0.2.10 remote-as 64496' in result.commands" + - "'neighbor 192.0.2.10 description IBGP_NBR_1' in result.commands" + - "'neighbor 192.0.2.10 ebgp-multihop 100' in result.commands" + - "'neighbor 192.0.2.10 timers 300 360' in result.commands" + - "'neighbor 192.0.2.15 remote-as 64496' in result.commands" + - "'neighbor 192.0.2.15 description IBGP_NBR_2' in result.commands" + - "'neighbor 192.0.2.15 ebgp-multihop 150' in result.commands" + +- name: Configure BGP neighbors (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id002 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors with operation replace + become: true + register: result + arista.eos.eos_bgp: &id003 + operation: replace + config: + bgp_as: 64496 + neighbors: + + - neighbor: 192.0.2.15 + remote_as: 64496 + description: IBGP_NBR_2 + ebgp_multihop: 150 + + - neighbor: 203.0.113.10 + remote_as: 64511 + description: EBGP_NBR_1 + +- assert: + that: + - result.changed == true + - "'neighbor 203.0.113.10 remote-as 64511' in result.commands" + - "'neighbor 203.0.113.10 description EBGP_NBR_1' in result.commands" + - "'no neighbor 192.0.2.10' in result.commands" + +- name: Configure BGP neighbors with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id003 + +- assert: + that: + - result.changed == false + +- name: Configure root-level networks for BGP + become: true + register: result + arista.eos.eos_bgp: &id004 + operation: merge + config: + bgp_as: 64496 + networks: + + - prefix: 203.0.113.0 + masklen: 27 + route_map: RMAP_1 + + - prefix: 203.0.113.32 + masklen: 27 + route_map: RMAP_2 + +- assert: + that: + - result.changed == True + - "'router bgp 64496' in result.commands" + - "'network 203.0.113.0/27 route-map RMAP_1' in result.commands" + - "'network 203.0.113.32/27 route-map RMAP_2' in result.commands" + +- name: Configure root-level networks for BGP (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id004 + +- assert: + that: + - result.changed == false + +- name: Configure root-level networks for BGP with operation replace + become: true + register: result + arista.eos.eos_bgp: &id005 + operation: replace + config: + bgp_as: 64496 + networks: + + - prefix: 203.0.113.0 + masklen: 27 + route_map: RMAP_1 + + - prefix: 198.51.100.16 + masklen: 28 + +- assert: + that: + - result.changed == True + - "'router bgp 64496' in result.commands" + - "'network 198.51.100.16/28' in result.commands" + - "'no network 203.0.113.32/27' in result.commands" + +- name: Configure root-level networks for BGP with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id005 + +- assert: + that: + - result.changed == false + +- name: Configure BGP route redistribute information + become: true + register: result + arista.eos.eos_bgp: &id006 + operation: merge + config: + bgp_as: 64496 + redistribute: + + - protocol: ospf + route_map: RMAP_1 + + - protocol: rip + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'redistribute ospf route-map RMAP_1' in result.commands" + - "'redistribute rip' in result.commands" + +- name: Configure BGP route redistribute information (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id006 + +- assert: + that: + - result.changed == false + +- name: Configure BGP route redistribute information with operation replace + become: true + register: result + arista.eos.eos_bgp: &id007 + operation: replace + config: + bgp_as: 64496 + redistribute: + + - protocol: ospf + route_map: RMAP_1 + + - protocol: static + route_map: RMAP_2 + +- assert: + that: + - result.changed == true + - "'redistribute static route-map RMAP_2' in result.commands" + - "'no redistribute rip' in result.commands" + +- name: Configure BGP route redistribute information with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id007 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors under address family mode + become: true + register: result + arista.eos.eos_bgp: &id008 + operation: merge + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + neighbors: + + - neighbor: 203.0.113.10 + activate: true + default_originate: true + + - neighbor: 192.0.2.15 + activate: true + graceful_restart: false + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'address-family ipv4' in result.commands" + - "'neighbor 203.0.113.10 activate' in result.commands" + - "'neighbor 203.0.113.10 default-originate' in result.commands" + - "'neighbor 192.0.2.15 activate' in result.commands" + - "'no neighbor 192.0.2.15 graceful-restart' in result.commands" + +- name: Configure BGP neighbors under address family mode (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id008 + +- assert: + that: + - result.changed == false + +- name: Configure networks under address family + become: true + register: result + arista.eos.eos_bgp: &id009 + operation: merge + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + networks: + + - prefix: 198.51.100.48 + masklen: 28 + route_map: RMAP_1 + + - prefix: 192.0.2.64 + masklen: 27 + + - prefix: 203.0.113.160 + masklen: 27 + route_map: RMAP_2 + + - afi: ipv6 + networks: + + - prefix: '2001:db8::' + masklen: 33 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'address-family ipv4' in result.commands" + - "'network 198.51.100.48/28 route-map RMAP_1' in result.commands" + - "'network 192.0.2.64/27' in result.commands" + - "'network 203.0.113.160/27 route-map RMAP_2' in result.commands" + - "'address-family ipv6' in result.commands" + - "'network 2001:db8::/33' in result.commands" + +- name: Configure networks under address family (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id009 + +- assert: + that: + - result.changed == false + +- name: Configure networks under address family with operation replace + become: true + register: result + arista.eos.eos_bgp: &id010 + operation: replace + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + networks: + + - prefix: 198.51.100.80 + masklen: 28 + + - prefix: 192.0.2.64 + masklen: 27 + + - prefix: 203.0.113.192 + masklen: 27 + + - afi: ipv6 + networks: + + - prefix: '2001:db8:1000::' + masklen: 37 + +- assert: + that: + - result.changed == true + - '"router bgp 64496" in result.commands' + - '"address-family ipv4" in result.commands' + - '"network 198.51.100.80/28" in result.commands' + - '"network 203.0.113.192/27" in result.commands' + - '"no network 198.51.100.48/28" in result.commands' + - '"no network 203.0.113.160/27" in result.commands' + - '"address-family ipv6" in result.commands' + - '"network 2001:db8:1000::/37" in result.commands' + - '"no network 2001:db8::/33" in result.commands' + +- name: Configure networks under address family with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id010 + +- assert: + that: + - result.changed == false + +- name: Override all the exisiting BGP config + become: true + register: result + arista.eos.eos_bgp: + operation: override + config: + bgp_as: 64497 + router_id: 192.0.2.10 + log_neighbor_changes: true + +- assert: + that: + - result.changed == true + - "'no router bgp 64496' in result.commands" + - "'router bgp 64497' in result.commands" + - "'router-id 192.0.2.10' in result.commands" + - "'bgp log-neighbor-changes' in result.commands" + +- name: Teardown + become: true + register: result + arista.eos.eos_bgp: *id011 + +- assert: + that: + - result.changed == true + - "'no router bgp 64497' in result.commands" + +- name: Teardown again (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id011 + +- assert: + that: + - result.changed == false + +- debug: msg="END eos cli/eos_bgp.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg new file mode 100644 index 00000000..a6a10d80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg @@ -0,0 +1,24 @@ +router bgp 65536 + neighbor n2 peer-group + neighbor n2 next-hop-unchanged + neighbor n2 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + ! + address-family ipv4 + bgp additional-paths receive + neighbor peer2 default-originate always + neighbor 192.0.2.1 activate + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + redistribute ospf3 match external + ! + vrf vrft + address-family ipv4 + bgp additional-paths receive + ! + address-family ipv6 + redistribute isis level-2 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg new file mode 100644 index 00000000..a6a10d80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg @@ -0,0 +1,24 @@ +router bgp 65536 + neighbor n2 peer-group + neighbor n2 next-hop-unchanged + neighbor n2 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + ! + address-family ipv4 + bgp additional-paths receive + neighbor peer2 default-originate always + neighbor 192.0.2.1 activate + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + redistribute ospf3 match external + ! + vrf vrft + address-family ipv4 + bgp additional-paths receive + ! + address-family ipv6 + redistribute isis level-2 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0d2ec11c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router bgp 65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml new file mode 100644 index 00000000..5ca77031 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml @@ -0,0 +1,46 @@ +--- +- debug: + msg: Start eos_bgp_address_family deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &deleted + config: + as_number: "65536" + address_family: + - afi: "ipv4" + - afi: "ipv6" + vrf: "vrft" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_address_family + + - assert: + that: + - result.commands|length == 4 + - result.changed == true + - ansible_facts.network_resources.bgp_address_family == result.after + - result.after.address_family|symmetric_difference(deleted.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + - result.commands|symmetric_difference(deleted.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml new file mode 100644 index 00000000..66e0207f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_bgp_address_family empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml new file mode 100644 index 00000000..b340b606 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_bgp_address_family gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_bgp_address_family: + config: + state: gathered + + - name: Assert + assert: + that: + - result.gathered == gathered.populate + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml new file mode 100644 index 00000000..e6b8dfd5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: Start eos_bgp_address_family merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &merged + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - result.commands|length == 17 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.address_family|symmetric_difference(merged.after.address_family) == [] + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml new file mode 100644 index 00000000..39733adc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: Start eos_bgp_address_family overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &overridden + state: overridden + config: + as_number: "65536" + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 12 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after.address_family|symmetric_difference(overridden.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml new file mode 100644 index 00000000..9cf5f716 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_bgp_address_family_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_bgp_address_family: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed.address_family|symmetric_difference(replaced.before.address_family) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml new file mode 100644 index 00000000..cea72b9a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml @@ -0,0 +1,46 @@ +--- +- debug: + msg: Start eos_bgp_address_family rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: render given bgp_address_family configuration as device commands + become: true + register: result + arista.eos.eos_bgp_address_family: + state: rendered + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml new file mode 100644 index 00000000..6fd53736 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: Start eos_bgp_address_family replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Replace given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &replaced + state: replaced + config: + as_number: "65536" + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv4" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 15 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.address_family|symmetric_difference(replaced.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml new file mode 100644 index 00000000..7bb961c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml @@ -0,0 +1,83 @@ +--- +- debug: + msg: Start eos_bgp_address_family rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_address_family configuration + become: true + register: baseconfig + arista.eos.eos_bgp_address_family: &merged + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - baseconfig.commands|length == 17 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after.address_family|symmetric_difference(merged.after.address_family) == [] + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_address_family + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_bgp_address_family: + config: + as_number: "65536" + address_family: + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + - afi: "evpn" + graceful_restart: true + bgp_params: + additional_paths: "send" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_bgp_address_family: + config: "{{ ansible_facts['network_resources']['bgp_address_family'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml new file mode 100644 index 00000000..97d02b13 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml @@ -0,0 +1,185 @@ +--- +merged: + commands: + - router bgp 65536 + - address-family ipv4 + - redistribute ospf3 match external + - network 192.0.2.0/24 + - network 203.0.113.0/24 route-map MAP01 + - neighbor 192.0.2.1 activate + - exit + - address-family ipv6 + - neighbor peer2 default-originate always + - bgp additional-paths receive + - exit + - vrf vrft + - address-family ipv6 + - redistribute isis level-2 + - route-target export 33:11 + - exit + - exit + + after: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + +deleted: + after: + address_family: + - afi: "ipv4" + vrf: "vrft" + bgp_params: + additional_paths: "receive" + + commands: + - router bgp 65536 + - no address-family ipv4 + - vrf vrft + - no address-family ipv6 + +replaced: + commands: + - router bgp 65536 + - vrf vrft + - address-family ipv4 + - redistribute ospf3 match external + - exit + - exit + - address-family ipv4 + - redistribute isis level-2 + - no redistribute ospf3 match external + - no network 192.0.2.0/24 + - no network 203.0.113.0/24 route-map MAP01 + - no neighbor peer2 default-originate always + - no neighbor 192.0.2.1 activate + - no bgp additional-paths receive + - exit + before: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "peer2" + default_originate: + always: true + - peer: "192.0.2.1" + activate: true + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv4" + vrf: "vrft" + bgp_params: + additional_paths: "receive" + after: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + +overridden: + commands: + - router bgp 65536 + - vrf vrft + - address-family ipv4 + - redistribute ospf3 match external + - exit + - exit + - address-family ipv6 + - redistribute isis level-2 + - exit + - no address-family ipv4 + - vrf vrft + - no address-family ipv6 + + after: + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + +gathered: + populate: + address_family: + - afi: "ipv4" + bgp_params: + additional_paths: "receive" + neighbor: + - default_originate: + always: true + peer: "peer2" + - activate: true + peer: "192.0.2.1" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + redistribute: + - ospf_route: "external" + protocol: "ospf3" + - afi: "ipv4" + bgp_params: + additional_paths: "receive" + vrf: "vrft" + - afi: "ipv6" + redistribute: + - isis_level: "level-2" + protocol: "isis" + vrf: "vrft" + as_number: "65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg new file mode 100644 index 00000000..175a034b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg @@ -0,0 +1,22 @@ +router bgp 65536 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 203.0.113.0/24 as-set summary-only + aggregate-address 192.0.2.0/24 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg new file mode 100644 index 00000000..2bc00601 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg @@ -0,0 +1,4 @@ +router bgp 65536 + vrf vrf01 + address-family ipv4 + bgp additional-paths receive diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg new file mode 100644 index 00000000..175a034b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg @@ -0,0 +1,22 @@ +router bgp 65536 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 203.0.113.0/24 as-set summary-only + aggregate-address 192.0.2.0/24 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml new file mode 100644 index 00000000..04ab196a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate_af.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0d2ec11c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router bgp 65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml new file mode 100644 index 00000000..db58a740 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: Start eos_bgp_global deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &deleted + config: + as_number: "65536" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - assert: + that: + - result.commands|length == 15 + - result.changed == true + - "'no router bgp 65536' not in result.commands" + - ansible_facts.network_resources.bgp_global == result.after + - result.after == deleted.after + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml new file mode 100644 index 00000000..e5ca0e1b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: START eos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml new file mode 100644 index 00000000..fd30b979 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_bgp_global gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_bgp_global: + config: + state: gathered + + - name: Assert + assert: + that: + - populate.global == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml new file mode 100644 index 00000000..9327987d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml @@ -0,0 +1,79 @@ +--- +- debug: + msg: Start eos_bgp_global merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &merged + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + + - assert: + that: + - result.commands|length == 21 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after == populate.global + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml new file mode 100644 index 00000000..2ec182ad --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_bgp_global_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_bgp_global: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed == populate.global diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml new file mode 100644 index 00000000..19bc3bb5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: Start eos_bgp_global purged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Purge given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &purged + config: + as_number: "65536" + state: purged + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router bgp 65536' in result.commands" + - ansible_facts.network_resources.bgp_global == [] + - result.after == {} + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *purged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml new file mode 100644 index 00000000..85c120f3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: Start eos_bgp_global rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: Render given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &rendered + state: "rendered" + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml new file mode 100644 index 00000000..4f2c4470 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml @@ -0,0 +1,68 @@ +--- +- debug: + msg: Start eos_bgp_global replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &replaced + state: "replaced" + config: + as_number: "65536" + vrfs: + - vrf: "vrf02" + redistribute: + - protocol: "isis" + isis_level: "level-2" + timers: + holdtime: 100 + keepalive: 44 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 22 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after == replaced.after + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + - name: Configure address_family under vrf + become: true + arista.eos.eos_config: + src: populate_af.cfg + + - name: Replace in presence of address_family + become: true + ignore_errors: true + register: result + arista.eos.eos_bgp_global: *replaced + + - assert: + that: + - result.msg == 'Use the _bgp_address_family module to delete the address_family under vrf, before replacing/deleting the vrf.' + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml new file mode 100644 index 00000000..3e3a3433 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml @@ -0,0 +1,104 @@ +--- +- debug: + msg: Start eos_bgp_global rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_global configuration + become: true + register: baseconfig + arista.eos.eos_bgp_global: &merged + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + + - assert: + that: + - baseconfig.commands|length == 21 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after == populate.global + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_bgp_global: + config: + as_number: "65536" + vrfs: + - vrf: "vrf01" + aggregate_address: + - address: "10.1.1.0/24" + as_set: true + summary_only: true + attribute_map: "attrmap" + default_metric: 433 + network: + - address: "4.1.1.0/24" + route_map: "netmap2" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_bgp_global: + config: "{{ ansible_facts['network_resources']['bgp_global'] }}" + state: replaced + + - assert: + that: + - baseconfig.after == revert.after + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml new file mode 100644 index 00000000..10dfcd45 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml @@ -0,0 +1,118 @@ +--- +merged: + commands: + - router bgp 65536 + - vrf vrf01 + - redistribute isis level-2 + - network 6.6.6.0/24 route-map netmap1 + - network 10.1.0.0/16 + - default-metric 433 + - route-target export 44:22 + - exit + - neighbor peer1 maximum-routes 12000 + - neighbor peer1 peer-group + - neighbor peer1 send-community link-bandwidth divide ratio + - neighbor peer2 maximum-routes 12000 + - neighbor peer2 peer-group + - redistribute ospf match nssa-external 2 + - redistribute static + - redistribute rip route-map MAP01 + - aggregate-address 203.0.113.0/24 as-set summary-only + - aggregate-address 192.0.2.0/24 attribute-map attrmap + - timers bgp 44 100 + - ucmp link-bandwidth recursive + - vlan-aware-bundle bundle1 bundle3 + +deleted: + after: + as_number: "65536" + +replaced: + commands: + - router bgp 65536 + - vrf vrf02 + - redistribute isis level-2 + - timers bgp 44 100 + - exit + - no vrf vrf01 + - no neighbor peer1 peer-group + - no neighbor peer1 send-community link-bandwidth divide ratio + - no neighbor peer1 maximum-routes 12000 + - no neighbor peer2 peer-group + - no neighbor peer2 maximum-routes 12000 + - redistribute isis level-2 + - no redistribute ospf match nssa-external 2 + - no redistribute static + - no redistribute rip route-map MAP01 + - network 6.6.6.0/24 route-map netmap1 + - network 10.1.0.0/16 + - no aggregate-address 203.0.113.0/24 as-set summary-only + - no aggregate-address 192.0.2.0/24 attribute-map attrmap + - no timers bgp 44 100 + - no ucmp link-bandwidth recursive + - no vlan-aware-bundle bundle1 bundle3 + after: + as_number: "65536" + redistribute: + - protocol: "isis" + isis_level: "level-2" + network: + - address: "10.1.0.0/16" + - address: "6.6.6.0/24" + route_map: "netmap1" + vrfs: + - vrf: "vrf02" + timers: + holdtime: 100 + keepalive: 44 + redistribute: + - protocol: "isis" + isis_level: "level-2" +populate: + global: + as_number: "65536" + aggregate_address: + - address: "192.0.2.0/24" + attribute_map: "attrmap" + - address: "203.0.113.0/24" + as_set: true + summary_only: true + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "10.1.0.0/16" + - address: "6.6.6.0/24" + route_map: "netmap1" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..d9559736 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" + +- name: test bad operator + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name foo Management + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml new file mode 100644 index 00000000..9cf021d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml @@ -0,0 +1,65 @@ +--- +- debug: + msg: START cli/cli_command.yaml on connection={{ ansible_connection }} + +- block: + + - name: get output for single command + register: result + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.changed == false + - result.stdout is defined + + - name: send invalid command + register: result + ignore_errors: true + ansible.netcommon.cli_command: + command: show foo + + - assert: + that: + - result.failed == true + - result.msg is defined + + - name: get output in JSON format + register: result + ansible.netcommon.cli_command: + command: show version | json + + - assert: + that: + - result.changed == false + - result.stdout is defined + - result.json is defined + + - name: command that does require become (should fail) + become: false + ignore_errors: true + register: result + ansible.netcommon.cli_command: + command: show running-config + + - assert: + that: + - result.failed == true + - '"privileged mode required" in result.msg' + when: ansible_connection == 'ansible.netcommon.network_cli' + +- block: + + - name: test failure for local connection + register: result + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.failed == true + - "'Connection type local is not valid for this module' in result.msg" + when: ansible_connection == 'local' + +- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml new file mode 100644 index 00000000..faabb1c8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[0] contains EOS + - result[1].interfaces.Management1.name contains Manage + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml new file mode 100644 index 00000000..ab1808a2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/equal.yaml on connection={{ ansible_connection }}" + +- name: test eq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name eq Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test == operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name == Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/equal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml new file mode 100644 index 00000000..933fe335 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/greaterthan.yaml on connection={{ ansible_connection }}" + +- name: test gt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu gt 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test > operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu > 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/greaterthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml new file mode 100644 index 00000000..64b9869e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test ge operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu ge 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test >= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu >= 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml new file mode 100644 index 00000000..7fc9fb77 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" + +- name: run invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: run commands that include invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml new file mode 100644 index 00000000..0cdf3baa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/lessthan.yaml on connection={{ ansible_connection }}" + +- name: test lt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu lt 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test < operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu < 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/lessthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml new file mode 100644 index 00000000..dc650186 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml @@ -0,0 +1,33 @@ +--- +- debug: msg="START cli/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test le operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu le 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test <= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu <= 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/lessthanorequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml new file mode 100644 index 00000000..1c2e023c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/notequal.yaml on connection={{ ansible_connection }}" + +- name: test neq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name neq Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test != operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name != Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/notequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml new file mode 100644 index 00000000..88c7e8da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml @@ -0,0 +1,27 @@ +--- +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" + +- name: get output for single command + register: result + arista.eos.eos_command: + commands: + - show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: get output for multiple commands + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml new file mode 100644 index 00000000..49c4131f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" + +- name: test bad condition + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml new file mode 100644 index 00000000..cc8d0066 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/bad_operator.yaml" + +- name: test bad operator + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 + wait_for: + - result[1].interfaces.Management1.name foo Management + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/bad_operator.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml new file mode 100644 index 00000000..5849bbd8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[0] contains EOS + - result[1].interfaces.Management1.name contains Manage + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/contains.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml new file mode 100644 index 00000000..a3a4809e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/equal.yaml on connection={{ ansible_connection }}" + +- name: test eq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name eq Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test == operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name == Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/equal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml new file mode 100644 index 00000000..622eddab --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/greaterthan.yaml on connection={{ ansible_connection }}" + +- name: test gt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu gt 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test > operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu > 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/greaterthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml new file mode 100644 index 00000000..e4a66cc8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eapi/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test ge operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu ge 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test >= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu >= 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml new file mode 100644 index 00000000..f105f9ef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eapi/invalid.yaml" + +- name: run invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: run commands that include invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/invalid.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml new file mode 100644 index 00000000..79be9691 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/lessthan.yaml on connection={{ ansible_connection }}" + +- name: test lt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu lt 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test < operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu < 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/lessthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml new file mode 100644 index 00000000..e6dbde5f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eapi/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test le operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu le 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test <= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu <= 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/lessthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml new file mode 100644 index 00000000..82d5f101 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/notequal.yaml on connection={{ ansible_connection }}" + +- name: test neq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name neq Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test != operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name != Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/notequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml new file mode 100644 index 00000000..cbfdacb5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml @@ -0,0 +1,27 @@ +--- +- debug: msg="START eapi/output.yaml" + +- name: get output for single command + register: result + arista.eos.eos_command: + commands: + - show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: get output for multiple commands + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/output.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml new file mode 100644 index 00000000..80992734 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/timeout.yaml" + +- name: test bad condition + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + wait_for: + - result[0].version foo 4.15 + retries: 1 + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/timeout.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt new file mode 100644 index 00000000..fba5bde0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt @@ -0,0 +1,21 @@ +! +! boot system flash:/vEOS-lab.swi +! +transceiver qsfp default-mode 4x10G +! +hostname localhost +! +spanning-tree mode mstp +! +no aaa root +! +interface Ethernet1 +! +interface Ethernet2 +! +! +no ip routing +! +! +end + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml new file mode 100644 index 00000000..98bd1fce --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli_config test cases + find: + paths: '{{ role_path }}/tests/cli_config' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml new file mode 100644 index 00000000..3986c294 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml @@ -0,0 +1,15 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: cli_config.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 new file mode 100644 index 00000000..c68cce8e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 @@ -0,0 +1,4 @@ +ip access-list test + 10 permit ip host 192.168.0.2 host 192.168.0.1 + 20 permit ip host 192.168.0.1 host 192.168.0.2 +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 new file mode 100644 index 00000000..82a61b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 @@ -0,0 +1,4 @@ +interface Ethernet2 + description this is a test + shutdown + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 new file mode 100644 index 00000000..8ff8f305 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 @@ -0,0 +1,3 @@ +interface Ethernet2 + description this is a test + no shutdown diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 new file mode 100644 index 00000000..82a61b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 @@ -0,0 +1,4 @@ +interface Ethernet2 + description this is a test + shutdown + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml new file mode 100644 index 00000000..19fc53dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml @@ -0,0 +1,133 @@ +--- +- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}" + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: delete backup files + file: + path: '{{ item.path }}' + state: absent + with_items: '{{backup_files.files|default([])}}' + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + backup: true + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- assert: + that: + - backup_files.files is defined + +- name: delete configurable backup file path + file: + path: '{{ item }}' + state: absent + with_items: + - '{{ role_path }}/backup_test_dir/' + - '{{ role_path }}/backup/backup.cfg' + +- name: take configuration backup in custom filename and directory path + become: true + register: result + arista.eos.eos_config: + backup: true + backup_options: + filename: backup.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-1 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom filename + become: true + register: result + arista.eos.eos_config: + backup: true + backup_options: + filename: backup.cfg + +- assert: + that: + - result.changed == true + +- name: check if the backup file-2 exist + find: + paths: '{{ role_path }}/backup/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom path and default filename + become: true + register: result + arista.eos.eos_config: + backup: true + backup_options: + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-3 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml new file mode 100644 index 00000000..3a07636c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml @@ -0,0 +1,93 @@ +--- +- debug: + msg: START cli/check_mode.yaml on connection={{ ansible_connection }} + +- name: invalid configuration in check mode + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 1 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.256 + parents: interface Loopback911 + +- assert: + that: + - result.msg is defined + - result.failed == true + - "'Invalid input' in result.msg" + +- name: valid configuration in check mode + become: true + check_mode: true + register: config + arista.eos.eos_config: + before: + - no ip access-list test + src: basic/cmds.j2 + +- name: check if session is removed + become: true + register: result + arista.eos.eos_command: + commands: + - show configuration sessions | json + +- assert: + that: + - config.session not in result.stdout[0].sessions + +- name: configuration in check mode + no config session + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 0 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.254 + parents: interface Loopback911 + +- assert: + that: + - result.failed == true + +- name: invalid configuration in check mode + no config session + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 0 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.256 + parents: interface Loopback911 + diff_against: running + +- assert: + that: + - result.changed == true + +- name: valid configuration in check mode + no config session + become: true + check_mode: true + register: result + vars: + ansible_eos_use_sessions: 0 + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.255 + parents: interface Loopback911 + diff_against: running + +- assert: + that: + - result.changed == true + - "'session' not in result" + +- debug: msg="END cli/check_mode.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml new file mode 100644 index 00000000..8f9137b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml @@ -0,0 +1,51 @@ +--- +- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: get current running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + +- name: configure hostname + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + config: '{{ config.stdout[0] }}' + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: get current running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + +- name: configure hostname again + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + config: '{{ config.stdout[0] }}' + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml new file mode 100644 index 00000000..98aae1f2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml @@ -0,0 +1,42 @@ +--- +- debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml new file mode 100644 index 00000000..13340695 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml @@ -0,0 +1,31 @@ +--- +- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: save config always + become: true + register: result + arista.eos.eos_config: &id001 + save_when: always + +- assert: &id002 + that: + - result.changed == true + +- name: save should always run + become: true + register: result + arista.eos.eos_config: *id001 + +- assert: *id002 + +- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml new file mode 100644 index 00000000..75f8dff3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + defaults: true + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml new file mode 100644 index 00000000..1ac9ef5b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml @@ -0,0 +1,17 @@ +--- +- debug: msg="START cli/src_invalid.yaml on connection={{ ansible_connection }}" + +- name: configure with invalid src + become: true + register: result + ignore_errors: true + arista.eos.eos_config: + src: basic/foobar.j2 + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == 'path specified in src not found' + +- debug: msg="END cli/src_invalid.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml new file mode 100644 index 00000000..a229d1e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START cli/src_match_none.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + match: none + +- assert: + that: + - result.changed == true + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + defaults: true + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml new file mode 100644 index 00000000..78d65999 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: no vlan 10 + match: none + +- name: configure sub level command + become: true + register: result + arista.eos.eos_config: + lines: name test + parents: vlan 10 + +- assert: + that: + - result.changed == true + - "'vlan 10' in result.updates" + - "'name test' in result.updates" + +- name: configure sub level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: name test + parents: vlan 10 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no vlan 10 + match: none + +- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml new file mode 100644 index 00000000..959d0ba1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml @@ -0,0 +1,62 @@ +--- +- debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using block resplace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + +- name: check sub level command using block replace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml new file mode 100644 index 00000000..7ae4fb33 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: exact + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: exact + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml new file mode 100644 index 00000000..cb399707 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'30 permit ip host 192.0.2.2 any log' in result.updates" + - "'20 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: strict + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml new file mode 100644 index 00000000..b9ccf19b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml @@ -0,0 +1,86 @@ +--- +- debug: + msg: START cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection + }} + +- name: setup + become: true + arista.eos.eos_config: + lines: + - class-map type qos match-any c1 + - match ip access-group 10 + - policy-map type qos p1 + - class c1 + before: + - no policy-map type qos p1 + - no class-map type qos match-any c1 + match: none + +- block: + + - name: configure sub level command using strict match + register: result + become: true + arista.eos.eos_config: + lines: + - set cos 1 + - set dscp 62 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == true + - "'set cos 1' in result.updates" + - "'set dscp 62' in result.updates" + + - name: change sub level command order and config with strict match + register: result + become: true + arista.eos.eos_config: + lines: + - set dscp 62 + - set cos 1 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == true + - "'set cos 1' in result.updates" + - "'set dscp 62' in result.updates" + + - name: Config sub level command with strict match (Idempotency) + register: result + become: true + arista.eos.eos_config: + lines: + - set cos 1 + - set dscp 62 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == false + always: + + - name: teardown + become: true + arista.eos.eos_config: + lines: + - no policy-map type qos p1 + - no class-map type qos match-any c1 + match: none + +- debug: msg="END cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml new file mode 100644 index 00000000..ae92eba3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml new file mode 100644 index 00000000..fe1920f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml @@ -0,0 +1,45 @@ +--- +- debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml new file mode 100644 index 00000000..0f48a190 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml @@ -0,0 +1,45 @@ +--- +- debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_backup.yaml new file mode 100644 index 00000000..3880a040 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_backup.yaml @@ -0,0 +1,114 @@ +--- +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" + +- name: delete configurable backup file path + file: + path: '{{ item }}' + state: absent + with_items: + - '{{ role_path }}/backup_test_dir/' + - '{{ role_path }}/backup/backup.cfg' + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: delete backup files + file: + path: '{{ item.path }}' + state: absent + with_items: '{{backup_files.files|default([])}}' + +- name: take config backup + become: true + register: result + ansible.netcommon.cli_config: + backup: true + +- assert: + that: + - result.changed == true + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- assert: + that: + - backup_files.files is defined + +- name: take configuration backup in custom filename and directory path + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-1 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom filename + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + +- assert: + that: + - result.changed == true + +- name: check if the backup file-2 exist + find: + paths: '{{ role_path }}/backup/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom path and default filename + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-3 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml new file mode 100644 index 00000000..0dd90785 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + ansible.netcommon.cli_config: &id002 + config: "interface Ethernet2\nno description\nno shutdown\n" + +- name: configure device with config + register: result + become: true + ansible.netcommon.cli_config: &id001 + config: "{{ lookup('template', 'basic/config.j2') }}" + +- assert: + that: + - result.changed == true + +- name: Idempotence + register: result + become: true + ansible.netcommon.cli_config: *id001 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + ansible.netcommon.cli_config: *id002 + +- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml new file mode 100644 index 00000000..6786e02a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml @@ -0,0 +1,50 @@ +--- +- debug: msg="START eapi/backup.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: delete backup files + file: + path: '{{ item.path }}' + state: absent + with_items: '{{backup_files.files|default([])}}' + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + backup: true + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- assert: + that: + - backup_files.files is defined + +- debug: msg="END eapi/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml new file mode 100644 index 00000000..fee19874 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml @@ -0,0 +1,42 @@ +--- +- debug: msg="START eapi/defaults.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/defaults.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml new file mode 100644 index 00000000..5ac37f4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml @@ -0,0 +1,31 @@ +--- +- debug: msg="START eapi/save.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: save config always + become: true + register: result + arista.eos.eos_config: &id001 + save_when: always + +- assert: &id002 + that: + - result.changed == true + +- name: save should always run + become: true + register: result + arista.eos.eos_config: *id001 + +- assert: *id002 + +- debug: msg="END eapi/save.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml new file mode 100644 index 00000000..9f64858b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/src_basic.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/src_basic.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml new file mode 100644 index 00000000..1300041a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml @@ -0,0 +1,16 @@ +--- +- debug: msg="START eapi/src_invalid.yaml" + +- name: configure with invalid src + register: result + ignore_errors: true + arista.eos.eos_config: + src: basic/foobar.j2 + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == 'path specified in src not found' + +- debug: msg="END eapi/src_invalid.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml new file mode 100644 index 00000000..e0e3e8d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eapi/src_match_none.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + match: none + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/src_match_none.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml new file mode 100644 index 00000000..ffe51858 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml @@ -0,0 +1,41 @@ +--- +- debug: msg="START eapi/sublevel.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- name: configure sub level command + become: true + register: result + arista.eos.eos_config: + lines: 10 permit ip any any log + parents: ip access-list test + after: exit + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip any any log' in result.updates" + +- name: configure sub level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: 10 permit ip any any log + parents: ip access-list test + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml new file mode 100644 index 00000000..c0d87a19 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START eapi/sublevel_block.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + match: none + +- name: configure sub level command using block resplace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + after: end + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + +- name: check sub level command using block replace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_block.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml new file mode 100644 index 00000000..296c67e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml @@ -0,0 +1,65 @@ +--- +- debug: msg="START eapi/sublevel_exact.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: exact + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + before: no ip access-list test + parents: ip access-list test + match: exact + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_exact.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml new file mode 100644 index 00000000..092ad1d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/sublevel_strict.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + match: none + +- name: configure sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'30 permit ip host 192.0.2.2 any log' in result.updates" + - "'20 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: strict + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_strict.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml new file mode 100644 index 00000000..85d6c5ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eapi/toplevel.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml new file mode 100644 index 00000000..feae7e37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START eapi/toplevel_after.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel_after.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml new file mode 100644 index 00000000..04d956b3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START eapi/toplevel_before.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel_before.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..7eb3ef68 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START redirection/shortname.yaml on connection={{ ansible_connection }}" + +- name: Use src with module alias + register: result + become: true + arista.eos.config: + src: basic/config.j2 + +- assert: + that: + # make sure that the template content was read and not the path + - result.failed == false + +- name: use module alias to take configuration backup + register: result + become: true + arista.eos.config: + backup: true + backup_options: + filename: backup_with_alias.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-4 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup_with_alias.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END redirection/shortname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml new file mode 100644 index 00000000..c3aa51c5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml @@ -0,0 +1,16 @@ +--- +- debug: msg="START CLI/BADTRANSPORT.YAML" + +- block: + + - name: Expect transport other than cli to fail + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + provider: '{{ eapi }}' + + - assert: + that: eos_eapi_output.failed == true + when: ansible_connection == 'local' + +- debug: msg="START CLI/BADTRANSPORT.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml new file mode 100644 index 00000000..5954853c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}" + +- name: Setup + become: true + arista.eos.eos_config: + lines: no management api http-commands + match: none + provider: '{{ cli }}' + +- name: Get running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + provider: '{{ cli }}' + +- name: Set config + become: true + register: config + arista.eos.eos_eapi: + config: '{{ config.stdout[0] }}' + provider: '{{ cli }}' + +- name: Ensure that this triggered a change + assert: + that: + - config.changed == true + +- name: Get running-config again + become: true + register: config + arista.eos.eos_command: + commands: show running-config + provider: '{{ cli }}' + +- name: Set config + become: true + register: config + arista.eos.eos_eapi: + config: '{{ config.stdout[0] }}' + provider: '{{ cli }}' + +- name: Idempotency check + assert: + that: + - config.changed == false + +- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml new file mode 100644 index 00000000..868aee05 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START CLI/CONFIGURE.YAML" + +- name: Change endpoint ports + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + http_port: 81 + https_port: 4443 + enable_local_http: true + enable_https: true + local_http_port: 8181 + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- name: Expect endpoint ports to be set + assert: + that: + - http_config.stdout[0].httpServer.port == 80 + - http_config.stdout[0].httpsServer.port == 4443 + - http_config.stdout[0].localHttpServer.port == 8181 + +- name: Change endpoint ports again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + http_port: 80 + https_port: 4443 + enable_local_http: true + local_http_port: 8181 + provider: '{{ cli }}' + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="END CLI/CONFIGURE.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml new file mode 100644 index 00000000..85b386bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml @@ -0,0 +1,50 @@ +--- +- debug: msg="START CLI/OFF.YAML" + +- name: Turn all endpoints off + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + enable_https: false + enable_local_http: false + enable_socket: false + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + +- name: Expect all EAPI endpoints to be in off state + assert: + that: + - http_config.stdout[0].httpServer.running == false + - http_config.stdout[0].httpsServer.running == false + - http_config.stdout[0].localHttpServer.running == false + - http_config.stdout[0].unixSocketServer.running == false + +- name: Turn all endpoints off again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + enable_https: false + enable_local_http: false + enable_socket: false + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="END CLI/OFF.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml new file mode 100644 index 00000000..56631ae0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml @@ -0,0 +1,48 @@ +--- +- debug: msg="START CLI/ON.YAML" + +- name: Turn on all endpoints + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: true + enable_https: true + enable_local_http: true + enable_socket: true + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect all EAPI endpoints to be in on state + assert: + that: + - http_config.stdout[0].httpServer.running == true + - http_config.stdout[0].httpsServer.running == true + - http_config.stdout[0].localHttpServer.running == true + - http_config.stdout[0].unixSocketServer.running == true + +- name: Turn on all endpoints again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: true + enable_https: true + enable_local_http: true + enable_socket: true + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="START CLI/ON.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml new file mode 100644 index 00000000..de4d718f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml @@ -0,0 +1,39 @@ +--- +- debug: msg="START CLI/START.YAML" + +- name: Set state to started + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: started + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is on + assert: + that: http_config.stdout[0].enabled == true + +- name: Set state to running again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: started + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="STOP CLI/START.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml new file mode 100644 index 00000000..d2f762da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml @@ -0,0 +1,39 @@ +--- +- debug: msg="START CLI/STOP.YAML" + +- name: Set state to stopped + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: stopped + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is off + assert: + that: http_config.stdout[0].enabled == false + +- name: Set state to stopped again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: stopped + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="STOP CLI/ENABLE.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml new file mode 100644 index 00000000..7ab138f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml @@ -0,0 +1,46 @@ +--- +- debug: msg="START cli/vrf.yaml on connection={{ ansible_connection }}" + +- name: Set invalid VRF + become: true + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + vrf: foobar + provider: '{{ cli }}' + +- name: Ensure that setting VRF failed + assert: + that: + - eos_eapi_output.failed == true + - eos_eapi_output.changed == false + - eos_eapi_output.msg == "vrf `foobar` is not configured on the system" + +- name: Set VRF to default + become: true + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + vrf: default + provider: '{{ cli }}' + +- name: Set VRF to default again (idempotent) + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + vrf: default + provider: '{{ cli }}' + +- name: Ensure idempotent + assert: + that: + - eos_eapi_output.changed == false + +- name: DEBUG show vrf + register: eos_eapi_output + when: false + arista.eos.eos_command: + commands: show vrf + provider: '{{ cli }}' + +- debug: msg="END cli/vrf.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 new file mode 100644 index 00000000..b489ae80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 @@ -0,0 +1,38 @@ +- debug: msg="START CLI/RESET.YAML" + +- name: Change endpoint ports back to default values + eos_config: + lines: default management api http-commands + match: none + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- name: Expect endpoint ports to have default port values + assert: + that: + - http_config.stdout[0].httpServer.port == 80 + - http_config.stdout[0].httpsServer.port == 443 + - http_config.stdout[0].localHttpServer.port == 8080 + +- name: Change endpoint ports back to default values again + eos_config: + lines: default management api http-commands + match: none + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="END CLI/RESET.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml new file mode 100644 index 00000000..7e1717c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml new file mode 100644 index 00000000..40522749 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml new file mode 100644 index 00000000..47a877e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + +- include: eapi.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml new file mode 100644 index 00000000..d0e12981 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting all facts + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - all + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' 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 + +- debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml new file mode 100644 index 00000000..ea1dcb67 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START cli/default_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting default facts + become: true + register: result + arista.eos.eos_facts: + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memtotal_mb > 10 + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_config is not defined + +- debug: msg="END cli/default_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml new file mode 100644 index 00000000..ebd88253 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/invalid_subset.yaml on connection={{ ansible_connection + }}" + +- name: test invalid subset (foobar) + become: true + register: result + ignore_errors: true + arista.eos.eos_facts: + gather_subset: + - foobar + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - "'Subset must be one of' in result.msg" + +- debug: msg="END cli/invalid_subset.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml new file mode 100644 index 00000000..54ede8ab --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START cli/not_hardware.yaml on connection={{ ansible_connection }}" + +- name: test not hardware + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - '!hardware' + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_filesystems is not defined + +- debug: msg="END cli/not_hardware.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml new file mode 100644 index 00000000..9d0b8728 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START eapi/all_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting all facts + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - all + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' 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 + +- debug: msg="END eapi/all_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml new file mode 100644 index 00000000..b75edf9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml @@ -0,0 +1,24 @@ +--- +- debug: msg="START eapi/default_facts.yaml on connection={{ ansible_connection + }}" + +- name: test getting default facts + become: true + register: result + arista.eos.eos_facts: + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memtotal_mb > 10 + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_config is not defined + +- debug: msg="END eapi/default_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml new file mode 100644 index 00000000..361500ca --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START eapi/invalid_subset.yaml on connection={{ ansible_connection + }}" + +- name: test invalid subset (foobar) + become: true + register: result + ignore_errors: true + arista.eos.eos_facts: + gather_subset: + - foobar + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - "'Subset must be one of' in result.msg" + +- debug: msg="END eapi/invalid_subset.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml new file mode 100644 index 00000000..eb136076 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START eapi/not_hardware.yaml on connection={{ ansible_connection }}" + +- name: test not hardware + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - '!hardware' + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_filesystems is not defined + +- debug: msg="END eapi/not_hardware.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..9a45cccc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml @@ -0,0 +1,255 @@ +--- +- debug: msg="START eos_interface cli/basic.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Configure interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface (idempotent) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == false + +- name: Confgure interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Change interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-1" in result.commands' + - '"mtu 1800" in result.commands' + +- name: Disable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: true + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: Confgure second interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_2 }}' + description: test-interface-initial + mtu: 1800 + state: present + +- name: Add interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"mtu 2000" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"description test-interface-2" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Add interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: false + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: true + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: loopback interface setup + become: true + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- name: Create loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: present + +- assert: + that: + - result.changed == true + - '"interface loopback9" in result.commands' + - '"interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == true + - '"no interface loopback9" in result.commands' + - '"no interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_interface cli/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml new file mode 100644 index 00000000..8ed69dcf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml @@ -0,0 +1,162 @@ +--- +- debug: msg="START eos_interface cli/intent.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Check intent arguments + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: up + tx_rate: ge(0) + rx_rate: ge(0) + +- assert: + that: + - result.failed == false + +- name: Check intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: down + tx_rate: gt(0) + rx_rate: lt(0) + +- 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 + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: down + +- assert: + that: + - result.failed == false + +- name: Config + intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: up + +- assert: + that: + - result.failed == true + - "'state eq(up)' in result.failed_conditions" + +- name: Register show neighbors detail + become: true + register: show_lldp_neighbors_result + arista.eos.eos_command: + commands: + - show lldp neighbors management1 + +- block: + + - name: Check neighbors intent arguments + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Check neighbors intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: '"an-vyos-02" in show_lldp_neighbors_result.stdout[0]' + +- name: Aggregate config + intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + enabled: true + state: up + +- assert: + that: + - result.failed == false + +- block: + + - name: Aggregate neighbors intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Aggregate neighbors intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: "'an-vyos-02' in show_lldp_neighbors_result.stdout[0]" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml new file mode 100644 index 00000000..9064167a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START eos cli/net_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Configure interface (setup) + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface description using platform agnostic module + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface parameters + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- debug: msg="END eos cli/net_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..aaafd973 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml @@ -0,0 +1,255 @@ +--- +- debug: msg="START eos_interface eapi/basic.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Configure interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface (idempotent) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == false + +- name: Confgure interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Change interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-1" in result.commands' + - '"mtu 1800" in result.commands' + +- name: Disable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: true + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: Confgure second interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_2 }}' + description: test-interface-initial + mtu: 1800 + state: present + +- name: Add interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"mtu 2000" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"description test-interface-2" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Add interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: false + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: true + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: loopback interface setup + become: true + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- name: Create loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: present + +- assert: + that: + - result.changed == true + - '"interface loopback9" in result.commands' + - '"interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == true + - '"no interface loopback9" in result.commands' + - '"no interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_interface eapi/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml new file mode 100644 index 00000000..ffcab9e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml @@ -0,0 +1,167 @@ +--- +- debug: msg="START eos_interface eapi/intent.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Make sure LLDP is running + become: true + arista.eos.eos_config: + lines: lldp run + +- name: Check intent arguments + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: up + tx_rate: ge(0) + rx_rate: ge(0) + +- assert: + that: + - result.failed == false + +- name: Check intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: down + tx_rate: gt(0) + rx_rate: lt(0) + +- 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 + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: down + +- assert: + that: + - result.failed == false + +- name: Config + intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: up + +- assert: + that: + - result.failed == true + - "'state eq(up)' in result.failed_conditions" + +- name: Register show neighbors detail + become: true + register: show_lldp_neighbors_result + arista.eos.eos_command: + commands: + - show lldp neighbors management1 + +- block: + + - name: Check neighbors intent arguments + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Check neighbors intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: '"an-vyos-02" in show_lldp_neighbors_result.stdout[0]' + +- name: Aggregate config + intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + enabled: true + state: up + +- assert: + that: + - result.failed == false + +- block: + + - name: Aggregate neighbors intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Aggregate neighbors intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: "'an-vyos-02' in show_lldp_neighbors_result.stdout[0]" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml new file mode 100644 index 00000000..8bfb271e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START eos eapi/net_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Configure interface (setup) + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface description using platform agnostic module + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface parameters + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- debug: msg="END eos eapi/net_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg new file mode 100644 index 00000000..8288812b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg @@ -0,0 +1,12 @@ +interface Ethernet1 + description "Interface 1" + switchport + no shutdown + no mtu + speed forced 40gfull +interface Ethernet2 + no description + no shutdown + no switchport + mtu 3000 + speed auto diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..83b6cf71 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + description "this is interface for testing" +! +interface Ethernet2 + description "Configured by Ansible" + shutdown +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..04f9c181 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,5 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + src: reset.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..bf3283e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Returns interfaces to default parameters + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..eca1cc6e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..3502dddc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + + - assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..7d71274c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: layer3 + description: this is interface for testing + enabled: true + + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..1061e7ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + duplex: auto + enabled: true + + - name: Ethernet2 + mode: layer2 + duplex: auto + description: Configured by Ansible + enabled: false + + - name: Management1 + enabled: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Overrides device configuration of all interfaces with provided configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..5c27a4b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..21913323 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml @@ -0,0 +1,27 @@ +--- +- debug: + msg: START eos_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + enabled: true + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..bcb37339 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + duplex: auto + enabled: true + + - name: Ethernet2 + description: Configured by Ansible + duplex: auto + mode: layer2 + enabled: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Replaces device configuration of listed interfaces with provided configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..744985dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml @@ -0,0 +1,48 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + config2: + - name: Ethernet1 + mode: layer3 + enabled: true + description: Config to be reverted + +- name: Merge provided configuration with device configuration( Base config ) + register: baseconfig + become: true + arista.eos.eos_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(baseconfig.after) == [] + +- name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_interfaces: + config: '{{ config2 }}' + state: merged + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_interfaces: + config: "{{ ansible_facts['network_resources']['interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml new file mode 100644 index 00000000..bf23519b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml @@ -0,0 +1,17 @@ +--- +parsed: + config: + - name: Ethernet1 + description: 'this is interface for testing' + enabled: true + - name: Ethernet2 + description: 'Configured by Ansible' + enabled: false + +rendered: + - "interface Ethernet2" + - "speed 10full" + - "description Configured by Ansible" + - "shutdown" + - "interface Ethernet1" + - "no shutdown" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..58b3bc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml @@ -0,0 +1,110 @@ +--- +- debug: + msg: START eos_l2_interface cli/basic.yaml on connection={{ ansible_connection + }} + +- name: Delete test interface switchports + become: true + arista.eos.eos_l2_interface: &id008 + name: Ethernet1 + state: absent + +- name: Set switchport mode to access on vlan 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: present + mode: access + access_vlan: 4000 + +- assert: &id002 + that: + - result.changed == true + +- name: Set switchport mode to access on vlan 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: &id004 + that: + - result.changed == false + +- name: Change access vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id003 + name: Ethernet1 + state: present + mode: access + access_vlan: 4001 + +- assert: *id002 + +- name: Change access vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id003 + +- assert: *id004 + +- name: Change switchport mode to trunk + become: true + register: result + arista.eos.eos_l2_interface: &id005 + name: Ethernet1 + state: present + mode: trunk + +- assert: *id002 + +- name: Change switchport mode to trunk (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id005 + +- assert: *id004 + +- name: Change switchport mode to trunk and set native vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id006 + name: Ethernet1 + state: present + mode: trunk + native_vlan: 4001 + +- assert: *id002 + +- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id006 + +- assert: *id004 + +- name: Set trunk allowed vlans to 20 and 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id007 + name: Ethernet1 + state: present + mode: trunk + trunk_allowed_vlans: 20,4000 + +- assert: *id002 + +- name: Set trunk allowed vlans to 20 and 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id007 + +- assert: *id004 + +- name: Tear down switchports + become: true + arista.eos.eos_l2_interface: *id008 + +- debug: msg="END eos_l2_interface cli/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml new file mode 100644 index 00000000..b9aa2577 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml @@ -0,0 +1,39 @@ +--- +- debug: + msg: START eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection + }} + +- name: Create fake interface + become: true + arista.eos.eos_interface: + name: Management0 + +- block: + + - name: eos_l2_interface shouldn't fail + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: absent + + - assert: + that: "'Interface does not exist' in result.warnings[0]" + always: + + - name: Cleanup fake interface + become: true + ansible.netcommon.cli_config: + config: no interface Management0 + +- name: eos_l2_interface should still not fail + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: + that: result.warnings is not defined + +- debug: + msg: END eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..a2ca7143 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml @@ -0,0 +1,110 @@ +--- +- debug: + msg: START eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection + }} + +- name: Delete test interface switchports + become: true + arista.eos.eos_l2_interface: &id008 + name: Ethernet1 + state: absent + +- name: Set switchport mode to access on vlan 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: present + mode: access + access_vlan: 4000 + +- assert: &id002 + that: + - result.changed == true + +- name: Set switchport mode to access on vlan 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: &id004 + that: + - result.changed == false + +- name: Change access vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id003 + name: Ethernet1 + state: present + mode: access + access_vlan: 4001 + +- assert: *id002 + +- name: Change access vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id003 + +- assert: *id004 + +- name: Change switchport mode to trunk + become: true + register: result + arista.eos.eos_l2_interface: &id005 + name: Ethernet1 + state: present + mode: trunk + +- assert: *id002 + +- name: Change switchport mode to trunk (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id005 + +- assert: *id004 + +- name: Change switchport mode to trunk and set native vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id006 + name: Ethernet1 + state: present + mode: trunk + native_vlan: 4001 + +- assert: *id002 + +- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id006 + +- assert: *id004 + +- name: Set trunk allowed vlans to 20 and 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id007 + name: Ethernet1 + state: present + mode: trunk + trunk_allowed_vlans: 20,4000 + +- assert: *id002 + +- name: Set trunk allowed vlans to 20 and 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id007 + +- assert: *id004 + +- name: Tear down switchports + become: true + arista.eos.eos_l2_interface: *id008 + +- debug: msg="END eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml new file mode 100644 index 00000000..c94c2dda --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml @@ -0,0 +1,40 @@ +--- +- debug: + msg: START eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection + }} + +- name: Create fake interface + become: true + arista.eos.eos_interface: + name: Management0 + +- block: + + - name: eos_l2_interface shouldn't fail + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: absent + + - assert: + that: "'Interface does not exist' in result.warnings[0]" + always: + + - name: Cleanup fake interface + become: true + arista.eos.eos_config: + lines: + - no interface Management0 + +- name: eos_l2_interface should still not fail + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: + that: result.warnings is not defined + +- debug: + msg: END eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..de357afd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml @@ -0,0 +1,32 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + +- name: Clean up test state + include: '{{ role_path }}/tests/common/_cleanup.yml ansible_connection=ansible.netcommon.network_cli' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..630e6be6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml @@ -0,0 +1,32 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + +- name: Clean up test state + include: '{{ role_path }}/tests/common/_cleanup.yml ansible_connection=ansible.netcommon.network_cli' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml new file mode 100644 index 00000000..87412ed6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml @@ -0,0 +1,14 @@ +--- +- name: Remove all vlans + become: true + ansible.netcommon.cli_config: + config: no vlan 1-4094 + +- name: Completely remove vlans from interfaces + with_items: + - Ethernet1 + - Ethernet2 + become: true + ansible.netcommon.cli_config: + config: "interface {{ item }}\n no switchport mode\n no switchport access\ + \ vlan\n no switchport trunk native vlan\n" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..5f6297e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + switchport trunk native vlan 10 + switchport mode trunk +! +interface Ethernet2 + switchport access vlan 30 +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..023c4cb7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,36 @@ +--- +- name: Reset state + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " switchport access vlan 20" + - " no switchport mode" + - " no switchport trunk native vlan" + - " no switchport trunk allowed vlan" + - "interface Ethernet2" + - " no switchport access vlan" + - " switchport trunk native vlan 20" + - " switchport mode trunk" + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + access: + vlan: 20 + + - mode: trunk + name: Ethernet2 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..936a4f5c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml @@ -0,0 +1,42 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + + - name: Ethernet2 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Delete EOS L2 interfaces as in given arguments. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..398f8e2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_l2_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_l2_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..ca5af2df --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_l2_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_l2_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + + - assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..50fc8a29 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml @@ -0,0 +1,63 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + mode: trunk + access: + vlan: 20 + trunk: + native_vlan: 10 + + - name: Ethernet2 + mode: trunk + access: + vlan: 30 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..1fa59e11 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Override device configuration of all L2 interfaces on device with provided + configuration. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Ethernet1'}, {'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..6d040bcd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_l2_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..671e762a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..a866f305 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + trunk: + native_vlan: 20 + trunk_allowed_vlans: + - 5-10 + - '15' + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Replace device configuration of specified L2 interfaces with provided configuration. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'mode': 'trunk', 'name': 'Ethernet2', 'trunk':\ + \ {'native_vlan': 20}}, {'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..6819f5b1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml @@ -0,0 +1,75 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + config2: + + - name: Ethernet2 + access: + vlan: 30 + +- name: Merge provided configuration with device configuration (base config) + register: baseconfig + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Apply the provided configuration (config to be reverted) + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + mode: trunk + access: + vlan: 20 + trunk: + native_vlan: 10 + + - name: Ethernet2 + mode: trunk + access: + vlan: 30 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - result.after|symmetric_difference(expected_config) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_l2_interfaces: + config: "{{ ansible_facts['network_resources']['l2_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml new file mode 100644 index 00000000..549dc8a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml @@ -0,0 +1,17 @@ +--- +rendered: + - "interface Ethernet2" + - "switchport access vlan 30" + - "interface Ethernet1" + - "switchport mode trunk" + - "switchport trunk native vlan 10" + +parsed: + config: + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + - name: Ethernet2 + access: + vlan: 30 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..7b241101 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml @@ -0,0 +1,209 @@ +--- +- debug: + msg: START eos_l3_interface cli/basic.yaml on connection={{ ansible_connection + }} + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + ipv4_addr_1: 192.0.2.5/24 + ipv4_addr_2: 198.51.100.15/24 + ipv4_addr_3: 203.0.113.25/28 + ipv4_addr_4: 203.0.113.225/28 + ipv6_addr_1: 2001:DB8:123::/64 + ipv6_addr_2: 2001:DB8:ABC::/64 + ipv6_addr_3: 2001:DB8::/48 + ipv6_addr_4: 2001:DB8:FFFF::/90 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + arista.eos.eos_l3_interface: &id004 + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: &id001 + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + +- name: Configure interface ipv4 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id001 + +- assert: &id003 + that: + - result.changed == false + +- name: Change interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + +- name: Configure interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: &id002 + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure interface ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id002 + +- assert: *id003 + +- name: Change interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + +- name: Delete interface ipv4 and ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete interface ipv4 and ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: *id003 + +- name: Delete second interface ipv4 and ipv6 address (setup) + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_2 }}' + state: absent + +- name: Configure ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id005 + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_3 }}' + ipv6: '{{ ipv6_addr_3 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_3 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_3 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id005 + +- assert: *id003 + +- name: Change ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + ipv6: '{{ ipv6_addr_2 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_4 }}' + ipv6: '{{ ipv6_addr_4 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_4 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_4 }}" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id006 + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + state: absent + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id006 + +- assert: *id003 + +- debug: + msg: END eos_l3_interface cli/basic.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml new file mode 100644 index 00000000..6f3fbde7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START eos cli/net_l3_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address using platform agnostic module + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: 192.108.0.1/24 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address 192.108.0.1/24" in result.commands' + +- name: Delete interface ipv4 and ipv6 address(teardown) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- debug: msg="END eos cli/net_l3_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..2a3f2ec1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml @@ -0,0 +1,209 @@ +--- +- debug: + msg: START eos_l3_interface eapi/basic.yaml on connection={{ ansible_connection + }} + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + ipv4_addr_1: 192.0.2.5/24 + ipv4_addr_2: 198.51.100.15/24 + ipv4_addr_3: 203.0.113.25/28 + ipv4_addr_4: 203.0.113.225/28 + ipv6_addr_1: 2001:DB8:123::/64 + ipv6_addr_2: 2001:DB8:ABC::/64 + ipv6_addr_3: 2001:DB8::/48 + ipv6_addr_4: 2001:DB8:FFFF::/90 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + arista.eos.eos_l3_interface: &id004 + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: &id001 + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + +- name: Configure interface ipv4 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id001 + +- assert: &id003 + that: + - result.changed == false + +- name: Change interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + +- name: Configure interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: &id002 + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure interface ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id002 + +- assert: *id003 + +- name: Change interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + +- name: Delete interface ipv4 and ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete interface ipv4 and ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: *id003 + +- name: Delete second interface ipv4 and ipv6 address (setup) + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_2 }}' + state: absent + +- name: Configure ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id005 + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_3 }}' + ipv6: '{{ ipv6_addr_3 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_3 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_3 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id005 + +- assert: *id003 + +- name: Change ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + ipv6: '{{ ipv6_addr_2 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_4 }}' + ipv6: '{{ ipv6_addr_4 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_4 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_4 }}" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id006 + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + state: absent + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id006 + +- assert: *id003 + +- debug: + msg: END eos_l3_interface eapi/basic.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml new file mode 100644 index 00000000..b1c99d65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START eos eapi/net_l3_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address using platform agnostic module + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: 192.108.0.1/24 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address 192.108.0.1/24" in result.commands' + +- name: Delete interface ipv4 and ipv6 address(teardown) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- debug: msg="END eos eapi/net_l3_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..47c54811 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg new file mode 100644 index 00000000..08059b6e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg @@ -0,0 +1,10 @@ +interface Ethernet1 + ip address 192.0.2.12/24 + ip address 203.0.113.27/31 secondary + no ipv6 address +interface Ethernet2 + no ip address + ipv6 address 2001:db8::1/64 +interface Management1 + ip address dhcp + no ipv6 address diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..85c42127 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + ip address 198.51.100.14/24 +! +interface Ethernet2 + ip address 203.0.113.27/24 +! + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..95779005 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,34 @@ +--- +- name: Reset state + become: true + arista.eos.eos_config: + src: reset.cfg + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 192.0.2.12/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..0f944e75 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml @@ -0,0 +1,49 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + + - name: Ethernet2 + other_config: + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Delete EOS L3 interfaces as in given arguments. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..37e67b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..2d648b12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_l3_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_l3_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + + - assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..034de19d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml @@ -0,0 +1,70 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Merge provided configuration with device configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..71358a31 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml @@ -0,0 +1,55 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + ipv6: + + - address: 2001:db8:feed::1/96 + + - name: Ethernet2 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Override device configuration of all L3 interfaces on device with provided + configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..6f13973d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_l3_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..08e6f228 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml @@ -0,0 +1,24 @@ +--- +- set_fact: + config: + + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + + - name: Ethernet2 + ipv4: + - address: 203.0.113.27/24 + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..b61d99bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml @@ -0,0 +1,58 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.205/31 + other_config: + + - name: Ethernet1 + ipv4: + + - address: 192.0.2.12/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Replace device configuration of specified L3 interfaces with provided configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..a97c5f82 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml @@ -0,0 +1,82 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + config2: + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + +- name: Merge provided configuration with device configuration (base config). + register: baseconfig + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(baseconfig.after) + == [] + become: true + +- name: Merge provided configuration with device configuration (config to be reverted). + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - result.after|symmetric_difference(expected_config) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_l3_interfaces: + config: "{{ ansible_facts['network_resources']['l3_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml new file mode 100644 index 00000000..00f2a3c4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml @@ -0,0 +1,15 @@ +--- +parsed: + config: + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + - name: Ethernet2 + ipv4: + - address: 203.0.113.27/24 + +rendered: + - "interface Ethernet1" + - "ip address 198.51.100.14/24" + - "interface Ethernet2" + - "ip address 203.0.113.27/24" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg new file mode 100644 index 00000000..5e87c055 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg @@ -0,0 +1 @@ +lacp system-priority 20 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml new file mode 100644 index 00000000..d36c4d53 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml @@ -0,0 +1,19 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "lacp system-priority 10" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- set_fact: + expected_config: + system: + priority: 10 + +- assert: + that: + - expected_config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml new file mode 100644 index 00000000..166cadc0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml @@ -0,0 +1,28 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Returns lacp to default parameters + register: result + become: true + arista.eos.eos_lacp: + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - ansible_facts.network_resources.lacp == {} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml new file mode 100644 index 00000000..a550d502 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: START eos.eos_lacp empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lacp empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml new file mode 100644 index 00000000..a9779917 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lacp: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lacp + + - assert: + that: + - ansible_facts.network_resources.lacp == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml new file mode 100644 index 00000000..1469f286 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml @@ -0,0 +1,34 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + system: + priority: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Merge provided lacp configuration with device configuration + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml new file mode 100644 index 00000000..6549828f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml @@ -0,0 +1,21 @@ +--- +- debug: + msg: START eos_lacp parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + system: + priority: 20 + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lacp: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml new file mode 100644 index 00000000..679cc997 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml @@ -0,0 +1,26 @@ +--- +- debug: + msg: START eos_lacp rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + system: + priority: 20 + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "lacp system-priority 20" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml new file mode 100644 index 00000000..e5fee498 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml @@ -0,0 +1,34 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + system: + priority: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Replaces device lacp configuration with provided configuration + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..1db4d4d6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,4 @@ +interface Ethernet1 + lacp port-priority 30 + lacp rate fast +interface Ethernet2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..653b0c49 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,29 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " lacp port-priority 30" + - " lacp rate normal" + - "interface Ethernet2" + - " no lacp port-priority" + - " lacp rate fast" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + + - name: Ethernet2 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..d9811a70 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + other_config: + + - name: Ethernet2 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Returns vlans to default parameters + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..6de8fd2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lacp_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lacp_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..e4fec7bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lacp_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + + - assert: + that: + - ansible_facts.network_resources.lacp_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..f3d2a3e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml @@ -0,0 +1,48 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + + - name: Ethernet2 + rate: normal + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..ca03f684 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Overrides device configuration of all vlans with provided configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..1de8011d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + rate: fast + port_priority: 30 + - name: Ethernet2 + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lacp_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..43dc6a9d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- debug: + msg: START eos_lacp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + rate: fast + - name: Ethernet2 + rate: normal + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "interface Ethernet1" + - "lacp rate fast" + - "interface Ethernet2" + - "lacp rate normal" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..aa109de6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + port_priority: 45 + other_config: + + - name: Ethernet2 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Replaces device configuration of listed vlans with provided configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..a596c633 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml @@ -0,0 +1,64 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + rate: fast + + config2: + - name: Ethernet2 + port_priority: 20 + rate: fast + + +- name: Merge provided configuration with device configuration (base config) + register: baseconfig + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + rate: fast + + - name: Ethernet2 + port_priority: 20 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(result.after) == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_lacp_interfaces: + config: "{{ ansible_facts['network_resources']['lacp_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig.after | symmetric_difference(revert.after) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg new file mode 100644 index 00000000..fdaa5444 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg @@ -0,0 +1,4 @@ +interface Ethernet1 + channel-group 5 mode on +interface Ethernet2 + channel-group 5 mode on diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml new file mode 100644 index 00000000..dba69500 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml @@ -0,0 +1,24 @@ +--- +- name: Reset state + become: true + ansible.netcommon.cli_config: + config: "interface Ethernet1\n channel-group 5 mode on\ninterface Ethernet2\n\ + \ no channel-group\nno interface Port-Channel10\n" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- set_fact: + expected_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..863f560b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel5 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Delete EOS L3 interfaces as in given arguments. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..a1a42083 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..2c265100 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lag_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lag_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + + - assert: + that: + - ansible_facts.network_resources.lag_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..389c8069 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml @@ -0,0 +1,74 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel5 + members: + + - member: Ethernet2 + mode: 'on' + + change_config: + - name: Port-Channel5 + members: + + - member: Ethernet2 + mode: 'passive' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Merge provided configuration with device configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- set_fact: + expected_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + + - member: Ethernet2 + mode: 'on' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 + +- name: Merge provided configuration with device configuration, expect error. + become: true + ignore_errors: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ change_config }}' + state: merged + +- assert: + that: + - result.failed == true + - result.msg is defined + - '"Cannot change mode" in result.module_stderr' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..f7ca1ed2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel10 + members: + + - member: Ethernet2 + mode: 'on' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Override device configuration of all LAGs on device with provided configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..c694e5dc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lag_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result['parsed']) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..9fabbb6d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,22 @@ +--- +- set_fact: + config: + - name: 5 + members: + - member: Ethernet2 + mode: "on" + - member: Ethernet1 + mode: "on" + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..cf7eac88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,51 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel10 + members: + + - member: Ethernet2 + mode: 'on' + other_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Replace device configuration of specified LAGs with provided configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml new file mode 100644 index 00000000..01a7e807 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml @@ -0,0 +1,15 @@ +--- +parsed: + config: + - name: "Port-Channel5" + members: + - member: Ethernet1 + mode: "on" + - member: Ethernet2 + mode: "on" + +rendered: + - "interface Ethernet1" + - "channel-group 5 mode on" + - "interface Ethernet2" + - "channel-group 5 mode on" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml new file mode 100644 index 00000000..df2df8fd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml @@ -0,0 +1,198 @@ +--- +- debug: msg="START cli/basic.yaml" + +- name: setup - remove config used in test(part1) + become: true + arista.eos.eos_config: + lines: + - no interface port-channel 20 + - no interface port-channel 100 + provider: '{{ cli }}' + +- name: setup - remove config used in test(part2) + loop: + - interface Ethernet1 + - interface Ethernet2 + become: true + arista.eos.eos_config: + lines: + - no channel-group 20 + provider: '{{ cli }}' + parents: '{{ item }}' + +- name: create linkagg + become: true + register: result + arista.eos.eos_linkagg: &id001 + group: 20 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface port-channel 20' in result.commands" + +- name: create linkagg(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id001 + +- assert: + that: + - result.changed == false + +- name: set link aggregation group to members + become: true + register: result + arista.eos.eos_linkagg: &id002 + group: 20 + mode: active + members: + - Ethernet1 + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface Ethernet1' in result.commands" + - "'channel-group 20 mode active' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'channel-group 20 mode active' in result.commands" + +- name: set link aggregation group to members(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id002 + +- assert: + that: + - result.changed == false + +- name: remove link aggregation group from member + become: true + register: result + arista.eos.eos_linkagg: &id003 + group: 20 + mode: active + members: + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface Ethernet1' in result.commands" + - "'no channel-group 20' in result.commands" + +- name: remove link aggregation group from member(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id003 + +- assert: + that: + - result.changed == false + +- name: remove linkagg + become: true + register: result + arista.eos.eos_linkagg: &id004 + group: 20 + state: absent + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no interface port-channel 20' in result.commands" + +- name: remove linkagg(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id004 + +- assert: + that: + - result.changed == false + +- name: create aggregate of linkagg definitions + become: true + register: result + arista.eos.eos_linkagg: &id005 + aggregate: + + - group: 20 + min_links: 3 + + - group: 100 + min_links: 4 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface port-channel 20' in result.commands" + - "'port-channel min-links 3' in result.commands" + - "'interface port-channel 100' in result.commands" + - "'port-channel min-links 4' in result.commands" + +- name: create aggregate of linkagg definitions(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id005 + +- assert: + that: + - result.changed == false + +- name: remove aggregate of linkagg definitions + become: true + register: result + arista.eos.eos_linkagg: &id006 + aggregate: + + - group: 20 + min_links: 3 + + - group: 100 + min_links: 4 + provider: '{{ cli }}' + state: absent + +- 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) + become: true + register: result + arista.eos.eos_linkagg: *id006 + +- assert: + that: + - result.changed == false + +- name: teardown(part1) + become: true + arista.eos.eos_config: + lines: + - no interface port-channel 20 + - no interface port-channel 100 + provider: '{{ cli }}' + +- name: teardown(part2) + become: true + loop: + - interface Ethernet1 + - interface Ethernet2 + arista.eos.eos_config: + lines: + - no channel-group 20 + provider: '{{ cli }}' + parents: '{{ item }}' + +- debug: msg="END cli/basic.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml new file mode 100644 index 00000000..748ab308 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml @@ -0,0 +1,52 @@ +--- +- debug: msg="START eos_lldp cli/basic.yaml on connection={{ ansible_connection + }}" + +- name: Make sure LLDP is not running before tests + become: true + arista.eos.eos_config: + lines: no lldp run + +- name: Enable LLDP service + register: result + become: true + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"lldp run" in result.commands' + +- name: Enable LLDP service again (idempotent) + register: result + become: true + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP service + register: result + become: true + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == true + - '"no lldp run" in result.commands' + +- name: Disable LLDP service (idempotent) + register: result + become: true + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_lldp cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml new file mode 100644 index 00000000..ea5f6b11 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml @@ -0,0 +1,52 @@ +--- +- debug: msg="START eos_lldp eapi/basic.yaml on connection={{ ansible_connection + }}" + +- name: Make sure LLDP is not running before tests + become: true + arista.eos.eos_config: + lines: no lldp run + +- name: Enable LLDP service + become: true + register: result + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"lldp run" in result.commands' + +- name: Enable LLDP service again (idempotent) + become: true + register: result + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP service + become: true + register: result + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == true + - '"no lldp run" in result.commands' + +- name: Disable LLDP service (idempotent) + become: true + register: result + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_lldp eapi/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg new file mode 100644 index 00000000..b507f3f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg @@ -0,0 +1,6 @@ +lldp timer 3000 +lldp holdtime 100 +lldp reinit 5 +no lldp tlv-select management-address +no lldp tlv-select system-description + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml new file mode 100644 index 00000000..ca00bed6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml @@ -0,0 +1,28 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "lldp timer 3000" + - "lldp holdtime 100" + - "lldp reinit 5" + - "no lldp tlv-select management-address" + - "no lldp tlv-select system-description" + - "lldp tlv-select port-description" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: false + system_description: false + +- assert: + that: + - expected_config == ansible_facts.network_resources.lldp_global diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml new file mode 100644 index 00000000..fc8b8f88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml @@ -0,0 +1,28 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Returns LLDP configuration to default parameters + register: result + become: true + arista.eos.eos_lldp_global: + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- assert: + that: + - ansible_facts.network_resources.lldp_global == {} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml new file mode 100644 index 00000000..ea65cfd2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: START eos.eos_lldp_global empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lldp_global empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml new file mode 100644 index 00000000..1c33a2b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_global gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lldp_global: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + + - assert: + that: + - ansible_facts.network_resources.lldp_global == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml new file mode 100644 index 00000000..0b3e414c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Merge provided LLDP configuration with device configuration + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: false + port_description: false + +- assert: + that: + - ansible_facts.network_resources.lldp_global == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml new file mode 100644 index 00000000..94f6bbea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lldp_global: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml new file mode 100644 index 00000000..80b90b57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml @@ -0,0 +1,21 @@ +--- +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml new file mode 100644 index 00000000..eb209ecd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Replaces device configuration with provided LLDP configuration + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- set_fact: + expected_config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + +- assert: + that: + - ansible_facts.network_resources.lldp_global == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml new file mode 100644 index 00000000..e8ee687d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml @@ -0,0 +1,17 @@ +--- +parsed: + config: + holdtime: 100 + timer: 3000 + reinit: 5 + tlv_select: + management_address: false + system_description: false + +rendered: + - "lldp holdtime 100" + - "lldp timer None" + - "no lldp tlv-select port-description" + - "lldp tlv-select system-description" + - "no lldp tlv-select management-address" + - "lldp reinit None" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..0bc2f5f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,5 @@ +interface Ethernet1 + no lldp transmit +interface Ethernet2 + no lldp transmit + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..6cba9bf9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,29 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " no lldp receive" + - " lldp transmit" + - "interface Ethernet2" + - " lldp receive" + - " no lldp transmit" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + receive: false + + - name: Ethernet2 + transmit: false + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..87f3aebe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + expected_config: + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Returns interface lldp parameterss to default parameters + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..2fae304c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..0f2fde22 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lldp_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + + - assert: + that: + - ansible_facts.network_resources.lldp_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..8e7375b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml @@ -0,0 +1,51 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + transmit: false + receive: false + + - name: Ethernet2 + transmit: false + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..10fec735 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,38 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Override the LLDP configuration of all interfaces with provided configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- assert: + that: + - config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..1f235217 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + transmit: false + - name: Ethernet2 + transmit: false + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lldp_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..8331802e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- debug: + msg: START eos_lldp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + transmit: false + - name: Ethernet2 + transmit: false + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "interface Ethernet1" + - "no lldp transmit" + - "interface Ethernet2" + - "no lldp transmit" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..1dc1b0ce --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + other_config: + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Replace existing LLDP configuration of specified interfaces with provided + configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..ce910f4b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml @@ -0,0 +1,63 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + transmit: false + + config2: + + - name: Ethernet2 + receive: false + +- name: Merge provided configuration with device configuration(base config). + register: baseconfig + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration(config to be reverted). + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + transmit: false + receive: false + + - name: Ethernet2 + transmit: false + receive: false + +- assert: + that: + - expected_config|symmetric_difference(result.after) == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_lldp_interfaces: + config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml new file mode 100644 index 00000000..87d5a464 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml @@ -0,0 +1,155 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Set up host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Set up host logging again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == false + +- name: Delete/disable host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Console logging with level warnings + become: true + register: result + arista.eos.eos_logging: + dest: console + level: warnings + state: present + +- assert: + that: + - result.changed == true + - '"logging console warnings" in result.commands' + +- name: Configure buffer size + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 480000 + +- assert: + that: + - result.changed == true + - '"logging buffered 480000" in result.commands' + +- name: Set up logging destination and facility at the same time + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 4096 + facility: local7 + level: informational + state: present + +- assert: + that: + - result.changed == true + - '"logging buffered 4096 informational" in result.commands' + - '"logging facility local7" in result.commands' + +- name: Set up logging destination and facility at the same time again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 4096 + facility: local7 + level: informational + state: present + +- assert: + that: + - result.changed == false + +- name: Set up logging facility alone + become: true + register: result + arista.eos.eos_logging: + facility: local2 + state: present + +- assert: + that: + - result.changed == true + - '"logging facility local2" in result.commands' + +- name: Set up logging facility (idempotent) + become: true + register: result + arista.eos.eos_logging: + facility: local2 + state: present + +- assert: + that: + - result.changed == false + +- name: remove logging as collection tearDown + become: true + register: result + arista.eos.eos_logging: + aggregate: + + - dest: console + level: warnings + state: absent + + - dest: buffered + level: informational + size: 4096 + state: absent + + - facility: local2 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging console" in result.commands' + - '"no logging buffered" in result.commands' + - '"no logging facility local2" in result.commands' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml new file mode 100644 index 00000000..947ab02c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_logging.yaml on connection={{ ansible_connection + }}" + +- name: Delete/disable host logging- setup + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- name: Set up host logging using platform agnostic module + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging- teardown + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- debug: msg="END eos cli/net_logging.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml new file mode 100644 index 00000000..afa2bea9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml @@ -0,0 +1,97 @@ +--- +- debug: msg="START eapi/basic.yaml on connection={{ ansible_connection }}" + +- name: Set up host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Set up host logging again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == false + +- name: Delete/disable host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Console logging with level warnings + become: true + register: result + arista.eos.eos_logging: + dest: console + level: warnings + state: present + +- assert: + that: + - result.changed == true + - '"logging console warnings" in result.commands' + +- name: Configure buffer size + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 480000 + +- assert: + that: + - result.changed == true + - '"logging buffered 480000" in result.commands' + +- name: remove logging as collection tearDown + become: true + register: result + arista.eos.eos_logging: + aggregate: + + - dest: console + level: warnings + state: absent + + - dest: buffered + size: 480000 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging console" in result.commands' + - '"no logging buffered" in result.commands' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml new file mode 100644 index 00000000..452728db --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos eapi/net_logging.yaml on connection={{ ansible_connection + }}" + +- name: Delete/disable host logging- setup + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- name: Set up host logging using platform agnostic module + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging- teardown + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- debug: msg="END eos eapi/net_logging.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg new file mode 100644 index 00000000..3a4b518c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg @@ -0,0 +1,17 @@ +interface Vlan2 + ospfv3 ipv4 area 0.0.0.6 + ospfv3 ipv4 hello-interval 45 + ospfv3 ipv4 retransmit-interval 100 +interface Vlan1 + ip ospf dead-interval 29 + ip ospf mtu-ignore + ip ospf hello-interval 66 + ospfv3 hello-interval 77 + ospfv3 cost 106 + ospfv3 transmit-delay 100 + ospfv3 ipv4 area 0.0.0.5 + ospfv3 ipv4 priority 45 + ospfv3 ipv6 retransmit-interval 115 + ospfv3 ipv6 dead-interval 56 + ospfv3 ipv6 passive-interface + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..8043f970 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,17 @@ +interface Vlan1 + ip ospf dead-interval 29 + ip ospf mtu-ignore + ip ospf hello-interval 66 + ospfv3 hello-interval 77 + ospfv3 cost 106 + ospfv3 transmit-delay 100 + ospfv3 ipv4 area 0.0.0.5 + ospfv3 ipv4 priority 45 + ospfv3 ipv6 retransmit-interval 115 + ospfv3 ipv6 dead-interval 56 + ospfv3 ipv6 passive-interface +interface Vlan2 + ospfv3 ipv4 area 0.0.0.6 + ospfv3 ipv4 hello-interval 45 + ospfv3 ipv4 retransmit-interval 100 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml new file mode 100644 index 00000000..690eff73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no interface Vlan1" + - "no interface Vlan2" + - "no interface Vlan3" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..8a642e3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start eos_ospf_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: delete given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + - afi: "ipv6" + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 12 + - result.changed == true + - result.commands|symmetric_difference(deleted.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..7024fae6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START eos_ospf_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..abc1a841 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml @@ -0,0 +1,29 @@ +--- +- debug: + msg: Start eos_ospf_interfaces gathered integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.changed == false + - result.gathered|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..56c773de --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: Start eos_ospf_interfaces merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: merge given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 16 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..3b483610 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml @@ -0,0 +1,51 @@ +--- +- debug: + msg: Start eos_ospf_interfaces overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: overridde device ocnfiguration with given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv6" + cost: 44 + bfd: true + ip_params: + - afi: "ipv6" + mtu_ignore: true + network: "point-to-point" + dead_interval: 56 + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 18 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..db22340a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospf_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospf_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result.parsed) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..04bcce8c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: Start eos_ospf_interfaces rendered integration tests ansible_connection={{ + ansible_connection }} + + +- block: + + - name: render native config + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..aff1c14d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml @@ -0,0 +1,51 @@ +--- +- debug: + msg: Start eos_ospf_interfaces replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: replace device ocnfiguration with given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv6" + cost: 44 + bfd: true + ip_params: + - afi: "ipv6" + mtu_ignore: true + network: "point-to-point" + dead_interval: 56 + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 14 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..e65ba878 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml @@ -0,0 +1,80 @@ +--- +- debug: + msg: Start eos_ospf_interfaces rtt integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: merge given ospf interfaces configuration + become: true + register: baseconfig + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - baseconfig.commands|length == 16 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Apply the provided configuration (config to be reverted) check + become: true + register: result + arista.eos.eos_ospf_interfaces: + config: + - name: "Vlan2" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospf_interfaces: + config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml new file mode 100644 index 00000000..801ddfe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml @@ -0,0 +1,126 @@ +--- +deleted: + commands: + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - no ospfv3 cost 106 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 dead-interval 56 + - no ospfv3 ipv6 retransmit-interval 115 +merged: + commands: + - interface Vlan1 + - ip ospf dead-interval 29 + - ip ospf mtu-ignore + - ip ospf hello-interval 66 + - ospfv3 hello-interval 77 + - ospfv3 cost 106 + - ospfv3 transmit-delay 100 + - ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv4 priority 45 + - ospfv3 ipv6 retransmit-interval 115 + - ospfv3 ipv6 dead-interval 56 + - ospfv3 ipv6 passive-interface + - interface Vlan2 + - ospfv3 ipv4 area 0.0.0.6 + - ospfv3 ipv4 hello-interval 45 + - ospfv3 ipv4 retransmit-interval 100 +replaced: + commands: + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - ospfv3 cost 44 + - ospfv3 bfd + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv6 mtu-ignore + - ospfv3 ipv6 network point-to-point + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 retransmit-interval 115 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 +overridden: + commands: + - interface Vlan2 + - no ospfv3 ipv4 hello-interval 45 + - no ospfv3 ipv4 retransmit-interval 100 + - no ospfv3 ipv4 area 0.0.0.6 + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - ospfv3 cost 44 + - ospfv3 bfd + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv6 mtu-ignore + - ospfv3 ipv6 network point-to-point + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 retransmit-interval 115 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 +roundtrip: + commands: + - interface GigabitEthernet0/1 + - ip access-group aclv401 in +gathered: + config: + - name: Loopback888 + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 + - name: GigabitEthernet0/2 + - name: GigabitEthernet0/3 +parsed: + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + hello_interval: 66 + mtu_ignore: true + - afi: "ipv6" + cost: 106 + hello_interval: 77 + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - afi: "ipv6" + dead_interval: 56 + passive_interface: true + retransmit_interval: 115 + transmit_delay: 100 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg new file mode 100644 index 00000000..7d40fa3a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg @@ -0,0 +1,18 @@ +router ospf 1 + router-id 170.21.0.4 + distance ospf intra-area 85 + redistribute static + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + max-lsa 8000 40 ignore-count 3 ignore-time 6 reset-time 20 + adjacency exchange-start threshold 20045623 + default-information originate metric 100 metric-type 1 + exit +router ospf 2 vrf vrf01 + area 0.0.0.9 default-cost 20 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + exit +router ospf 3 vrf vrf02 + redistribute connected diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg new file mode 100644 index 00000000..ffc94513 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg @@ -0,0 +1,16 @@ +router ospf 1 + adjacency exchange-start threshold 20045623 + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + default-information originate metric 100 metric-type 1 + distance ospf intra-area 85 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + redistribute static + router-id 170.21.0.4 +router ospf 2 vrf vrf01 + area 0.0.0.9 default-cost 20 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 +router ospf 3 vrf vrf02 + redistribute connected diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml new file mode 100644 index 00000000..663ad5fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router ospf 1" + - "no router ospf 2" + - "no router ospf 3" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml new file mode 100644 index 00000000..e305ed6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_ospfv2 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &deleted + config: + processes: + - process_id: 1 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router ospf 1' in result.commands" + - ansible_facts.network_resources.ospfv2 == result.after + - result.after.processes|symmetric_difference(deleted.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml new file mode 100644 index 00000000..13f26211 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_ospfv2 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml new file mode 100644 index 00000000..55193fa2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_ospfv2 gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_ospfv2: + config: + state: gathered + + - name: Assert + assert: + that: + - gathered.config == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml new file mode 100644 index 00000000..626a2d25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml @@ -0,0 +1,75 @@ +--- +- debug: + msg: Start eos_ospfv2 merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &merged + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: 10.10.2.0/24 + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + + - assert: + that: + - result.commands|length == 18 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.processes|symmetric_difference(merged.after.processes) == [] + - result.before == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml new file mode 100644 index 00000000..7df9f820 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start eos_ospfv2 overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &overridden + config: + processes: + - process_id: 2 + vrf: "vrf01" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + redistribute: + - routes: "isis" + isis_level: "level-1" + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - ansible_facts.network_resources.ospfv2 == result.after + - result.after.processes|symmetric_difference(overridden.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml new file mode 100644 index 00000000..69c0d34e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospfv2_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospfv2: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml new file mode 100644 index 00000000..06621a5d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: Start eos_ospfv2 replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &replaced + config: + processes: + - process_id: 2 + vrf: "vrf01" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + redistribute: + - routes: "isis" + isis_level: "level-1" + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 4 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.processes|symmetric_difference(replaced.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml new file mode 100644 index 00000000..77402db9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml @@ -0,0 +1,100 @@ +--- +- debug: + msg: Start eos_ospfv2 round trip integration tests ansible_connection={{ ansible_connection + }} + +- block: + + - name: merge attributes of given ospfv2(apply base config). + become: true + register: base_config + arista.eos.eos_ospfv2: + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: 10.10.2.0/24 + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - base_config.commands|length == 18 + - base_config.changed == true + - base_config.commands|symmetric_difference(merged.commands) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_ospfv2: + config: + processes: + - process_id: 1 + areas: + - area_id: "0.0.0.9" + default_cost: 20 + redistribute: + - routes: "isis" + isis_level: "level-1" + - process_id: 3 + vrf: "vrf02" + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospfv2: + config: "{{ ansible_facts['network_resources']['ospfv2'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: base_config.after == revert.after + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml new file mode 100644 index 00000000..36862ab6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml @@ -0,0 +1,318 @@ +--- +merged: + commands: + - router ospf 1 + - adjacency exchange-start threshold 20045623 + - area 0.0.0.2 filter 10.1.1.0/24 + - area 0.0.0.50 range 172.20.0.0/16 cost 34 + - default-information originate metric 100 metric-type 1 + - distance ospf intra-area 85 + - max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + - network 10.10.2.0/24 area 0.0.0.0 + - network 10.10.3.0/24 area 0.0.0.0 + - redistribute static + - router-id 170.21.0.4 + - exit + - router ospf 2 vrf vrf01 + - area 0.0.0.9 default-cost 20 + - exit + - router ospf 3 vrf vrf02 + - redistribute connected + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 12000 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +deleted: + after: + processes: + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +replaced: + commands: + - router ospf 2 vrf vrf01 + - no area 0.0.0.9 default-cost 20 + - redistribute isis level-1 + - exit + before: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + redistribute: + - routes: "isis" + isis_level: "level-1" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +overridden: + commands: + - router ospf 2 vrf vrf01 + - no area 0.0.0.9 default-cost 20 + - redistribute isis level-1 + - exit + - no router ospf 1 + - no router ospf 3 + after: + processes: + - process_id: 2 + vrf: "vrf01" + redistribute: + - routes: "isis" + isis_level: "level-1" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 +gathered: + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +parsed: + config: + processes: + - adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + process_id: 1 + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg new file mode 100644 index 00000000..6cc382d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg @@ -0,0 +1,46 @@ +router ospfv3 + fips restrictions + area 0.0.0.20 stub + area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + area 0.0.0.40 default-cost 45 + area 0.0.0.40 stub + timers pacing flood 7 + adjacency exchange-start threshold 11 + address-family ipv4 + fips restrictions + redistribute connected + exit + address-family ipv6 + router-id 10.1.1.1 + fips restrictions + exit + exit +router ospfv3 vrf vrf01 + bfd all-interfaces + fips restrictions + area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + log-adjacency-changes detail + address-family ipv4 + passive-interface default + fips restrictions + redistribute connected route-map MAP01 + maximum-paths 100 + exit + address-family ipv6 + fips restrictions + area 0.0.0.10 nssa no-summary + default-information originate route-map DefaultRouteFilter + max-metric router-lsa external-lsa 25 summary-lsa + exit + exit +router ospfv3 vrf vrf02 + fips restrictions + address-family ipv6 + router-id 10.17.0.3 + distance ospf intra-area 200 + fips restrictions + area 0.0.0.1 stub + timers throttle spf 56 56 56 + timers out-delay 10 + exit + exit diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg new file mode 100644 index 00000000..6cc382d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg @@ -0,0 +1,46 @@ +router ospfv3 + fips restrictions + area 0.0.0.20 stub + area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + area 0.0.0.40 default-cost 45 + area 0.0.0.40 stub + timers pacing flood 7 + adjacency exchange-start threshold 11 + address-family ipv4 + fips restrictions + redistribute connected + exit + address-family ipv6 + router-id 10.1.1.1 + fips restrictions + exit + exit +router ospfv3 vrf vrf01 + bfd all-interfaces + fips restrictions + area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + log-adjacency-changes detail + address-family ipv4 + passive-interface default + fips restrictions + redistribute connected route-map MAP01 + maximum-paths 100 + exit + address-family ipv6 + fips restrictions + area 0.0.0.10 nssa no-summary + default-information originate route-map DefaultRouteFilter + max-metric router-lsa external-lsa 25 summary-lsa + exit + exit +router ospfv3 vrf vrf02 + fips restrictions + address-family ipv6 + router-id 10.17.0.3 + distance ospf intra-area 200 + fips restrictions + area 0.0.0.1 stub + timers throttle spf 56 56 56 + timers out-delay 10 + exit + exit diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml new file mode 100644 index 00000000..9e3c3a05 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router ospfv3" + - "no router ospfv3 vrf vrf01" + - "no router ospfv3 vrf vrf02" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml new file mode 100644 index 00000000..3f908cb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_ospfv3 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &deleted + config: + processes: + - vrf: "vrf01" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv3 + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router ospfv3 vrf vrf01' in result.commands" + - ansible_facts.network_resources.ospfv3 == result.after + - result.after.processes|symmetric_difference(deleted.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml new file mode 100644 index 00000000..6907b699 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_ospfv3 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml new file mode 100644 index 00000000..e326aefa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_ospfv3 gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_ospfv3: + config: + state: gathered + + - name: Assert + assert: + that: + - populate.before == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml new file mode 100644 index 00000000..80aefc63 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml @@ -0,0 +1,117 @@ +--- +- debug: + msg: Start eos_ospfv3 merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &merged + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 46 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.processes|symmetric_difference(populate.before.processes) == [] + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml new file mode 100644 index 00000000..2014b5da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: Start eos_ospfv3 overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &overridden + state: overridden + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 16 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after.processes|symmetric_difference(overridden.after.processes) == [] + - result.before.processes|symmetric_difference(populate.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml new file mode 100644 index 00000000..58f18eba --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospfv3: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed.processes|symmetric_difference(populate.before.processes) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml new file mode 100644 index 00000000..8cf0656c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml @@ -0,0 +1,102 @@ +--- +- debug: + msg: START eos_ospfv3 rendered integration tests on connection={{ ansible_connection + }} + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_ospfv3: + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml new file mode 100644 index 00000000..61885a8c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: Start eos_ospfv3 replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &replaced + state: replaced + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 14 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.processes|symmetric_difference(replaced.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml new file mode 100644 index 00000000..553e71fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml @@ -0,0 +1,148 @@ +--- +- debug: + msg: Start eos_ospfv3 rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv3 configuration + become: true + register: baseconfig + arista.eos.eos_ospfv3: &merged + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + + - assert: + that: + - baseconfig.commands|length == 46 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after.processes|symmetric_difference(populate.before.processes) == [] + - baseconfig.before == {} + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv3 + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_ospfv3: + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospfv3: + config: "{{ ansible_facts['network_resources']['ospfv3'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml new file mode 100644 index 00000000..e1fe0fcc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml @@ -0,0 +1,449 @@ +--- +merged: + commands: + - router ospfv3 vrf vrf01 + - address-family ipv4 + - redistribute connected route-map MAP01 + - fips restrictions + - maximum-paths 100 + - passive-interface default + - exit + - address-family ipv6 + - area 0.0.0.10 nssa no-summary + - default-information originate route-map DefaultRouteFilter + - fips restrictions + - max-metric router-lsa external-lsa 25 summary-lsa + - exit + - area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + - bfd all-interfaces + - fips restrictions + - log-adjacency-changes detail + - exit + - router ospfv3 + - address-family ipv4 + - redistribute connected + - fips restrictions + - exit + - address-family ipv6 + - fips restrictions + - router-id 10.1.1.1 + - exit + - adjacency exchange-start threshold 11 + - area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + - area 0.0.0.20 stub + - area 0.0.0.40 default-cost 45 + - area 0.0.0.40 stub + - fips restrictions + - timers pacing flood 7 + - exit + - router ospfv3 vrf vrf02 + - address-family ipv6 + - area 0.0.0.1 stub + - distance ospf intra-area 200 + - fips restrictions + - router-id 10.17.0.3 + - timers out-delay 10 + - timers throttle spf 56 56 56 + - exit + - fips restrictions + - exit + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 12000 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +deleted: + after: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" +replaced: + commands: + - router ospfv3 vrf vrf02 + - address-family ipv6 + - no fips restrictions + - no router-id + - no timers out-delay 10 + - no timers throttle spf 56 56 56 + - redistribute static + - exit + - address-family ipv4 + - area 0.0.0.3 range 60.1.0.0/16 cost 30 + - timers lsa arrival 10 + - exit + - no fips restrictions + - exit + before: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + after: + processes: + - address_family: + - afi: "ipv4" + redistribute: + - routes: "connected" + - afi: "ipv6" + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: "60.1.0.0/16" + cost: 30 + timers: + lsa: 10 + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + vrf: "vrf02" +overridden: + commands: + - no router ospfv3 + - no router ospfv3 vrf vrf01 + - router ospfv3 vrf vrf02 + - address-family ipv6 + - no fips restrictions + - no router-id + - no timers out-delay 10 + - no timers throttle spf 56 56 56 + - redistribute static + - exit + - address-family ipv4 + - area 0.0.0.3 range 60.1.0.0/16 cost 30 + - timers lsa arrival 10 + - exit + - no fips restrictions + - exit + after: + processes: + - address_family: + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: "60.1.0.0/16" + cost: 30 + timers: + lsa: 10 + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + vrf: "vrf02" +populate: + before: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml new file mode 100644 index 00000000..477df469 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml new file mode 100644 index 00000000..679a7144 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/eapi" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml new file mode 100644 index 00000000..9806e592 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml @@ -0,0 +1,6 @@ +--- +- include: cli.yaml + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml new file mode 100644 index 00000000..c16f7ca7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml @@ -0,0 +1,109 @@ +--- +# arista.eos.eos_config -> NetworkConfig, dumps + +- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}" + +- name: setup + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ cli }}" + become: true + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ cli }}" + become: true + register: config + +- name: configure hostname + arista.eos.eos_config: + lines: hostname foo + config: "{{ config.stdout[0] }}" + provider: "{{ cli }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ cli }}" + become: true + register: config + +- name: teardown + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ cli }}" + become: true + +# hit block and diffs +- block: + - name: setup + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + provider: "{{ cli }}" + become: true + + - name: configure sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ cli }}" + match: line + become: true + register: result + + - assert: + that: + - "result.changed == true" + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + + - name: check sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ cli }}" + match: exact + become: true + register: result + + always: + - name: teardown + arista.eos.eos_config: + lines: no ip access-list test + match: none + provider: "{{ cli }}" + become: true + +- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml new file mode 100644 index 00000000..1e7d30a7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml @@ -0,0 +1,66 @@ +--- +# eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix +# eos_interface -> conditional +# eos_command -> ComplexList + +- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList +- name: setup - remove config used in test + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ cli }}" + become: true + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ cli }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/250 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ cli }}" + become: true + register: result + ignore_errors: true + +- assert: + that: + - "result.failed == true" + +- name: teardown + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ cli }}" + become: true + +- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit conditional() +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Check intent arguments + eos_interface: + name: "{{ test_interface_1 }}" + state: up + tx_rate: ge(0) + rx_rate: ge(0) + provider: "{{ cli }}" + become: true + register: result diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml new file mode 100644 index 00000000..03841f28 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}" + + +# test become and unbecome +- block: + - name: command that does require become (should fail) + arista.eos.eos_command: + commands: show running-config + become: false + ignore_errors: true + register: result + + - assert: + that: + - 'result.failed == true' + - '"privileged mode required" in result.msg' + + - name: command that doesn't require become + arista.eos.eos_command: + commands: show uptime + become: false + + - name: wrong transport specified in provider + arista.eos.eos_command: + commands: show version + provider: "{{ eapi }}" + + when: "ansible_connection != 'local'" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml new file mode 100644 index 00000000..20f886fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml @@ -0,0 +1,20 @@ +--- +- block: + - cli_command: + command: reload power + prompt: + - "yes/no/cancel/diff]" + - "confirm]" + answer: + - "no" + - "" + check_all: true + become: true + + - wait_for_connection: + delay: 20 + sleep: 10 + + - cli_command: + command: show version + when: ansible_connection.endswith("network_cli") diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml new file mode 100644 index 00000000..f5cceb55 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml @@ -0,0 +1,109 @@ +--- +# arista.eos.eos_config -> NetworkConfig, dumps + +- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}" + +- name: setup + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ eapi }}" + become: true + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ eapi }}" + become: true + register: config + +- name: configure hostname + arista.eos.eos_config: + lines: hostname foo + config: "{{ config.stdout[0] }}" + provider: "{{ eapi }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ eapi }}" + become: true + register: config + +- name: teardown + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ eapi }}" + become: true + +# hit block and diffs +- block: + - name: setup + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + provider: "{{ eapi }}" + become: true + + - name: configure sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ eapi }}" + match: line + become: true + register: result + + - assert: + that: + - "result.changed == true" + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + + - name: check sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ eapi }}" + match: exact + become: true + register: result + + always: + - name: teardown + arista.eos.eos_config: + lines: no ip access-list test + match: none + provider: "{{ eapi }}" + become: true + +- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml new file mode 100644 index 00000000..66f369f9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml @@ -0,0 +1,66 @@ +--- +# arista.eos.eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix +# arista.eos.eos_interface -> conditional +# arista.eos.eos_command -> ComplexList + +- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList +- name: setup - remove config used in test + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ eapi }}" + become: true + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ eapi }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/250 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ eapi }}" + become: true + register: result + ignore_errors: true + +- assert: + that: + - "result.failed == true" + +- name: teardown + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ eapi }}" + become: true + +- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit conditional() +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Check intent arguments + arista.eos.eos_interface: + name: "{{ test_interface_1 }}" + state: up + tx_rate: ge(0) + rx_rate: ge(0) + provider: "{{ eapi }}" + become: true + register: result diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml new file mode 100644 index 00000000..3b8bca3c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml @@ -0,0 +1,126 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + - no ip route 192.168.4.0/24 192.168.0.1 + - no ip route 192.168.5.0/24 192.168.0.1 + provider: '{{ cli }}' + +- name: configure static route + become: true + register: result + arista.eos.eos_static_route: &id001 + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route(Idempotence) + become: true + register: result + arista.eos.eos_static_route: *id001 + +- assert: + that: + - result.changed == false + +- name: delete static route + become: true + register: result + arista.eos.eos_static_route: &id002 + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + state: absent + +- assert: + that: + - result.changed == true + - "'no ip route 192.168.3.0/24 192.168.0.1' in result.commands" + +- name: delete static route + become: true + register: result + arista.eos.eos_static_route: *id002 + +- assert: + that: + - result.changed == false + +- name: configure static routes using aggregate + become: true + register: result + arista.eos.eos_static_route: &id003 + aggregate: + + - address: 192.168.4.0/24 + next_hop: 192.168.0.1 + + - address: 192.168.5.0/24 + next_hop: 192.168.0.1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.4.0/24 192.168.0.1 1' in result.commands" + - "'ip route 192.168.5.0/24 192.168.0.1 1' in result.commands" + +- name: configure static routes using aggregate(Idemporence) + become: true + register: result + arista.eos.eos_static_route: *id003 + +- assert: + that: + - result.changed == false + +- name: delete static routes using aggregate + become: true + register: result + arista.eos.eos_static_route: &id004 + aggregate: + + - address: 192.168.4.0/24 + next_hop: 192.168.0.1 + + - address: 192.168.5.0/24 + next_hop: 192.168.0.1 + state: absent + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no ip route 192.168.4.0/24 192.168.0.1' in result.commands" + - "'no ip route 192.168.5.0/24 192.168.0.1' in result.commands" + +- name: delete static routes using aggregate(Idempotence) + become: true + register: result + arista.eos.eos_static_route: *id004 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + - no ip route 192.168.4.0/24 192.168.0.1 + - no ip route 192.168.5.0/24 192.168.0.1 + provider: '{{ cli }}' + +- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml new file mode 100644 index 00000000..69e1bdff --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_static_route.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: '{{ cli }}' + +- name: configure static route using platform agnostic module + become: true + register: result + ansible.netcommon.net_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: teardown - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_static_route.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg new file mode 100644 index 00000000..a4bb4d65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +ip route 10.1.1.0/24 Management1 +ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200 +ip route 10.50.0.0/16 Management1 +ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42 +ip route vrf testvrf 120.1.1.0/24 Ethernet1 23 +ip route vrf vrftest1 77.77.1.0/24 33.1.1.1 +ipv6 route 1000:10::/64 Ethernet1 67 tag 98 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml new file mode 100644 index 00000000..24c16dbb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml @@ -0,0 +1,15 @@ +--- +- name: Setup + become: true + + arista.eos.eos_config: + lines: + - "vrf definition testvrf" + - "vrf definition vrftest1" + - "ip route 10.1.1.0/24 Management1" + - "ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" + - "ip route 10.50.0.0/16 Management1" + - "ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" + - "ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" + - "ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" + - "ipv6 route 1000:10::/64 Ethernet1 67 tag 98" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0377bcad --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml @@ -0,0 +1,30 @@ +--- +- name: Remove routes + become: true + arista.eos.eos_config: + lines: + - "no ip route 10.1.1.0/24 Management1" + - "no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" + - "no ip route 10.50.0.0/16 Management1" + - "no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" + - "no ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100" + - "no ip route 122.1.19.0/24 Nexthop-Group testgrp 21" + - "no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" + - "no ipv6 route 1000:10::/64 Ethernet1 55" + +- name: Remove testvrf VRF + become: true + arista.eos.eos_config: + lines: + - "no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" + - "no ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" + - "no vrf definition testvrf" + ignore_errors: true + +- name: Remove vrftest1 VRF + become: true + arista.eos.eos_config: + lines: + - "no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" + - "no vrf definition vrftest1" + ignore_errors: true diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml new file mode 100644 index 00000000..7b732d07 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml @@ -0,0 +1,204 @@ +--- +- debug: + msg: Start eos_static_routes deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + +- set_fact: + config1: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + +- set_fact: + config2: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + vrf: testvrf + +- set_fact: + config3: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + +- include_tasks: _populate.yaml + +- name: Delete attributes of given static routes - afi specific. + become: true + register: result + arista.eos.eos_static_routes: + config: + + - address_families: + + - afi: ipv6 + state: deleted + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config1) + == [] + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + become: true + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml new file mode 100644 index 00000000..3b134729 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml @@ -0,0 +1,97 @@ +--- +- debug: + msg: START eos_static_routes gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + state: gathered + + - set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + vrf: testvrf + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - " config | symmetric_difference(result['gathered']) == []" + + - name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml new file mode 100644 index 00000000..4bbffbc7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml @@ -0,0 +1,137 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: merge attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + - '"ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml new file mode 100644 index 00000000..2fe80c6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml @@ -0,0 +1,71 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: Override attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + state: overridden + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - result.commands|length == 8 + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + - '"no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" in result.commands' + - '"no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" in result.commands' + - '"no ip route 10.50.0.0/16 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" in result.commands' + - '"no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" in result.commands' + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml new file mode 100644 index 00000000..d9ef9c65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START eos_static_routes parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- name: Gather static_routes facts + become: true + register: static_routes_facts + arista.eos.eos_facts: + gather_subset: + - default + gather_network_resources: + - static_routes + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_static_routes: &id001 + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\ + \ |length == 0 }}" + +- name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result['changed'] == false + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml new file mode 100644 index 00000000..bb947942 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START eos_static_routes rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: rendered + + - name: Assert that correct set of commands were generated + vars: + lines: + - ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55 + - ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100 + assert: + that: + - "{{ lines | symmetric_difference(result['rendered']) |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + arista.eos.eos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml new file mode 100644 index 00000000..181227e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml @@ -0,0 +1,119 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: Replace attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + state: replaced + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - '"ipv6 route vrf testvrf 1000:10::/64 Ethernet1 55" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml new file mode 100644 index 00000000..5c7b3f37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml @@ -0,0 +1,243 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + revert_config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 122.1.19.0/24 + next_hops: + + - admin_distance: 21 + nexthop_grp: testgrp + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- block: + + - name: merge attributes of given static routes. + become: true + register: base_config + arista.eos.eos_static_routes: + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + + - assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_static_routes: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 122.1.19.0/24 + next_hops: + + - nexthop_grp: testgrp + admin_distance: 21 + state: merged + + - assert: + that: + - result.after|symmetric_difference(revert_config) == [] + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_static_routes: + config: "{{ ansible_facts['network_resources']['static_routes'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: + - ansible_facts.network_resources.static_routes | symmetric_difference(revert.after) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml new file mode 100644 index 00000000..11ccb29f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos cli/net_system.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list using platform agnostic module + become: true + register: result + ansible.netcommon.net_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- debug: msg="END eos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml new file mode 100644 index 00000000..99e283b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml @@ -0,0 +1,123 @@ +--- +- debug: msg="START cli/set_domain_list.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == false + +- name: add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + +- debug: msg="END cli/set_domain_list.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml new file mode 100644 index 00000000..5f1ad237 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- name: configure domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == true + +- name: verify domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml new file mode 100644 index 00000000..dd7547bb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname switch + match: none + +- name: configure hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == true + +- name: verify hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname }} + match: none + +- debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml new file mode 100644 index 00000000..0340a02a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml @@ -0,0 +1,72 @@ +--- +- debug: msg="START cli/set_lookup_source.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + +- name: configure lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == false + +- name: change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END cli/set_lookup_source.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml new file mode 100644 index 00000000..ea1a0a2d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/set_name_servers.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip name-server + - vrf definition ansible + match: none + +- name: configure name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 192.0.2.1' in result.commands" + - "'ip name-server 192.0.2.2' in result.commands" + - "'ip name-server 192.0.2.3' in result.commands" + +- name: verify name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == false + +- name: remove one + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 192.0.2.3' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml new file mode 100644 index 00000000..d7b43e88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos eapi/net_system.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list using platform agnostic module + become: true + register: result + ansible.netcommon.net_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- debug: msg="END eos eapi/net_system.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml new file mode 100644 index 00000000..b34eca82 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml @@ -0,0 +1,122 @@ +--- +- debug: msg="START eapi/set_domain_list.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == false + +- name: add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + +- debug: msg="END eapi/set_domain_list.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml new file mode 100644 index 00000000..733c54e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/set_domain_name.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- name: configure domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == true + +- name: verify domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- debug: msg="END eapi/set_domain_name.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml new file mode 100644 index 00000000..fcf76662 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/set_hostname.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname switch + match: none + +- name: configure hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == true + +- name: verify hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname }} + match: none + +- debug: msg="END eapi/set_hostname.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml new file mode 100644 index 00000000..676b9fef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml @@ -0,0 +1,70 @@ +--- +- debug: msg="START eapi/set_lookup_source.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + +- name: configure lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == false + +- name: change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END eapi/set_lookup_source.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml new file mode 100644 index 00000000..3dba50fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/set_name_servers.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip name-server + - vrf definition ansible + match: none + +- name: configure name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 192.0.2.1' in result.commands" + - "'ip name-server 192.0.2.2' in result.commands" + - "'ip name-server 192.0.2.3' in result.commands" + +- name: verify name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == false + +- name: remove one + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 192.0.2.3' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END eapi/set_name_servers.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml new file mode 100644 index 00000000..8ff7eba0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml @@ -0,0 +1,42 @@ +--- +- block: + + - name: Create user with password + become: true + arista.eos.eos_user: + name: auth_user + privilege: 15 + role: network-operator + state: present + provider: '{{ cli }}' + configured_password: pass123 + + - name: test login + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=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 + responses: + (?i)password: badpass + ignore_errors: true + register: results + + - name: check that attempt failed + assert: + that: + - results.failed + always: + + - name: delete user + become: true + register: result + arista.eos.eos_user: + name: auth_user + state: absent + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml new file mode 100644 index 00000000..8a2ec87c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml @@ -0,0 +1,100 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Set Up + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + - no username ansibletest2 + - no username ansibletest3 + - no username ansibletest4 + provider: '{{ cli }}' + +- name: Create user with role + become: true + register: result + arista.eos.eos_user: + name: ansibletest1 + privilege: 15 + role: network-operator + state: present + configured_password: test1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"privilege 15" in result.commands[2]' + +- name: Create user with priv level and update_password + become: true + register: result + arista.eos.eos_user: + name: ansibletest4 + privilege: 15 + state: present + configured_password: test1 + update_password: on_create + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"privilege 15" in result.commands[1]' + +- name: Collection of users + become: true + register: result + arista.eos.eos_user: + aggregate: + + - name: ansibletest2 + configured_password: test2 + + - name: ansibletest3 + configured_password: test3 + state: present + role: network-operator + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"secret" in result.commands[0]' + - '"username" in result.commands[2]' + - '"role network-operator" in result.commands[3]' + - '"secret" in result.commands[2]' + +- name: Add user without password or nopassword arg(Should fail) + become: true + ignore_errors: true + register: result + arista.eos.eos_user: + name: faileduser1 + privilege: 15 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == "configured_password, sshkey or nopassword should be provided" + +- name: tearDown + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + - no username ansibletest2 + - no username ansibletest3 + - no username ansibletest4 + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml new file mode 100644 index 00000000..2a0a3e2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eos cli/net_user.yaml on connection={{ ansible_connection }}" + +- name: Set Up + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + provider: '{{ cli }}' + +- name: Create user with role using platform agnostic module + become: true + register: result + ansible.netcommon.net_user: + name: ansibletest1 + privilege: 15 + role: network-operator + state: present + configured_password: test1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"privilege 15" in result.commands[2]' + +- name: Teardown + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_user.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml new file mode 100644 index 00000000..466a0556 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml @@ -0,0 +1,277 @@ +--- +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + - no vlan 4001 + - no vlan 4002 + provider: '{{ cli }}' + +- name: setup - remove switchport settings on interface Ethernet1 used in test + become: true + arista.eos.eos_config: + lines: + - switchport + - no switchport access vlan 4000 + parents: interface Ethernet1 + provider: '{{ cli }}' + +- name: setup - remove switchport settings on interface Ethernet2 used in test + become: true + arista.eos.eos_config: + lines: + - switchport + - no switchport access vlan 4000 + parents: interface Ethernet2 + provider: '{{ cli }}' + +- name: Create vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Change vlan name and state + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000-new + state: suspend + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000-new' in result.commands" + - "'state suspend' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Change vlan name and state again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000-new + state: suspend + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Unsuspend vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: active + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'state active' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add interfaces to vlan and check state + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet1 + - Ethernet2 + associated_interfaces: + - Ethernet1 + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'interface Ethernet1' in result.commands" + - "'switchport access vlan 4000' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'switchport access vlan 4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add interfaces to vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet 1 + - Ethernet 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: vlan interface intent fail + become: true + register: result + ignore_errors: true + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + associated_interfaces: + - test + provider: '{{ cli }}' + +- assert: + that: + - result.failed == True + +- name: Remove interface from vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'no switchport access vlan 4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove interface from vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet 1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create aggregate of vlans + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4000 + state: absent + + - vlan_id: 4001 + name: vlan-4001 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no vlan 4000' in result.commands" + - "'vlan 4001' in result.commands" + - "'name vlan-4001' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create aggregate of vlans again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4000 + state: absent + + - vlan_id: 4001 + name: vlan-4001 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create vlan with purge + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4002 + name: vlan-4002 + name: vlan-4002 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no vlan 4001' in result.commands" + - "'vlan 4002' in result.commands" + - "'name vlan-4002' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vlan with purge + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4002 + name: vlan-4002 + name: vlan-4002 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml new file mode 100644 index 00000000..e91f9ca3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_vlan.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + provider: '{{ cli }}' + +- name: Create vlan using platform agnostic vlan module + become: true + register: result + ansible.netcommon.net_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_vlan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg new file mode 100644 index 00000000..f16ae504 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +vlan 10 + name ten + state active +! +vlan 20 + name twenty + state suspend diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml new file mode 100644 index 00000000..68e96460 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml @@ -0,0 +1,31 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "no vlan 1-4094" + - "vlan 10" + - " name ten" + - "vlan 20" + - " name twenty" + match: none + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: active + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml new file mode 100644 index 00000000..cc94e11b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Returns vlans to default parameters + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml new file mode 100644 index 00000000..2d59a627 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_vlans empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_vlans empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml new file mode 100644 index 00000000..c9c1ed57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_vlans gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_vlans: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: vlans + + - assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.gathered) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml new file mode 100644 index 00000000..9c7eb249 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml @@ -0,0 +1,24 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Ensures that facts are idempotent through replace + register: result + become: true + arista.eos.eos_vlans: + config: '{{ ansible_facts.network_resources.vlans }}' + state: replaced + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - result.changed == False + - result.commands == [] + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml new file mode 100644 index 00000000..b4b53697 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml @@ -0,0 +1,49 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: suspend + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml new file mode 100644 index 00000000..b06b25fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml @@ -0,0 +1,45 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + + - vlan_id: 50 + name: fifty + state: active + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Overrides device configuration of all vlans with provided configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml new file mode 100644 index 00000000..9bdbbb87 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_vlans parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_vlans: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result['parsed']) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml new file mode 100644 index 00000000..fa987233 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml @@ -0,0 +1,20 @@ +--- +- set_fact: + config: + - vlan_id: 10 + name: ten + - vlan_id: 20 + state: suspend + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml new file mode 100644 index 00000000..23ceba50 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml @@ -0,0 +1,47 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + name: twentyreplaced + other_config: + + - vlan_id: 10 + name: ten + state: active + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Replaces device configuration of listed vlans with provided configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml new file mode 100644 index 00000000..58831e04 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml @@ -0,0 +1,67 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - vlan_id: 20 + state: suspend + + config2: + - vlan_id: 30 + name: thirty + +- name: Merge provided configuration with device configuration(base config). + register: baseconfig + become: true + arista.eos.eos_vlans: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration(config to be reverted). + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: suspend + + - vlan_id: 30 + name: thirty + state: active + +- assert: + that: + - expected_config|symmetric_difference(result.after) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_vlans: + config: "{{ ansible_facts['network_resources']['vlans'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml new file mode 100644 index 00000000..b6e27ebe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml @@ -0,0 +1,16 @@ +--- +parsed: + config: + - vlan_id: 10 + name: ten + state: active + - vlan_id: 20 + state: suspend + name: twenty + + +rendered: + - "vlan 10" + - "name ten" + - "vlan 20" + - "state suspend" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml new file mode 100644 index 00000000..2ac30d25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml @@ -0,0 +1,315 @@ +--- +- name: setup - remove vrf + become: true + with_items: + - test + - test1 + - test2 + - test3 + - test4 + - test5 + arista.eos.eos_vrf: + name: '{{ item }}' + state: absent + provider: '{{ cli }}' + +- name: Create vrf + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:200' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vrf again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Modify rd + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:201' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Modify rd again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Add Ethernet2 to vrf and check interface assigned state + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + interfaces: + - Ethernet2 + associated_interfaces: + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface ethernet2' in result.commands" + - "'vrf forwarding test' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add Ethernet2 to vrf again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + interfaces: + - ethernet 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - "'session_name' not in result.commands" + +- name: vrf interface intent fail + become: true + register: result + ignore_errors: true + arista.eos.eos_vrf: + name: test + state: present + associated_interfaces: + - test + provider: '{{ cli }}' + +- assert: + that: + - result.failed == True + +- name: Add multiple interfaces to vrf + become: true + register: result + arista.eos.eos_vrf: + name: test1 + rd: 1:202 + state: present + interfaces: + - loopback10 + - loopback11 + - loopback12 + - loopback13 + - loopback14 + - loopback15 + - loopback1000 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface loopback10' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback11' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback12' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback13' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback14' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback15' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback1000' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add multiple interfaces to vrf (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test1 + rd: 1:202 + state: present + interfaces: + - loopback10 + - loopback11 + - loopback12 + - loopback13 + - loopback14 + - loopback15 + - loopback1000 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + +- name: setup - remove vrf + become: true + with_items: + - test1 + - test2 + - test3 + arista.eos.eos_vrf: + name: '{{ item }}' + state: absent + provider: '{{ cli }}' + +- name: Create aggregate of VRFs + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test2 + rd: 1:202 + + - name: test3 + rd: 1:203 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test2' in result.commands" + - "'rd 1:202' in result.commands" + - "'vrf definition test3' in result.commands" + - "'rd 1:203' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create aggregate of VRFs again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test2 + rd: 1:202 + + - name: test3 + rd: 1:203 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create aggregate of VRFs with purge + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test4 + rd: 1:204 + + - name: test5 + rd: 1:205 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test4' in result.commands" + - "'rd 1:204' in result.commands" + - "'vrf definition test5' in result.commands" + - "'rd 1:205' in result.commands" + - "'no vrf definition test' in result.commands" + - "'no vrf definition test2' in result.commands" + - "'no vrf definition test3' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Delete VRFs + become: true + arista.eos.eos_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Delete VRFs again (idempotent) + become: true + arista.eos.eos_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Delete aggregate of VRFs + become: true + arista.eos.eos_vrf: + aggregate: + + - name: test1 + + - name: test2 + + - name: test3 + + - name: test4 + + - name: test5 + state: absent + provider: '{{ cli }}' + +- name: Delete VRFs again (idempotent) + become: true + arista.eos.eos_vrf: + aggregate: + + - name: test1 + + - name: test2 + + - name: test3 + + - name: test4 + + - name: test5 + state: absent + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml new file mode 100644 index 00000000..cd06900b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_vrf.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vrf + become: true + ansible.netcommon.net_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Create vrf using platform agnostic vrf module + become: true + register: result + ansible.netcommon.net_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:200' in result.commands" + - "'ansible_1' in result.session_name" + +- name: teardown - remove vrf + become: true + ansible.netcommon.net_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_vrf.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml new file mode 100644 index 00000000..a40e0d23 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: Enable Ethernet1 interface and disable switchport + become: true + connection: ansible.netcommon.network_cli + arista.eos.eos_config: + lines: + - no shutdown + - no switchport + parents: int Ethernet1 + +- name: Enable Ethernet2 interface and disable switchport + become: true + connection: ansible.netcommon.network_cli + arista.eos.eos_config: + lines: + - no shutdown + - no switchport + parents: int Ethernet2 + +- name: enable eapi + become: true + connection: ansible.netcommon.network_cli + tags: eapi + arista.eos.eos_eapi: + http: true + https: true + local_http: false + enable_socket: true diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..9d3adff8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.10.txt @@ -0,0 +1,3 @@ +plugins/action/eos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` +plugins/modules/eos_bgp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_bgp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.11.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.11.txt new file mode 100644 index 00000000..9d3adff8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.11.txt @@ -0,0 +1,3 @@ +plugins/action/eos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` +plugins/modules/eos_bgp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_bgp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..069aadfd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/ignore-2.9.txt @@ -0,0 +1,15 @@ +plugins/modules/eos_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_l2_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_l2_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_l3_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_l3_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_linkagg.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_linkagg.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_static_route.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_static_route.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_vlan.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_vlan.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/eos_bgp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/eos_bgp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/action/eos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/requirements.txt new file mode 100644 index 00000000..3e3a9669 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/sanity/requirements.txt @@ -0,0 +1,4 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/builtins.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/builtins.py new file mode 100644 index 00000000..bfc8adfb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/builtins.py @@ -0,0 +1,34 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# +# Compat for python2.7 +# + +# One unittest needs to import builtins via __import__() so we need to have +# the string that represents it +try: + import __builtin__ +except ImportError: + BUILTINS = "builtins" +else: + BUILTINS = "__builtin__" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/mock.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/mock.py new file mode 100644 index 00000000..b7df24ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/mock.py @@ -0,0 +1,127 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +Compat module for Python3.x's unittest.mock module +""" +import sys +import _io + +# Python 2.7 + +# Note: Could use the pypi mock library on python3.x as well as python2.x. It +# is the same as the python3 stdlib mock library + +try: + # Allow wildcard import because we really do want to import all of mock's + # symbols into this compat shim + # pylint: disable=wildcard-import,unused-wildcard-import + from unittest.mock import * +except ImportError: + # Python 2 + # pylint: disable=wildcard-import,unused-wildcard-import + try: + from mock import * + except ImportError: + print("You need the mock library installed on python2.x to run tests") + + +# Prior to 3.4.4, mock_open cannot handle binary read_data +if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + sep = b"\n" if isinstance(read_data, bytes) else "\n" + data_as_list = [l + sep for l in read_data.split(sep)] + + if data_as_list[-1] == sep: + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=""): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return type(read_data)().join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + + file_spec = list( + set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))) + ) + + if mock is None: + mock = MagicMock(name="open", spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/unittest.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/unittest.py new file mode 100644 index 00000000..df3379b8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/compat/unittest.py @@ -0,0 +1,39 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +Compat module for Python2.7's unittest module +""" + +import sys + +# Allow wildcard import because we really do want to import all of +# unittests's symbols into this compat shim +# pylint: disable=wildcard-import,unused-wildcard-import +if sys.version_info < (2, 7): + try: + # Need unittest2 on python2.6 + from unittest2 import * + except ImportError: + print("You need unittest2 installed on python2.6.x to run tests") +else: + from unittest import * diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/loader.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/loader.py new file mode 100644 index 00000000..c21188ee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/loader.py @@ -0,0 +1,116 @@ +# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import os + +from ansible.errors import AnsibleParserError +from ansible.parsing.dataloader import DataLoader +from ansible.module_utils._text import to_bytes, to_text + + +class DictDataLoader(DataLoader): + def __init__(self, file_mapping=None): + file_mapping = {} if file_mapping is None else file_mapping + assert type(file_mapping) == dict + + super(DictDataLoader, self).__init__() + + self._file_mapping = file_mapping + self._build_known_directories() + self._vault_secrets = None + + def load_from_file(self, path, cache=True, unsafe=False): + path = to_text(path) + if path in self._file_mapping: + return self.load(self._file_mapping[path], path) + return None + + # TODO: the real _get_file_contents returns a bytestring, so we actually convert the + # unicode/text it's created with to utf-8 + def _get_file_contents(self, path): + path = to_text(path) + if path in self._file_mapping: + return (to_bytes(self._file_mapping[path]), False) + else: + raise AnsibleParserError("file not found: %s" % path) + + def path_exists(self, path): + path = to_text(path) + return path in self._file_mapping or path in self._known_directories + + def is_file(self, path): + path = to_text(path) + return path in self._file_mapping + + def is_directory(self, path): + path = to_text(path) + return path in self._known_directories + + def list_directory(self, path): + ret = [] + path = to_text(path) + for x in list(self._file_mapping.keys()) + self._known_directories: + if x.startswith(path): + if os.path.dirname(x) == path: + ret.append(os.path.basename(x)) + return ret + + def is_executable(self, path): + # FIXME: figure out a way to make paths return true for this + return False + + def _add_known_directory(self, directory): + if directory not in self._known_directories: + self._known_directories.append(directory) + + def _build_known_directories(self): + self._known_directories = [] + for path in self._file_mapping: + dirname = os.path.dirname(path) + while dirname not in ("/", ""): + self._add_known_directory(dirname) + dirname = os.path.dirname(dirname) + + def push(self, path, content): + rebuild_dirs = False + if path not in self._file_mapping: + rebuild_dirs = True + + self._file_mapping[path] = content + + if rebuild_dirs: + self._build_known_directories() + + def pop(self, path): + if path in self._file_mapping: + del self._file_mapping[path] + self._build_known_directories() + + def clear(self): + self._file_mapping = dict() + self._known_directories = [] + + def get_basedir(self): + return os.getcwd() + + def set_vault_secrets(self, vault_secrets): + self._vault_secrets = vault_secrets diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/path.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/path.py new file mode 100644 index 00000000..caf8d58b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/path.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from ansible_collections.arista.eos.tests.unit.compat.mock import MagicMock +from ansible.utils.path import unfrackpath + + +mock_unfrackpath_noop = MagicMock( + spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x +) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/procenv.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/procenv.py new file mode 100644 index 00000000..db5bded4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/procenv.py @@ -0,0 +1,94 @@ +# (c) 2016, Matt Davis <mdavis@ansible.com> +# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import sys +import json + +from contextlib import contextmanager +from io import BytesIO, StringIO +from ansible_collections.arista.eos.tests.unit.compat import unittest +from ansible.module_utils.six import PY3 +from ansible.module_utils._text import to_bytes + + +@contextmanager +def swap_stdin_and_argv(stdin_data="", argv_data=tuple()): + """ + context manager that temporarily masks the test runner's values for stdin and argv + """ + real_stdin = sys.stdin + real_argv = sys.argv + + if PY3: + fake_stream = StringIO(stdin_data) + fake_stream.buffer = BytesIO(to_bytes(stdin_data)) + else: + fake_stream = BytesIO(to_bytes(stdin_data)) + + try: + sys.stdin = fake_stream + sys.argv = argv_data + + yield + finally: + sys.stdin = real_stdin + sys.argv = real_argv + + +@contextmanager +def swap_stdout(): + """ + context manager that temporarily replaces stdout for tests that need to verify output + """ + old_stdout = sys.stdout + + if PY3: + fake_stream = StringIO() + else: + fake_stream = BytesIO() + + try: + sys.stdout = fake_stream + + yield fake_stream + finally: + sys.stdout = old_stdout + + +class ModuleTestCase(unittest.TestCase): + def setUp(self, module_args=None): + if module_args is None: + module_args = { + "_ansible_remote_tmp": "/tmp", + "_ansible_keep_remote_files": False, + } + + args = json.dumps(dict(ANSIBLE_MODULE_ARGS=module_args)) + + # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually + self.stdin_swap = swap_stdin_and_argv(stdin_data=args) + self.stdin_swap.__enter__() + + def tearDown(self): + # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually + self.stdin_swap.__exit__(None, None, None) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/vault_helper.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/vault_helper.py new file mode 100644 index 00000000..b34ae134 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/vault_helper.py @@ -0,0 +1,42 @@ +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible.module_utils._text import to_bytes + +from ansible.parsing.vault import VaultSecret + + +class TextVaultSecret(VaultSecret): + """A secret piece of text. ie, a password. Tracks text encoding. + + The text encoding of the text may not be the default text encoding so + we keep track of the encoding so we encode it to the same bytes.""" + + def __init__(self, text, encoding=None, errors=None, _bytes=None): + super(TextVaultSecret, self).__init__() + self.text = text + self.encoding = encoding or "utf-8" + self._bytes = _bytes + self.errors = errors or "strict" + + @property + def bytes(self): + """The text encoded with encoding, unless we specifically set _bytes.""" + return self._bytes or to_bytes( + self.text, encoding=self.encoding, errors=self.errors + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/yaml_helper.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/yaml_helper.py new file mode 100644 index 00000000..5df30aae --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/mock/yaml_helper.py @@ -0,0 +1,167 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import io +import yaml + +from ansible.module_utils.six import PY3 +from ansible.parsing.yaml.loader import AnsibleLoader +from ansible.parsing.yaml.dumper import AnsibleDumper + + +class YamlTestUtils(object): + """Mixin class to combine with a unittest.TestCase subclass.""" + + def _loader(self, stream): + """Vault related tests will want to override this. + + Vault cases should setup a AnsibleLoader that has the vault password.""" + return AnsibleLoader(stream) + + def _dump_stream(self, obj, stream, dumper=None): + """Dump to a py2-unicode or py3-string stream.""" + if PY3: + return yaml.dump(obj, stream, Dumper=dumper) + else: + return yaml.dump(obj, stream, Dumper=dumper, encoding=None) + + def _dump_string(self, obj, dumper=None): + """Dump to a py2-unicode or py3-string""" + if PY3: + return yaml.dump(obj, Dumper=dumper) + else: + return yaml.dump(obj, Dumper=dumper, encoding=None) + + def _dump_load_cycle(self, obj): + # Each pass though a dump or load revs the 'generation' + # obj to yaml string + string_from_object_dump = self._dump_string(obj, dumper=AnsibleDumper) + + # wrap a stream/file like StringIO around that yaml + stream_from_object_dump = io.StringIO(string_from_object_dump) + loader = self._loader(stream_from_object_dump) + # load the yaml stream to create a new instance of the object (gen 2) + obj_2 = loader.get_data() + + # dump the gen 2 objects directory to strings + string_from_object_dump_2 = self._dump_string( + obj_2, dumper=AnsibleDumper + ) + + # The gen 1 and gen 2 yaml strings + self.assertEqual(string_from_object_dump, string_from_object_dump_2) + # the gen 1 (orig) and gen 2 py object + self.assertEqual(obj, obj_2) + + # again! gen 3... load strings into py objects + stream_3 = io.StringIO(string_from_object_dump_2) + loader_3 = self._loader(stream_3) + obj_3 = loader_3.get_data() + + string_from_object_dump_3 = self._dump_string( + obj_3, dumper=AnsibleDumper + ) + + self.assertEqual(obj, obj_3) + # should be transitive, but... + self.assertEqual(obj_2, obj_3) + self.assertEqual(string_from_object_dump, string_from_object_dump_3) + + def _old_dump_load_cycle(self, obj): + """Dump the passed in object to yaml, load it back up, dump again, compare.""" + stream = io.StringIO() + + yaml_string = self._dump_string(obj, dumper=AnsibleDumper) + self._dump_stream(obj, stream, dumper=AnsibleDumper) + + yaml_string_from_stream = stream.getvalue() + + # reset stream + stream.seek(0) + + loader = self._loader(stream) + # loader = AnsibleLoader(stream, vault_password=self.vault_password) + obj_from_stream = loader.get_data() + + stream_from_string = io.StringIO(yaml_string) + loader2 = self._loader(stream_from_string) + # loader2 = AnsibleLoader(stream_from_string, vault_password=self.vault_password) + obj_from_string = loader2.get_data() + + stream_obj_from_stream = io.StringIO() + stream_obj_from_string = io.StringIO() + + if PY3: + yaml.dump( + obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper + ) + yaml.dump( + obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper + ) + else: + yaml.dump( + obj_from_stream, + stream_obj_from_stream, + Dumper=AnsibleDumper, + encoding=None, + ) + yaml.dump( + obj_from_stream, + stream_obj_from_string, + Dumper=AnsibleDumper, + encoding=None, + ) + + yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue() + yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue() + + stream_obj_from_stream.seek(0) + stream_obj_from_string.seek(0) + + if PY3: + yaml_string_obj_from_stream = yaml.dump( + obj_from_stream, Dumper=AnsibleDumper + ) + yaml_string_obj_from_string = yaml.dump( + obj_from_string, Dumper=AnsibleDumper + ) + else: + yaml_string_obj_from_stream = yaml.dump( + obj_from_stream, Dumper=AnsibleDumper, encoding=None + ) + yaml_string_obj_from_string = yaml.dump( + obj_from_string, Dumper=AnsibleDumper, encoding=None + ) + + assert yaml_string == yaml_string_obj_from_stream + assert ( + yaml_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + ) + assert ( + yaml_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + == yaml_string_stream_obj_from_stream + == yaml_string_stream_obj_from_string + ) + assert obj == obj_from_stream + assert obj == obj_from_string + assert obj == yaml_string_obj_from_stream + assert obj == yaml_string_obj_from_string + assert ( + obj + == obj_from_stream + == obj_from_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + ) + return { + "obj": obj, + "yaml_string": yaml_string, + "yaml_string_from_stream": yaml_string_from_stream, + "obj_from_stream": obj_from_stream, + "obj_from_string": obj_from_string, + "yaml_string_obj_from_string": yaml_string_obj_from_string, + } diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/conftest.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/conftest.py new file mode 100644 index 00000000..e19a1e04 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/conftest.py @@ -0,0 +1,40 @@ +# Copyright (c) 2017 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import json + +import pytest + +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_bytes +from ansible.module_utils.common._collections_compat import MutableMapping + + +@pytest.fixture +def patch_ansible_module(request, mocker): + if isinstance(request.param, string_types): + args = request.param + elif isinstance(request.param, MutableMapping): + if "ANSIBLE_MODULE_ARGS" not in request.param: + request.param = {"ANSIBLE_MODULE_ARGS": request.param} + if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]: + request.param["ANSIBLE_MODULE_ARGS"][ + "_ansible_remote_tmp" + ] = "/tmp" + if ( + "_ansible_keep_remote_files" + not in request.param["ANSIBLE_MODULE_ARGS"] + ): + request.param["ANSIBLE_MODULE_ARGS"][ + "_ansible_keep_remote_files" + ] = False + args = json.dumps(request.param) + else: + raise Exception( + "Malformed data to the patch_ansible_module pytest fixture" + ) + + mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args)) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/.test_eos_l3_interfaces.py.swp b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/.test_eos_l3_interfaces.py.swp Binary files differnew file mode 100644 index 00000000..49b041da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/.test_eos_l3_interfaces.py.swp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/eos_module.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/eos_module.py new file mode 100644 index 00000000..bc191a00 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/eos_module.py @@ -0,0 +1,125 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import json +import os + +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + ModuleTestCase, +) + + +fixture_path = os.path.join(os.path.dirname(__file__), "fixtures") +fixture_data = {} + + +def load_fixture(name): + path = os.path.join(fixture_path, name) + + if path in fixture_data: + return fixture_data[path] + + with open(path) as f: + data = f.read() + try: + data = json.loads(data) + except Exception: + pass + + fixture_data[path] = data + return data + + +class TestEosModule(ModuleTestCase): + def execute_module( + self, + failed=False, + changed=False, + commands=None, + inputs=None, + sort=True, + defaults=False, + transport="cli", + filename=None, + ): + + if filename is None: + self.load_fixtures(commands, transport=transport) + else: + self.load_fixtures( + commands, transport=transport, filename=filename + ) + + if failed: + result = self.failed() + self.assertTrue(result["failed"], result) + else: + result = self.changed(changed) + self.assertEqual(result["changed"], changed, result) + if commands is not None: + if transport == "eapi": + cmd = [] + value = [] + for item in result["commands"]: + cmd.append(item["cmd"]) + if "input" in item: + value.append(item["input"]) + if sort: + self.assertEqual(sorted(commands), sorted(cmd), cmd) + else: + self.assertEqual(commands, cmd, cmd) + if inputs: + self.assertEqual(inputs, value, value) + else: + if sort: + self.assertEqual( + sorted(commands), + sorted(result["commands"]), + result["commands"], + ) + else: + self.assertEqual( + commands, result["commands"], result["commands"] + ) + + return result + + def failed(self): + with self.assertRaises(AnsibleFailJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertTrue(result["failed"], result) + return result + + def changed(self, changed=False): + with self.assertRaises(AnsibleExitJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertEqual(result["changed"], changed, result) + return result + + def load_fixtures(self, commands=None, transport="cli", filename=None): + pass diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/__init__.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/__init__.py diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg new file mode 100644 index 00000000..3a605679 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg @@ -0,0 +1,6 @@ +interface GigabitEthernet0/0 +ip access-group aclv404 in +ipv6 access-group aclv601 out +interface GigabitEthernet0/1 +ipv6 access-group aclv601 in + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acls_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acls_config.cfg new file mode 100644 index 00000000..fa4e4aae --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_acls_config.cfg @@ -0,0 +1,3 @@ +ip access-list test1 + 35 deny tcp 20.0.0.0/8 any log + 45 permit tcp any any diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_banner_show_banner.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_banner_show_banner.txt new file mode 100644 index 00000000..6292b5d0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_banner_show_banner.txt @@ -0,0 +1,4 @@ +this is a sample +mulitline banner + +used for testing diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_af_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_af_config.cfg new file mode 100644 index 00000000..9b061d4d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_af_config.cfg @@ -0,0 +1,23 @@ +router bgp 10 + neighbor n2 peer-group + neighbor n2 next-hop-unchanged + neighbor n2 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + network 1.1.1.0/24 + network 1.5.1.0/24 route-map MAP01 + ! + address-family ipv4 + bgp additional-paths receive + neighbor peer2 default-originate always + network 1.1.1.0/24 + network 1.5.1.0/24 route-map MAP01 + redistribute ospf3 match external + ! + vrf vrft + address-family ipv4 + bgp additional-paths receive + ! + address-family ipv6 + redistribute isis level-2 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_config.cfg new file mode 100644 index 00000000..3df62417 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_config.cfg @@ -0,0 +1,24 @@ +router bgp 64496 + bgp router-id 192.0.2.1 + bgp log-neighbor-changes + neighbor 198.51.100.102 remote-as 64498 + neighbor 198.51.100.102 timers 300 360 + neighbor 192.0.2.111 remote-as 64496 + neighbor 192.0.2.111 update-source Ethernet1 + neighbor 203.0.113.5 remote-as 64511 + neighbor 203.0.113.5 maximum-routes 500 + redistribute ospf route-map RMAP_1 + address-family ipv4 + neighbor 198.51.100.102 activate + neighbor 198.51.100.102 graceful-restart + neighbor 198.51.100.102 default-originate + neighbor 198.51.100.102 weight 25 + neighbor 192.0.2.111 activate + neighbor 192.0.2.111 default-originate + network 192.0.2.0/27 route-map RMAP_1 + network 198.51.100.0/24 route-map RMAP_2 + ! + address-family ipv6 + network 2001:db8:8000::/34 + network 2001:db8:c000::/34 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_af_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_af_config.cfg new file mode 100644 index 00000000..ba602b12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_af_config.cfg @@ -0,0 +1,25 @@ +router bgp 65535 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 1.1.1.0/24 as-set summary-only + aggregate-address 5.1.0.0/16 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 + ! + address-family ipv4 + bgp additional-paths receive diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_config.cfg new file mode 100644 index 00000000..a4229f15 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_bgp_global_config.cfg @@ -0,0 +1,22 @@ +router bgp 65535 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 1.1.1.0/24 as-set summary-only + aggregate-address 5.1.0.0/16 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_command_show_version.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_command_show_version.txt new file mode 100644 index 00000000..07c427ba --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_command_show_version.txt @@ -0,0 +1,15 @@ +Arista vEOS +Hardware version: +Serial number: +System MAC address: 0050.564a.009e + +Software image version: 4.15.4F +Architecture: i386 +Internal build version: 4.15.4F-2923910.4154F +Internal build ID: d8a3c846-c735-4766-93cd-82bb7427da51 + +Uptime: 30 weeks, 3 days, 18 hours and 28 minutes +Total memory: 1897592 kB +Free memory: 63424 kB + + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_candidate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_candidate.cfg new file mode 100644 index 00000000..b11bc93e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_candidate.cfg @@ -0,0 +1,7 @@ +hostname switch01 +! +interface Ethernet1 + description test interface + no shutdown +! +ip routing diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config.cfg new file mode 100644 index 00000000..6a471371 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config.cfg @@ -0,0 +1,26 @@ +! +hostname localhost +ip domain-name eng.ansible.com +! +vrf definition mgmt +! +vrf definition test +! +interface Management1 + ip address 192.168.1.1/24 +! +interface Ethernet1 + shutdown +! +interface Ethernet2 + shutdown +! +interface Ethernet3 + shutdown +! +interface Ethernet4 + shutdown +! +interface Ethernet5 + shutdown +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config_updated.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config_updated.cfg new file mode 100644 index 00000000..416cd599 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_config_config_updated.cfg @@ -0,0 +1,26 @@ +! +hostname changed +ip domain-name eng.ansible.com +! +vrf definition mgmt +! +vrf definition test +! +interface Management1 + ip address 192.168.1.1/24 +! +interface Ethernet1 + shutdown +! +interface Ethernet2 + shutdown +! +interface Ethernet3 + shutdown +! +interface Ethernet4 + shutdown +! +interface Ethernet5 + shutdown +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt.json b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt.json new file mode 100644 index 00000000..444d47d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt.json @@ -0,0 +1,47 @@ +{ + "httpServer": { + "running": true, + "configured": true, + "port": 80 + }, + "users": { + "admin": { + "requestCount": 17153, + "bytesOut": 19950055, + "lastHitTime": 1484142997.1464522, + "bytesIn": 3189628 + } + }, + "localHttpServer": { + "running": true, + "configured": true, + "port": 8080 + }, + "executionTime": 6642.150056908686, + "dscpValue": 0, + "bytesOut": 19950055, + "enabled": true, + "httpsServer": { + "running": true, + "configured": true, + "port": 443 + }, + "corsOrigins": [], + "hitCount": 17318, + "vrf": "default", + "urls": [ + "Management1 : https://172.26.4.24:443", + "Management1 : http://172.26.4.24:80", + "Unix Socket : unix:/var/run/command-api.sock", + "Local : http://localhost:8080/command-api" + ], + "lastHitTime": 1484142997.146127, + "unixSocketServer": { + "running": true, + "configured": true + }, + "requestCount": 17153, + "commandCount": 59298, + "bytesIn": 3189628 +} + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json new file mode 100644 index 00000000..8a17b19a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json @@ -0,0 +1,42 @@ +{ + "httpServer": { + "running": false, + "configured": false, + "port": 80 + }, + "users": { + "admin": { + "requestCount": 17153, + "bytesOut": 19950055, + "lastHitTime": 1484142997.1464522, + "bytesIn": 3189628 + } + }, + "localHttpServer": { + "running": false, + "configured": false, + "port": 8080 + }, + "executionTime": 6642.150056908686, + "dscpValue": 0, + "bytesOut": 19950055, + "enabled": false, + "httpsServer": { + "running": false, + "configured": false, + "port": 443 + }, + "corsOrigins": [], + "hitCount": 17318, + "vrf": "default", + "urls": [], + "lastHitTime": 1484142997.146127, + "unixSocketServer": { + "running": false, + "configured": false + }, + "requestCount": 17153, + "commandCount": 59298, + "bytesIn": 3189628 +} + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_vrf.text b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_vrf.text new file mode 100644 index 00000000..b320bdc6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_eapi_show_vrf.text @@ -0,0 +1,11 @@ +Maximum number of vrfs allowed: 14 + Vrf RD Protocols State Interfaces +--------- ----------- --------------- -------------------- -------------------- + mgmt 1:101 ipv4,ipv6 v4:no routing, + v6:no routing + + test 1:100 ipv4,ipv6 v4:routing, Ethernet5, Ethernet6 + v6:no routing + + + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_interfaces_config.cfg new file mode 100644 index 00000000..55838f49 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_interfaces_config.cfg @@ -0,0 +1,8 @@ +interface Ethernet1 + description "Interface 1" +interface Ethernet2 + no switchport +interface Ethernet4 + speed forced 10full +interface Management1 + description "Management interface" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg new file mode 100644 index 00000000..94a1880e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg @@ -0,0 +1,13 @@ +interface Ethernet1 + switchport access vlan 20 + switchport trunk allowed vlan 7-10 +! +interface Ethernet2 + switchport trunk native vlan 20 + switchport mode trunk +! +interface Management1 + ip address dhcp + ipv6 address auto-config +! + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l3_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l3_interfaces_config.cfg new file mode 100644 index 00000000..a818fa98 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_l3_interfaces_config.cfg @@ -0,0 +1,9 @@ +interface Ethernet1 + ip address 192.0.2.12/24 +! +interface Ethernet2 + ipv6 address 2001:db8::1/64 +! +interface Management1 + ip address dhcp + ipv6 address auto-config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_config.cfg new file mode 100644 index 00000000..729ece98 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_config.cfg @@ -0,0 +1 @@ +lacp system-priority 10 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg new file mode 100644 index 00000000..452e2a9f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg @@ -0,0 +1,4 @@ +interface Ethernet1 + lacp port-priority 30 +interface Ethernet2 + lacp rate fast diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lag_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lag_interfaces_config.cfg new file mode 100644 index 00000000..f7b385cd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lag_interfaces_config.cfg @@ -0,0 +1,5 @@ +interface Ethernet1 +interface Ethernet2 +interface Ethernet3 +channel-group 5 mode passive + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lldp_global_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lldp_global_config.cfg new file mode 100644 index 00000000..bd6a7b30 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_lldp_global_config.cfg @@ -0,0 +1,5 @@ +lldp timer 3000 +lldp holdtime 200 +lldp reinit 5 +no lldp tlv-select management-address +no lldp tlv-select system-description diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_logging_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_logging_config.cfg new file mode 100644 index 00000000..19283590 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_logging_config.cfg @@ -0,0 +1,6 @@ +! +logging host 175.16.0.10 +logging console warnings +logging buffered 50000 informational +logging facility local7 +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospf_interfaces_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospf_interfaces_config.cfg new file mode 100644 index 00000000..e92b10c4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospf_interfaces_config.cfg @@ -0,0 +1,21 @@ +interface Vlan1 + ip ospf dead-interval 29 + ip ospf hello-interval 66 + ip ospf mtu-ignore + ospfv3 bfd + ospfv3 cost 106 + ospfv3 hello-interval 77 + ospfv3 transmit-delay 100 + ospfv3 ipv4 priority 45 + ospfv3 ipv4 area 0.0.0.5 + ospfv3 ipv6 passive-interface + ospfv3 ipv6 dead-interval 56 + ospfv3 ipv6 retransmit-interval 115 + ospfv3 ipv6 network point-to-point + ospfv3 ipv6 mtu-ignore +! +interface Vlan3 + ospfv3 ipv4 hello-interval 45 + ospfv3 ipv4 retransmit-interval 100 + ospfv3 ipv4 area 0.0.0.6 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config.cfg new file mode 100644 index 00000000..268ab87b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config.cfg @@ -0,0 +1,19 @@ +router ospf 1 + router-id 170.21.0.4 + distance ospf intra-area 85 + redistribute static + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + max-lsa 80000 40 ignore-time 6 ignore-count 3 reset-time 20 + adjacency exchange-start threshold 20045623 + default-information originate metric 100 metric-type 1 +! +router ospf 2 vrf vrf01 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + area 0.0.0.9 default-cost 20 +! +router ospf 3 vrf02 + redistribute static +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config_gather.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config_gather.cfg new file mode 100644 index 00000000..6e931659 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv2_config_gather.cfg @@ -0,0 +1,15 @@ +router ospf 1 + router-id 170.21.0.4 + distance ospf intra-area 85 + redistribute static + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + max-lsa 80000 40 ignore-time 6 ignore-count 3 reset-time 20 + adjacency exchange-start threshold 20045623 + default-information originate metric 100 metric-type 1 +! +router ospf 3 vrf02 + redistribute static +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config.cfg new file mode 100644 index 00000000..04b4f64c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config.cfg @@ -0,0 +1,46 @@ +router ospfv3 + fips restrictions + area 0.0.0.20 stub + area 0.0.0.40 default-cost 45 + area 0.0.0.40 stub + timers pacing flood 7 + adjacency exchange-start threshold 11 + address-family ipv4 + fips restrictions + redistribute connected + exit + address-family ipv6 + router-id 10.1.1.1 + fips restrictions + exit + exit +router ospfv3 vrf vrf01 + bfd all-interfaces + fips restrictions + area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + log-adjacency-changes detail + address-family ipv4 + passive-interface default + fips restrictions + redistribute connected route-map MAP01 + maximum-paths 100 + exit + address-family ipv6 + fips restrictions + area 0.0.0.10 nssa no-summary + default-information originate route-map DefaultRouteFilter + max-metric router-lsa external-lsa 25 summary-lsa + exit + exit +router ospfv3 vrf vrf02 + fips restrictions + address-family ipv6 + router-id 10.17.0.3 + distance ospf intra-area 200 + fips restrictions + area 0.0.0.1 stub + timers throttle spf 56 56 56 + timers out-delay 10 + exit + exit + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config_gather.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config_gather.cfg new file mode 100644 index 00000000..899477a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_ospfv3_config_gather.cfg @@ -0,0 +1,11 @@ +router ospfv3 + area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + timers pacing flood 7 + router ospfv3 vrf vrf03 + fips restrictions + log-adjacency-changes detail + address-family ipv6 + area 0.0.0.43 nssa no-summary + area 0.0.0.43 range 20.1.1.0/24 not-advertise + default-information originate route-map DefaultRouteFilter + graceful-restart diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config.cfg new file mode 100644 index 00000000..6ec815d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config.cfg @@ -0,0 +1,3 @@ +ip route 10.1.1.0/24 Management1 +ip route vrf testvrf 120.1.1.0/24 Ethernet1 23 +ipv6 route 1000:10::/64 Ethernet1 67 tag 98 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config1.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config1.cfg new file mode 100644 index 00000000..db829ee8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_static_routes_config1.cfg @@ -0,0 +1 @@ +ip route 10.1.1.0/24 Management1 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_system_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_system_config.cfg new file mode 100644 index 00000000..08837ec4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_system_config.cfg @@ -0,0 +1,12 @@ +! +hostname switch01 +ip domain lookup source-interface Management1 +ip name-server vrf mgmt 8.8.4.4 +ip name-server vrf default 8.8.8.8 +ip domain-name eng.ansible.com +ip domain-list ansible.com +ip domain-list ops.ansible.com +! +vrf definition mgmt +! +vrf definition test diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_user_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_user_config.cfg new file mode 100644 index 00000000..76d76953 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_user_config.cfg @@ -0,0 +1,2 @@ +username admin role network-admin secret 5 $1$mdQIUxjg$3t3lzBpfKfITKvFm1uEIY. +username ansible role network-admin secret 5 $1$3yWSXiIi$VdzV59ChiurrNdGxlDeAW/ diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_vlan_config.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_vlan_config.cfg new file mode 100644 index 00000000..25d26a36 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/fixtures/eos_vlan_config.cfg @@ -0,0 +1,2 @@ +vlan_id 10 + name ten diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acl_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acl_interfaces.py new file mode 100644 index 00000000..179a0e95 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acl_interfaces.py @@ -0,0 +1,419 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_acl_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosAclInterfacesModule(TestEosModule): + module = eos_acl_interfaces + + def setUp(self): + super(TestEosAclInterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.acl_interfaces.acl_interfaces.Acl_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosAclInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_acl_interfaces_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_acl_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[ + dict(name="aclv401", direction="in"), + dict(name="aclv402", direction="out"), + ], + ), + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="in")], + ), + ], + ), + dict( + name="GigabitEthernet0/1", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv401", direction="in")], + ) + ], + ), + ], + state="merged", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "ip access-group aclv401 in", + "ip access-group aclv402 out", + "ipv6 access-group aclv601 in", + "interface GigabitEthernet0/1", + "ip access-group aclv401 in", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv404", direction="in")], + ), + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="out")], + ), + ], + ), + dict( + name="GigabitEthernet0/1", + access_groups=[ + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="in")], + ) + ], + ), + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acl_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[ + dict(name="aclv401", direction="in"), + dict(name="aclv402", direction="out"), + ], + ) + ], + ) + ], + state="replaced", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "no ip access-group aclv404 in", + "no ipv6 access-group aclv601 out", + "ip access-group aclv402 out", + "ip access-group aclv401 in", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv404", direction="in")], + ), + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="out")], + ), + ], + ) + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acl_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[ + dict(name="aclv401", direction="in"), + dict(name="aclv402", direction="out"), + ], + ) + ], + ) + ], + state="overridden", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "no ip access-group aclv404 in", + "no ipv6 access-group aclv601 out", + "ip access-group aclv402 out", + "ip access-group aclv401 in", + "interface GigabitEthernet0/1", + "no ipv6 access-group aclv601 in", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv404", direction="in")], + ), + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="out")], + ), + ], + ), + dict( + name="GigabitEthernet0/1", + access_groups=[ + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="in")], + ) + ], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acl_interfaces_deletedafi(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[dict(afi="ipv6")], + ) + ], + state="deleted", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "no ipv6 access-group aclv601 out", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_deletedint(self): + set_module_args( + dict(config=[dict(name="GigabitEthernet0/0")], state="deleted") + ) + commands = [ + "interface GigabitEthernet0/0", + "no ipv6 access-group aclv601 out", + "no ip access-group aclv404 in", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_deletedacl(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv404", direction="in")], + ) + ], + ) + ], + state="deleted", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "no ip access-group aclv404 in", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acl_interfaces_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_acl_interfaces_config.cfg" + ) + gathered_list = [ + { + "access_groups": [ + { + "acls": [{"direction": "in", "name": "aclv404"}], + "afi": "ipv4", + }, + { + "acls": [{"direction": "out", "name": "aclv601"}], + "afi": "ipv6", + }, + ], + "name": "GigabitEthernet0/0", + }, + { + "access_groups": [ + { + "acls": [{"direction": "in", "name": "aclv601"}], + "afi": "ipv6", + } + ], + "name": "GigabitEthernet0/1", + }, + ] + self.assertEqual(gathered_list, result["gathered"]) + + def test_eos_acl_interfaces_parsed(self): + set_module_args( + dict( + running_config="interface GigabitEthernet0/0\nipv6 access-group aclv601 out\nip access-group aclv404 in", + state="parsed", + ) + ) + result = self.execute_module(changed=False) + parsed_list = [ + { + "access_groups": [ + { + "acls": [{"direction": "in", "name": "aclv404"}], + "afi": "ipv4", + }, + { + "acls": [{"direction": "out", "name": "aclv601"}], + "afi": "ipv6", + }, + ], + "name": "GigabitEthernet0/0", + } + ] + self.assertEqual(parsed_list, result["parsed"]) + + def test_eos_acl_interfaces_rendered(self): + set_module_args( + dict( + config=[ + dict( + name="GigabitEthernet0/0", + access_groups=[ + dict( + afi="ipv4", + acls=[ + dict(name="aclv401", direction="in"), + dict(name="aclv402", direction="out"), + ], + ), + dict( + afi="ipv6", + acls=[dict(name="aclv601", direction="in")], + ), + ], + ), + dict( + name="GigabitEthernet0/1", + access_groups=[ + dict( + afi="ipv4", + acls=[dict(name="aclv401", direction="in")], + ) + ], + ), + ], + state="rendered", + ) + ) + commands = [ + "interface GigabitEthernet0/0", + "ip access-group aclv401 in", + "ip access-group aclv402 out", + "ipv6 access-group aclv601 in", + "interface GigabitEthernet0/1", + "ip access-group aclv401 in", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acls.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acls.py new file mode 100644 index 00000000..f732f736 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_acls.py @@ -0,0 +1,387 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_acls +from ansible_collections.arista.eos.plugins.module_utils.network.eos.config.acls.acls import ( + add_commands, +) +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture +import itertools + + +class TestEosAclsModule(TestEosModule): + module = eos_acls + + def setUp(self): + super(TestEosAclsModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.acls.acls.AclsFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosAclsModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_acls_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_acls_merged(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + acls=[ + dict( + name="test2", + standard="true", + aces=[ + dict( + sequence="10", + grant="permit", + protocol="tcp", + protocol_options=dict( + tcp=dict( + flags=dict(established="yes") + ) + ), + source=dict( + subnet_address="30.2.0.0/8" + ), + destination=dict(any="true"), + log="true", + ) + ], + ) + ], + ) + ], + state="merged", + ) + ) + commands = [ + "ipv6 access-list standard test2", + "10 permit tcp 30.2.0.0/8 any established log", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acls_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + sequence="35", + grant="deny", + protocol="tcp", + source=dict( + subnet_address="20.0.0.0/8" + ), + destination=dict(any="true"), + log="true", + ), + dict( + grant="permit", + source=dict(any="true"), + destination=dict(any="true"), + protocol=6, + ), + ], + ) + ], + ) + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acls_replaced(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + sequence="10", + grant="permit", + protocol="ospf", + source=dict( + subnet_address="30.2.0.0/8" + ), + destination=dict(any="true"), + log="true", + ) + ], + ) + ], + ) + ], + state="replaced", + ) + ) + commands = [ + "ip access-list test1", + "no 35", + "no 45", + "10 permit ospf 30.2.0.0/8 any log", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acls_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + sequence="35", + grant="deny", + protocol="tcp", + source=dict( + subnet_address="20.0.0.0/8" + ), + destination=dict(any="true"), + log="true", + ), + dict( + grant="permit", + source=dict(any="true"), + destination=dict(any="true"), + sequence="45", + protocol="tcp", + ), + ], + ) + ], + ) + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acls_overridden(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + sequence="10", + grant="permit", + protocol="ospf", + source=dict( + subnet_address="30.2.0.0/8" + ), + destination=dict(any="true"), + log="true", + ) + ], + ) + ], + ) + ], + state="overridden", + ) + ) + commands = [ + "ip access-list test1", + "no 35", + "no 45", + "10 permit ospf 30.2.0.0/8 any log", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_acls_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + sequence="35", + grant="deny", + protocol="tcp", + source=dict( + subnet_address="20.0.0.0/8" + ), + destination=dict(any="true"), + log="true", + ), + dict( + grant="permit", + source=dict(any="true"), + destination=dict(any="true"), + sequence="45", + protocol="tcp", + ), + ], + ) + ], + ) + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_acls_deletedacls(self): + set_module_args( + dict( + config=[dict(afi="ipv4", acls=[dict(name="test1")])], + state="deleted", + ) + ) + commands = ["no ip access-list test1"] + self.execute_module(changed=True, commands=commands) + + def test_eos_acls_deletedafis(self): + set_module_args(dict(config=[dict(afi="ipv4")], state="deleted")) + commands = ["no ip access-list test1"] + self.execute_module(changed=True, commands=commands) + + def test_eos_acls_gathered(self): + set_module_args(dict(config=[], state="gathered")) + result = self.execute_module( + changed=False, filename="eos_acls_config.cfg" + ) + commands = [] + for gathered_cmds in result["gathered"]: + cfg = add_commands(gathered_cmds) + commands.append(cfg) + commands = list(itertools.chain(*commands)) + config_commands = [ + "ip access-list test1", + "35 deny tcp 20.0.0.0/8 any log", + "45 permit tcp any any", + ] + self.assertEqual( + sorted(config_commands), sorted(commands), result["gathered"] + ) + + def test_eos_acls_rendered(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + acls=[ + dict( + name="test1", + aces=[ + dict( + grant="permit", + sequence="45", + source=dict(any="true"), + destination=dict(any="true"), + protocol=6, + ) + ], + ) + ], + ) + ], + state="rendered", + ) + ) + commands = ["ip access-list test1", "45 permit tcp any any"] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_acls_parsed(self): + set_module_args( + dict( + running_config="ipv6 access-list test2\n 10 permit icmpv6 host 10.2.33.1 any ttl eq 25", + state="parsed", + ) + ) + commands = [ + "ipv6 access-list test2", + "10 permit icmpv6 host 10.2.33.1 any ttl eq 25", + ] + result = self.execute_module(changed=False) + parsed_commands = [] + for cmds in result["parsed"]: + cfg = add_commands(cmds) + parsed_commands.append(cfg) + parsed_commands = list(itertools.chain(*parsed_commands)) + self.assertEqual( + sorted(parsed_commands), sorted(commands), result["parsed"] + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_banner.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_banner.py new file mode 100644 index 00000000..1966d58d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_banner.py @@ -0,0 +1,106 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_banner +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + +CLI = dict(transport="cli") +EAPI = dict(transport="eapi") + + +class TestEosBannerModule(TestEosModule): + + module = eos_banner + + def setUp(self): + super(TestEosBannerModule, self).setUp() + + self.mock_run_commands = patch( + "ansible_collections.arista.eos.plugins.modules.eos_banner.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_banner.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestEosBannerModule, self).tearDown() + + self.mock_run_commands.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + if transport == "cli": + self.run_commands.return_value = [ + load_fixture("eos_banner_show_banner.txt").strip() + ] + else: + self.run_commands.return_value = [ + { + "loginBanner": load_fixture( + "eos_banner_show_banner.txt" + ).strip() + } + ] + + self.load_config.return_value = dict(diff=None, session="session") + + def test_eos_banner_create_with_cli_transport(self): + set_module_args( + dict(banner="login", text="test\nbanner\nstring", provider=CLI) + ) + commands = ["banner login", "test", "banner", "string", "EOF"] + self.execute_module(changed=True, commands=commands) + + def test_eos_banner_remove_with_cli_transport(self): + set_module_args(dict(banner="login", state="absent", provider=CLI)) + commands = ["no banner login"] + self.execute_module(changed=True, commands=commands) + + def test_eos_banner_create_with_eapi_transport(self): + set_module_args( + dict(banner="login", text="test\nbanner\nstring", provider=EAPI) + ) + commands = ["banner login"] + inputs = ["test\nbanner\nstring"] + self.execute_module( + changed=True, commands=commands, inputs=inputs, transport="eapi" + ) + + def test_eos_banner_remove_with_eapi_transport(self): + set_module_args(dict(banner="login", state="absent", provider=EAPI)) + commands = ["no banner login"] + self.execute_module(changed=True, commands=commands, transport="eapi") + + def test_eos_banner_nochange_with_cli_transport(self): + banner_text = load_fixture("eos_banner_show_banner.txt").strip() + set_module_args(dict(banner="login", text=banner_text, provider=CLI)) + self.execute_module() + + def test_eos_banner_nochange_with_eapi_transport(self): + banner_text = load_fixture("eos_banner_show_banner.txt").strip() + set_module_args(dict(banner="login", text=banner_text, provider=EAPI)) + self.execute_module(transport="eapi") diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp.py new file mode 100644 index 00000000..a2e5b850 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp.py @@ -0,0 +1,386 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.cli.config.bgp.process import ( + Provider, +) +from ansible_collections.arista.eos.plugins.modules import eos_bgp +from .eos_module import TestEosModule, load_fixture + + +class TestFrrBgpModule(TestEosModule): + module = eos_bgp + + def setUp(self): + super(TestFrrBgpModule, self).setUp() + self._bgp_config = load_fixture("eos_bgp_config.cfg") + + def test_eos_bgp(self): + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + router_id="192.0.2.2", + networks=None, + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual( + commands, ["router bgp 64496", "router-id 192.0.2.2", "exit"] + ) + + def test_eos_bgp_idempotent(self): + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + router_id="192.0.2.1", + networks=None, + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_remove(self): + obj = Provider( + params=dict( + config=dict(bgp_as=64496, networks=None, address_family=None), + operation="delete", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual(commands, ["no router bgp 64496"]) + + def test_eos_bgp_neighbor(self): + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + neighbors=[ + dict(neighbor="198.51.100.12", remote_as=64498) + ], + networks=None, + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual( + commands, + [ + "router bgp 64496", + "neighbor 198.51.100.12 remote-as 64498", + "exit", + ], + ) + + def test_eos_bgp_neighbor_idempotent(self): + neighbors = [ + dict( + neighbor="198.51.100.102", + remote_as=64498, + timers=dict(keepalive=300, holdtime=360), + ), + dict(neighbor="203.0.113.5", remote_as=64511, maximum_prefix=500), + ] + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + neighbors=neighbors, + networks=None, + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_network(self): + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + networks=[ + dict( + prefix="203.0.113.0", + masklen=24, + route_map="RMAP_1", + ) + ], + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual( + sorted(commands), + sorted( + [ + "router bgp 64496", + "network 203.0.113.0/24 route-map RMAP_1", + "exit", + ] + ), + ) + + def test_eos_bgp_network_idempotent(self): + obj = Provider( + params=dict( + config=dict( + bgp_as=64496, + networks=[ + dict( + prefix="192.0.2.0", masklen=27, route_map="RMAP_1" + ), + dict( + prefix="198.51.100.0", + masklen=24, + route_map="RMAP_2", + ), + ], + address_family=None, + ), + operation="merge", + ) + ) + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_redistribute(self): + rd_1 = dict(protocol="rip", route_map="RMAP_1") + + config = dict( + bgp_as=64496, + redistribute=[rd_1], + networks=None, + address_family=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + cmd = ["router bgp 64496", "redistribute rip route-map RMAP_1", "exit"] + self.assertEqual(sorted(commands), sorted(cmd)) + + def test_eos_bgp_redistribute_idempotent(self): + rd_1 = dict(protocol="ospf", route_map="RMAP_1") + config = dict( + bgp_as=64496, + redistribute=[rd_1], + networks=None, + address_family=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_address_family_neighbors(self): + af_nbr_1 = dict( + neighbor="198.51.100.104", default_originate=True, activate=True + ) + af_nbr_2 = dict( + neighbor="198.51.100.105", + activate=True, + weight=30, + graceful_restart=True, + ) + + config = dict( + bgp_as=64496, + address_family=[dict(afi="ipv4", neighbors=[af_nbr_1, af_nbr_2])], + networks=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + cmd = [ + "router bgp 64496", + "address-family ipv4", + "neighbor 198.51.100.104 activate", + "neighbor 198.51.100.104 default-originate", + "neighbor 198.51.100.105 weight 30", + "neighbor 198.51.100.105 activate", + "neighbor 198.51.100.105 graceful-restart", + "exit", + "exit", + ] + self.assertEqual(sorted(commands), sorted(cmd)) + + def test_eos_bgp_address_family_neighbors_idempotent(self): + af_nbr_1 = dict( + neighbor="198.51.100.102", + activate=True, + graceful_restart=True, + default_originate=True, + weight=25, + ) + af_nbr_2 = dict( + neighbor="192.0.2.111", activate=True, default_originate=True + ) + config = dict( + bgp_as=64496, + address_family=[dict(afi="ipv4", neighbors=[af_nbr_1, af_nbr_2])], + networks=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_address_family_networks(self): + net = dict(prefix="203.0.113.128", masklen=26, route_map="RMAP_1") + net2 = dict(prefix="203.0.113.192", masklen=26, route_map="RMAP_2") + + config = dict( + bgp_as=64496, + address_family=[dict(afi="ipv4", networks=[net, net2])], + networks=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + cmd = [ + "router bgp 64496", + "address-family ipv4", + "network 203.0.113.128/26 route-map RMAP_1", + "network 203.0.113.192/26 route-map RMAP_2", + "exit", + "exit", + ] + self.assertEqual(sorted(commands), sorted(cmd)) + + def test_eos_bgp_address_family_networks_idempotent(self): + net = dict(prefix="2001:db8:8000::", masklen=34, route_map=None) + net2 = dict(prefix="2001:db8:c000::", masklen=34, route_map=None) + + config = dict( + bgp_as=64496, + address_family=[dict(afi="ipv6", networks=[net, net2])], + networks=None, + ) + + obj = Provider(params=dict(config=config, operation="merge")) + + commands = obj.render(self._bgp_config) + self.assertEqual(commands, []) + + def test_eos_bgp_operation_override(self): + net_1 = dict(prefix="2001:0db8:0800::", masklen=38, route_map="RMAP_1") + net_2 = dict(prefix="2001:0db8:1c00::", masklen=38, route_map="RMAP_2") + nbr_1 = dict( + neighbor="203.0.113.111", + remote_as=64511, + update_source="Ethernet2", + ) + nbr_2 = dict( + neighbor="203.0.113.120", + remote_as=64511, + timers=dict(keepalive=300, holdtime=360), + ) + af_nbr_1 = dict(neighbor="203.0.113.111", activate=True) + af_nbr_2 = dict( + neighbor="203.0.113.120", activate=True, default_originate=True + ) + + af_1 = dict(afi="ipv4", neighbors=[af_nbr_1, af_nbr_2]) + af_2 = dict(afi="ipv6", networks=[net_1, net_2]) + config = dict( + bgp_as=64496, + neighbors=[nbr_1, nbr_2], + address_family=[af_1, af_2], + networks=None, + ) + + obj = Provider(params=dict(config=config, operation="override")) + commands = obj.render(self._bgp_config) + + cmd = [ + "no router bgp 64496", + "router bgp 64496", + "neighbor 203.0.113.111 remote-as 64511", + "neighbor 203.0.113.111 update-source Ethernet2", + "neighbor 203.0.113.120 remote-as 64511", + "neighbor 203.0.113.120 timers 300 360", + "address-family ipv4", + "neighbor 203.0.113.111 activate", + "neighbor 203.0.113.120 default-originate", + "neighbor 203.0.113.120 activate", + "exit", + "address-family ipv6", + "network 2001:0db8:0800::/38 route-map RMAP_1", + "network 2001:0db8:1c00::/38 route-map RMAP_2", + "exit", + "exit", + ] + + self.assertEqual(sorted(commands), sorted(cmd)) + + def test_eos_bgp_operation_replace(self): + net = dict(prefix="203.0.113.0", masklen=27, route_map="RMAP_1") + net2 = dict(prefix="192.0.2.32", masklen=29, route_map="RMAP_2") + net_3 = dict(prefix="2001:db8:8000::", masklen=34, route_map=None) + net_4 = dict(prefix="2001:db8:c000::", masklen=34, route_map=None) + + af_1 = dict(afi="ipv4", networks=[net, net2]) + af_2 = dict(afi="ipv6", networks=[net_3, net_4]) + + config = dict(bgp_as=64496, address_family=[af_1, af_2], networks=None) + obj = Provider(params=dict(config=config, operation="replace")) + commands = obj.render(self._bgp_config) + + cmd = [ + "router bgp 64496", + "address-family ipv4", + "network 203.0.113.0/27 route-map RMAP_1", + "network 192.0.2.32/29 route-map RMAP_2", + "no network 192.0.2.0/27", + "no network 198.51.100.0/24", + "exit", + "exit", + ] + + self.assertEqual(sorted(commands), sorted(cmd)) + + def test_eos_bgp_operation_replace_with_new_as(self): + nbr = dict( + neighbor="203.0.113.124", + remote_as=64496, + update_source="Ethernet3", + ) + + config = dict( + bgp_as=64497, neighbors=[nbr], networks=None, address_family=None + ) + obj = Provider(params=dict(config=config, operation="replace")) + commands = obj.render(self._bgp_config) + + cmd = [ + "no router bgp 64496", + "router bgp 64497", + "neighbor 203.0.113.124 remote-as 64496", + "neighbor 203.0.113.124 update-source Ethernet3", + "exit", + ] + + self.assertEqual(sorted(commands), sorted(cmd)) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_address_family.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_address_family.py new file mode 100644 index 00000000..35e58ef2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_address_family.py @@ -0,0 +1,490 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import ( + eos_bgp_address_family, +) +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosBgpafModule(TestEosModule): + module = eos_bgp_address_family + + def setUp(self): + super(TestEosBgpafModule, self).setUp() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.bgp_address_family.bgp_address_family.Bgp_afFacts.get_config" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosBgpafModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_bgp_af_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_bgp_af_merged_idempotent(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + network=[ + dict(address="1.1.1.0/24"), + dict(address="1.5.1.0/24", route_map="MAP01"), + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv4", + vrf="vrft", + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv6", + vrf="vrft", + redistribute=[ + dict(protocol="isis", isis_level="level-2") + ], + ), + ], + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_bgp_af_merged(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + ), + dict(afi="ipv6", graceful_restart=True), + dict( + afi="ipv4", + vrf="vrft", + route_target=dict(mode="both", target="465:11"), + ), + ], + ), + state="merged", + ) + ) + commands = [ + "router bgp 10", + "vrf vrft", + "address-family ipv4", + "route-target both 465:11", + "exit", + "exit", + "address-family ipv6", + "graceful-restart", + "exit", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_af_replaced(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + ), + dict(afi="ipv6", graceful_restart=True), + dict( + afi="ipv4", + vrf="vrft", + route_target=dict(mode="both", target="465:11"), + ), + ], + ), + state="replaced", + ) + ) + commands = [ + "router bgp 10", + "address-family ipv4", + "no network 1.1.1.0/24", + "no network 1.5.1.0/24 route-map MAP01", + "no bgp additional-paths receive", + "exit", + "address-family ipv6", + "graceful-restart", + "exit", + "vrf vrft", + "address-family ipv4", + "no bgp additional-paths receive", + "route-target both 465:11", + "exit", + "exit", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_af_replaced_idempotent(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + network=[ + dict(address="1.1.1.0/24"), + dict(address="1.5.1.0/24", route_map="MAP01"), + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv4", + vrf="vrft", + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv6", + vrf="vrft", + redistribute=[ + dict(protocol="isis", isis_level="level-2") + ], + ), + ], + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_bgp_af_overridden(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + ), + dict(afi="ipv6", graceful_restart=True), + dict( + afi="ipv4", + vrf="vrft", + route_target=dict(mode="both", target="465:11"), + ), + ], + ), + state="overridden", + ) + ) + commands = [ + "router bgp 10", + "address-family ipv4", + "no network 1.1.1.0/24", + "no network 1.5.1.0/24 route-map MAP01", + "no bgp additional-paths receive", + "exit", + "address-family ipv6", + "graceful-restart", + "exit", + "vrf vrft", + "address-family ipv4", + "no bgp additional-paths receive", + "route-target both 465:11", + "exit", + "exit", + "vrf vrft", + "no address-family ipv6", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_af_overridden_idempotent(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + network=[ + dict(address="1.1.1.0/24"), + dict(address="1.5.1.0/24", route_map="MAP01"), + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv4", + vrf="vrft", + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv6", + vrf="vrft", + redistribute=[ + dict(protocol="isis", isis_level="level-2") + ], + ), + ], + ), + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_bgp_af_deleted(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict(afi="ipv4"), + dict(afi="ipv4", vrf="vrft"), + ], + ), + state="deleted", + ) + ) + commands = [ + "router bgp 10", + "no address-family ipv4", + "vrf vrft", + "no address-family ipv4", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_af_parsed(self): + + commands = [ + "router bgp 10", + "address-family ipv4", + "network 1.5.1.0/24 route-map MAP01", + "!", + "address-family ipv6", + "graceful-restart", + "redistribute isis level-1", + "bgp additional-paths receive", + "!", + "vrf vrft", + "address-family ipv4", + "redistribute ospf3 match external", + "route-target both 465:11", + "!", + ] + + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = { + "as_number": "10", + "address_family": [ + { + "afi": "ipv4", + "network": [ + {"address": "1.5.1.0/24", "route_map": "MAP01"} + ], + }, + { + "afi": "ipv6", + "redistribute": [ + {"protocol": "isis", "isis_level": "level-1"} + ], + "graceful_restart": True, + "bgp_params": {"additional_paths": "receive"}, + }, + { + "afi": "ipv4", + "vrf": "vrft", + "redistribute": [ + {"protocol": "ospf3", "ospf_route": "external`"} + ], + "route_target": {"mode": "both", "target": "465:11"}, + }, + ], + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_eos_bgp_af_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_bgp_af_config.cfg" + ) + gather_list = { + "address_family": [ + { + "afi": "ipv4", + "bgp_params": {"additional_paths": "receive"}, + "neighbor": [ + { + "default_originate": {"always": True}, + "peer": "peer2", + } + ], + "network": [ + {"address": "1.1.1.0/24"}, + {"address": "1.5.1.0/24", "route_map": "MAP01"}, + ], + "redistribute": [ + {"ospf_route": "external", "protocol": "ospf3"} + ], + }, + { + "afi": "ipv4", + "bgp_params": {"additional_paths": "receive"}, + "vrf": "vrft", + }, + { + "afi": "ipv6", + "redistribute": [ + {"isis_level": "level-2", "protocol": "isis"} + ], + "vrf": "vrft", + }, + ], + "as_number": "10", + } + self.assertEqual(sorted(gather_list), sorted(result["gathered"])) + + def test_eos_bgp_af_rendered(self): + set_module_args( + dict( + config=dict( + as_number=10, + address_family=[ + dict( + afi="ipv4", + redistribute=[ + dict(protocol="ospf3", ospf_route="external") + ], + network=[ + dict(address="1.1.1.0/24"), + dict(address="1.5.1.0/24", route_map="MAP01"), + ], + neighbor=[ + dict( + peer="peer2", + default_originate=dict(always=True), + ) + ], + bgp_params=dict(additional_paths="receive"), + ), + dict( + afi="ipv4", + vrf="vrft", + bgp_params=dict(additional_paths="receive"), + ), + ], + ), + state="rendered", + ) + ) + self.execute_module(changed=False) + rendered_cmds = [ + "router bgp 10", + "address-family ipv4", + "redistribute ospf3 match external", + "network 1.1.1.0/24", + "network 1.5.1.0/24 route-map MAP01", + "neighbor peer2 default-originate always", + "bgp additional-paths receive", + "exit", + "vrf vrft", + "address-family ipv4", + "bgp additional-paths receive", + "exit", + "exit", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), + sorted(rendered_cmds), + result["rendered"], + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_global.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_global.py new file mode 100644 index 00000000..9abec350 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_bgp_global.py @@ -0,0 +1,649 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_bgp_global +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosBgpglobalModule(TestEosModule): + module = eos_bgp_global + + def setUp(self): + super(TestEosBgpglobalModule, self).setUp() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_config" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + self.mock_execute_show_command_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.config.bgp_global.bgp_global.Bgp_global._get_config" + ) + self.execute_show_command_config = ( + self.mock_execute_show_command_config.start() + ) + + def tearDown(self): + super(TestEosBgpglobalModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_execute_show_command.stop() + self.mock_execute_show_command_config.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_bgp_global_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + self.execute_show_command_config.side_effect = load_from_file + + def test_eos_bgp_global_merged_idempotent(self): + set_module_args( + dict( + config=dict( + as_number="65535", + timers=dict(keepalive=44, holdtime=100), + ucmp=dict(link_bandwidth=dict(mode="recursive")), + neighbor=[ + dict( + peer="peer1", + peer_group="peer1", + maximum_received_routes=dict(count=12000), + send_community=dict( + community_attribute="link-bandwidth", + link_bandwidth_attribute="divide", + divide="ratio", + ), + ), + dict( + peer="peer2", + peer_group="peer2", + maximum_received_routes=dict(count=12000), + ), + ], + aggregate_address=[ + dict( + address="1.1.1.0/24", + as_set=True, + summary_only=True, + ), + dict(address="5.1.0.0/16", attribute_map="attrmap"), + ], + redistribute=[ + dict(protocol="ospf", ospf_route="nssa_external_2"), + dict(protocol="static"), + dict(protocol="rip", route_map="MAP01"), + ], + vlan_aware_bundle="bundle1 bundle3", + vrfs=[ + dict( + vrf="vrf01", + default_metric=433, + network=[ + dict( + address="6.6.6.0/24", route_map="netmap1" + ), + dict(address="10.1.0.0/16"), + ], + redistribute=[ + dict(protocol="isis", isis_level="level-2") + ], + route_target=dict(action="export", target="44:22"), + ) + ], + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_bgp_global_merged(self): + set_module_args( + dict( + config=dict( + as_number="65535", + vrfs=[ + dict( + vrf="vrf01", + timers=dict(keepalive=44, holdtime=100), + ucmp=dict(link_bandwidth=dict(mode="recursive")), + neighbor=[ + dict( + peer="peer1", + peer_group="peer1", + maximum_received_routes=dict(count=12000), + send_community=dict( + community_attribute="link-bandwidth", + link_bandwidth_attribute="divide", + divide="ratio", + ), + ), + dict( + peer="peer2", + peer_group="peer2", + maximum_received_routes=dict(count=12000), + ), + ], + ) + ], + default_metric=433, + network=[ + dict(address="6.6.6.0/24", route_map="netmap1"), + dict(address="10.1.0.0/16"), + ], + redistribute=[dict(protocol="isis", isis_level="level-2")], + route_target=dict(action="export", target="44:22"), + ), + state="merged", + ) + ) + commands = [ + "router bgp 65535", + "vrf vrf01", + "neighbor peer1 peer-group", + "neighbor peer1 maximum-routes 12000", + "neighbor peer1 send-community link-bandwidth divide ratio", + "neighbor peer2 peer-group", + "neighbor peer2 maximum-routes 12000", + "timers bgp 44 100", + "ucmp link-bandwidth recursive", + "exit", + "redistribute isis level-2", + "network 6.6.6.0/24 route-map netmap1", + "network 10.1.0.0/16", + "default-metric 433", + "route-target export 44:22", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_global_replaced_idempotent(self): + set_module_args( + dict( + config=dict( + as_number="65535", + timers=dict(keepalive=44, holdtime=100), + ucmp=dict(link_bandwidth=dict(mode="recursive")), + neighbor=[ + dict( + peer="peer1", + peer_group="peer1", + maximum_received_routes=dict(count=12000), + send_community=dict( + community_attribute="link-bandwidth", + link_bandwidth_attribute="divide", + divide="ratio", + ), + ), + dict( + peer="peer2", + peer_group="peer2", + maximum_received_routes=dict(count=12000), + ), + ], + aggregate_address=[ + dict( + address="1.1.1.0/24", + as_set=True, + summary_only=True, + ), + dict(address="5.1.0.0/16", attribute_map="attrmap"), + ], + redistribute=[ + dict(protocol="ospf", ospf_route="nssa_external_2"), + dict(protocol="static"), + dict(protocol="rip", route_map="MAP01"), + ], + vlan_aware_bundle="bundle1 bundle3", + vrfs=[ + dict( + vrf="vrf01", + default_metric=433, + network=[ + dict( + address="6.6.6.0/24", route_map="netmap1" + ), + dict(address="10.1.0.0/16"), + ], + redistribute=[ + dict(protocol="isis", isis_level="level-2") + ], + route_target=dict(action="export", target="44:22"), + ) + ], + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_bgp_global_replaced_novrf(self): + set_module_args( + dict( + config=dict( + as_number="65535", + default_metric=433, + network=[ + dict(address="6.6.6.0/24", route_map="netmap1"), + dict(address="10.1.0.0/16"), + ], + redistribute=[dict(protocol="isis", isis_level="level-2")], + route_target=dict(action="export", target="44:22"), + ), + state="replaced", + ) + ) + commands = [ + "router bgp 65535", + "no vrf vrf01", + "redistribute isis level-2", + "network 6.6.6.0/24 route-map netmap1", + "network 10.1.0.0/16", + "default-metric 433", + "route-target export 44:22", + "no timers bgp 44 100", + "no ucmp link-bandwidth recursive", + "no neighbor peer1 peer-group", + "no neighbor peer1 send-community link-bandwidth divide ratio", + "no neighbor peer1 maximum-routes 12000", + "no neighbor peer2 peer-group", + "no neighbor peer2 maximum-routes 12000", + "no aggregate-address 1.1.1.0/24 as-set summary-only", + "no aggregate-address 5.1.0.0/16 attribute-map attrmap", + "no redistribute ospf match nssa-external 2", + "no redistribute static", + "no vlan-aware-bundle bundle1 bundle3", + "no redistribute rip route-map MAP01", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_global_replaced_vrf(self): + set_module_args( + dict( + config=dict( + as_number="65535", + vrfs=[ + dict( + vrf="vrf01", + default_metric=433, + aggregate_address=[ + dict( + address="1.1.1.0/24", + as_set=True, + summary_only=True, + ), + dict( + address="5.1.0.0/16", + attribute_map="attrmap", + ), + ], + redistribute=[ + dict( + protocol="ospf", + ospf_route="nssa_external_2", + ), + dict(protocol="static"), + dict(protocol="rip", route_map="MAP01"), + ], + ) + ], + ), + state="replaced", + ) + ) + commands = [ + "router bgp 65535", + "vrf vrf01", + "no route-target export 44:22", + "redistribute ospf match nssa-external 2", + "redistribute static", + "redistribute rip route-map MAP01", + "no redistribute isis level-2", + "no network 6.6.6.0/24 route-map netmap1", + "no network 10.1.0.0/16", + "aggregate-address 1.1.1.0/24 as-set summary-only", + "aggregate-address 5.1.0.0/16 attribute-map attrmap", + "exit", + "no neighbor peer1 peer-group", + "no neighbor peer1 send-community link-bandwidth divide ratio", + "no neighbor peer1 maximum-routes 12000", + "no neighbor peer2 peer-group", + "no neighbor peer2 maximum-routes 12000", + "no redistribute ospf match nssa-external 2", + "no redistribute static", + "no redistribute rip route-map MAP01", + "no aggregate-address 1.1.1.0/24 as-set summary-only", + "no aggregate-address 5.1.0.0/16 attribute-map attrmap", + "no timers bgp 44 100", + "no ucmp link-bandwidth recursive", + "no vlan-aware-bundle bundle1 bundle3", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_global_deleted(self): + set_module_args(dict(config=dict(as_number="65535"), state="deleted")) + commands = [ + "router bgp 65535", + "no vrf vrf01", + "no neighbor peer1 peer-group", + "no neighbor peer1 send-community link-bandwidth divide ratio", + "no neighbor peer1 maximum-routes 12000", + "no neighbor peer2 peer-group", + "no neighbor peer2 maximum-routes 12000", + "no redistribute ospf match nssa-external 2", + "no redistribute static", + "no redistribute rip route-map MAP01", + "no aggregate-address 1.1.1.0/24 as-set summary-only", + "no aggregate-address 5.1.0.0/16 attribute-map attrmap", + "no timers bgp 44 100", + "no ucmp link-bandwidth recursive", + "no vlan-aware-bundle bundle1 bundle3", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_global_purged(self): + set_module_args(dict(config=dict(as_number="65535"), state="purged")) + commands = ["no router bgp 65535"] + self.execute_module(changed=True, commands=commands) + + def test_eos_bgp_global_merged_incorrect_instance(self): + set_module_args( + dict( + config=dict( + as_number="100", + vrfs=[ + dict( + vrf="vrf02", + timers=dict(keepalive=44, holdtime=100), + ucmp=dict(link_bandwidth=dict(mode="recursive")), + neighbor=[ + dict( + peer="peer1", + peer_group="peer1", + maximum_received_routes=dict(count=12000), + send_community=dict( + community_attribute="link-bandwidth", + link_bandwidth_attribute="divide", + divide="ratio", + ), + ), + dict( + peer="peer2", + peer_group="peer2", + maximum_received_routes=dict(count=12000), + ), + ], + ) + ], + default_metric=433, + network=[ + dict(address="6.6.6.0/24", route_map="netmap1"), + dict(address="10.1.0.0/16"), + ], + redistribute=[dict(protocol="isis", isis_level="level-2")], + route_target=dict(action="export", target="44:22"), + ), + state="merged", + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "Only one bgp instance is allowed per device", result["msg"] + ) + + def test_eos_bgp_global_replaced_with_af(self): + set_module_args( + dict( + config=dict( + as_number="65535", + default_metric=433, + network=[ + dict(address="6.6.6.0/24", route_map="netmap1"), + dict(address="10.1.0.0/16"), + ], + redistribute=[dict(protocol="isis", isis_level="level-2")], + route_target=dict(action="export", target="44:22"), + ), + state="replaced", + ) + ) + result = self.execute_module( + failed=True, filename="eos_bgp_global_af_config.cfg" + ) + self.assertIn( + "Use the _bgp_address_family module to delete the address_family under vrf, before replacing/deleting the vrf.", + result["msg"], + ) + + def test_eos_bgp_global_deleted_with_af(self): + set_module_args(dict(config=dict(as_number="65535"), state="deleted")) + result = self.execute_module( + failed=True, filename="eos_bgp_global_af_config.cfg" + ) + self.assertIn( + "Use the _bgp_address_family module to delete the address_family under vrf, before replacing/deleting the vrf.", + result["msg"], + ) + + def test_eos_bgp_global_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_bgp_global_config.cfg" + ) + gather_list = { + "aggregate_address": [ + { + "address": "1.1.1.0/24", + "as_set": True, + "summary_only": True, + }, + {"address": "5.1.0.0/16", "attribute_map": "attrmap"}, + ], + "as_number": "65535", + "neighbor": [ + { + "maximum_received_routes": {"count": 12000}, + "peer": "peer1", + "peer_group": "peer1", + "send_community": { + "community_attribute": "link-bandwidth", + "divide": "ratio", + "link_bandwidth_attribute": "divide", + }, + }, + { + "maximum_received_routes": {"count": 12000}, + "peer": "peer2", + "peer_group": "peer2", + }, + ], + "redistribute": [ + {"ospf_route": "nssa_external_2", "protocol": "ospf"}, + {"protocol": "static"}, + {"protocol": "rip", "route_map": "MAP01"}, + ], + "timers": {"holdtime": 100, "keepalive": 44}, + "ucmp": {"link_bandwidth": {"mode": "recursive"}}, + "vlan_aware_bundle": "bundle1 bundle3", + "vrfs": [ + { + "default_metric": 433, + "network": [ + {"address": "6.6.6.0/24", "route_map": "netmap1"}, + {"address": "10.1.0.0/16"}, + ], + "redistribute": [ + {"isis_level": "level-2", "protocol": "isis"} + ], + "route_target": {"action": "export", "target": "44:22"}, + "vrf": "vrf01", + } + ], + } + self.assertEqual(sorted(gather_list), sorted(result["gathered"])) + + def test_eos_bgp_global_parsed(self): + commands = [ + "router bgp 65535", + "timers bgp 44 100", + "ucmp link-bandwidth recursive", + "neighbor peer1 peer-group", + "neighbor peer1 send-community link-bandwidth divide ratio", + "neighbor peer1 maximum-routes 12000", + "neighbor peer2 peer-group", + "neighbor peer2 maximum-routes 12000", + "aggregate-address 1.1.1.0/24 as-set summary-only", + "aggregate-address 5.1.0.0/16 attribute-map attrmap", + "redistribute ospf match nssa-external 2", + "redistribute static", + "redistribute rip route-map MAP01", + "!", + "vlan-aware-bundle bundle1 bundle3", + "!", + "vrf vrf01", + "route-target export 44:22", + "default-metric 433", + "network 6.6.6.0/24 route-map netmap1", + "network 10.1.0.0/16", + "redistribute isis level-2", + ] + + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module( + changed=False, filename="eos_bgp_global_config.cfg" + ) + parsed_list = { + "aggregate_address": [ + { + "address": "1.1.1.0/24", + "as_set": True, + "summary_only": True, + }, + {"address": "5.1.0.0/16", "attribute_map": "attrmap"}, + ], + "as_number": "65535", + "neighbor": [ + { + "maximum_received_routes": {"count": 12000}, + "peer": "peer1", + "peer_group": "peer1", + "send_community": { + "community_attribute": "link-bandwidth", + "divide": "ratio", + "link_bandwidth_attribute": "divide", + }, + }, + { + "maximum_received_routes": {"count": 12000}, + "peer": "peer2", + "peer_group": "peer2", + }, + ], + "redistribute": [ + {"ospf_route": "nssa_external_2", "protocol": "ospf"}, + {"protocol": "static"}, + {"protocol": "rip", "route_map": "MAP01"}, + ], + "timers": {"holdtime": 100, "keepalive": 44}, + "ucmp": {"link_bandwidth": {"mode": "recursive"}}, + "vlan_aware_bundle": "bundle1 bundle3", + "vrfs": [ + { + "default_metric": 433, + "network": [ + {"address": "6.6.6.0/24", "route_map": "netmap1"}, + {"address": "10.1.0.0/16"}, + ], + "redistribute": [ + {"isis_level": "level-2", "protocol": "isis"} + ], + "route_target": {"action": "export", "target": "44:22"}, + "vrf": "vrf01", + } + ], + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_eos_bgp_global_rendered(self): + set_module_args( + dict( + config=dict( + as_number="65535", + vrfs=[ + dict( + vrf="vrf02", + timers=dict(keepalive=44, holdtime=100), + ucmp=dict(link_bandwidth=dict(mode="recursive")), + neighbor=[ + dict( + peer="peer1", + peer_group="peer1", + maximum_received_routes=dict(count=12000), + send_community=dict( + community_attribute="link-bandwidth", + link_bandwidth_attribute="divide", + divide="ratio", + ), + ), + dict( + peer="peer2", + peer_group="peer2", + maximum_received_routes=dict(count=12000), + ), + ], + ) + ], + default_metric=433, + network=[ + dict(address="6.6.6.0/24", route_map="netmap1"), + dict(address="10.1.0.0/16"), + ], + redistribute=[dict(protocol="isis", isis_level="level-2")], + route_target=dict(action="export", target="44:22"), + ), + state="rendered", + ) + ) + rendered_cmds = [ + "router bgp 65535", + "vrf vrf02", + "neighbor peer1 peer-group", + "neighbor peer1 maximum-routes 12000", + "neighbor peer1 send-community link-bandwidth divide ratio", + "neighbor peer2 peer-group", + "neighbor peer2 maximum-routes 12000", + "timers bgp 44 100", + "ucmp link-bandwidth recursive", + "exit", + "redistribute isis level-2", + "network 6.6.6.0/24 route-map netmap1", + "network 10.1.0.0/16", + "default-metric 433", + "route-target export 44:22", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), + sorted(rendered_cmds), + result["rendered"], + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_command.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_command.py new file mode 100644 index 00000000..d40c0ab0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_command.py @@ -0,0 +1,126 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import json + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_command +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosCommandModule(TestEosModule): + + module = eos_command + + def setUp(self): + super(TestEosCommandModule, self).setUp() + self.mock_run_commands = patch( + "ansible_collections.arista.eos.plugins.modules.eos_command.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + def tearDown(self): + super(TestEosCommandModule, self).tearDown() + self.mock_run_commands.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + module, commands = args + output = list() + + for item in commands: + try: + obj = json.loads(item["command"]) + command = obj["command"] + except ValueError: + command = item["command"] + filename = str(command).replace(" ", "_") + filename = "eos_command_%s.txt" % filename + output.append(load_fixture(filename)) + return output + + self.run_commands.side_effect = load_from_file + + def test_eos_command_simple(self): + set_module_args(dict(commands=["show version"])) + result = self.execute_module() + self.assertEqual(len(result["stdout"]), 1) + self.assertTrue(result["stdout"][0].startswith("Arista")) + + def test_eos_command_multiple(self): + set_module_args(dict(commands=["show version", "show version"])) + result = self.execute_module() + self.assertEqual(len(result["stdout"]), 2) + self.assertTrue(result["stdout"][0].startswith("Arista")) + + def test_eos_command_wait_for(self): + wait_for = 'result[0] contains "Arista vEOS"' + set_module_args(dict(commands=["show version"], wait_for=wait_for)) + self.execute_module() + + def test_eos_command_wait_for_fails(self): + wait_for = 'result[0] contains "test string"' + set_module_args(dict(commands=["show version"], wait_for=wait_for)) + self.execute_module(failed=True) + self.assertEqual(self.run_commands.call_count, 10) + + def test_eos_command_retries(self): + wait_for = 'result[0] contains "test string"' + set_module_args( + dict(commands=["show version"], wait_for=wait_for, retries=2) + ) + self.execute_module(failed=True) + self.assertEqual(self.run_commands.call_count, 2) + + def test_eos_command_match_any(self): + wait_for = [ + 'result[0] contains "Arista"', + 'result[0] contains "test string"', + ] + set_module_args( + dict(commands=["show version"], wait_for=wait_for, match="any") + ) + self.execute_module() + + def test_eos_command_match_all(self): + wait_for = [ + 'result[0] contains "Arista"', + 'result[0] contains "Software image"', + ] + set_module_args( + dict(commands=["show version"], wait_for=wait_for, match="all") + ) + self.execute_module() + + def test_eos_command_match_all_failure(self): + wait_for = [ + 'result[0] contains "Arista"', + 'result[0] contains "test string"', + ] + commands = ["show version", "show version"] + set_module_args( + dict(commands=commands, wait_for=wait_for, match="all") + ) + self.execute_module(failed=True) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_config.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_config.py new file mode 100644 index 00000000..9614e292 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_config.py @@ -0,0 +1,271 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import ( + patch, + MagicMock, +) +from ansible_collections.arista.eos.plugins.modules import eos_config +from ansible_collections.arista.eos.plugins.cliconf.eos import Cliconf +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosConfigModule(TestEosModule): + + module = eos_config + + def setUp(self): + super(TestEosConfigModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_get_connection = patch( + "ansible_collections.arista.eos.plugins.modules.eos_config.get_connection" + ) + self.get_connection = self.mock_get_connection.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_config.load_config" + ) + self.load_config = self.mock_load_config.start() + self.mock_run_commands = patch( + "ansible_collections.arista.eos.plugins.modules.eos_config.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + self.mock_supports_sessions = patch( + "ansible_collections.arista.eos.plugins.cliconf.eos.Cliconf.supports_sessions" + ) + self.supports_sessions = self.mock_supports_sessions.start() + self.mock_supports_sessions.return_value = True + + self.conn = self.get_connection() + self.conn.edit_config = MagicMock() + + self.cliconf_obj = Cliconf(MagicMock()) + self.running_config = load_fixture("eos_config_config.cfg") + + def tearDown(self): + super(TestEosConfigModule, self).tearDown() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_get_connection.stop() + self.mock_supports_sessions.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture("eos_config_config.cfg") + self.load_config.return_value = dict(diff=None, session="session") + + def test_eos_config_no_change(self): + lines = ["hostname localhost"] + config = "\n".join(lines) + args = dict(lines=lines) + set_module_args(args) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(config, config) + ) + self.execute_module() + + def test_eos_config_src(self): + src = load_fixture("eos_config_candidate.cfg") + args = dict(src=src) + set_module_args(args) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(src, self.running_config) + ) + result = self.execute_module(changed=True) + config = [ + "hostname switch01", + "interface Ethernet1", + "description test interface", + "no shutdown", + "ip routing", + ] + self.assertEqual( + sorted(config), sorted(result["commands"]), result["commands"] + ) + + def test_eos_config_lines(self): + lines = ["hostname switch01", "ip domain-name eng.ansible.com"] + args = dict(lines=lines) + set_module_args(args) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + "\n".join(lines), self.running_config + ) + ) + result = self.execute_module(changed=True) + config = ["hostname switch01"] + + self.assertEqual( + sorted(config), sorted(result["commands"]), result["commands"] + ) + + def test_eos_config_before(self): + lines = ["hostname switch01", "ip domain-name eng.ansible.com"] + before = ["before command"] + args = dict(lines=lines, before=before) + set_module_args(args) + + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + "\n".join(lines), self.running_config + ) + ) + result = self.execute_module(changed=True) + config = ["before command", "hostname switch01"] + self.assertEqual( + sorted(config), sorted(result["commands"]), result["commands"] + ) + self.assertEqual("before command", result["commands"][0]) + + def test_eos_config_after(self): + lines = ["hostname switch01", "ip domain-name eng.ansible.com"] + args = dict(lines=lines, after=["after command"]) + + set_module_args(args) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + "\n".join(lines), self.running_config + ) + ) + result = self.execute_module(changed=True) + config = ["after command", "hostname switch01"] + + self.assertEqual( + sorted(config), sorted(result["commands"]), result["commands"] + ) + self.assertEqual("after command", result["commands"][-1]) + + def test_eos_config_parents(self): + lines = ["ip address 1.2.3.4/5", "no shutdown"] + parents = ["interface Ethernet10"] + args = dict(lines=lines, parents=parents) + candidate = parents + lines + set_module_args(args) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + "\n".join(candidate), self.running_config + ) + ) + + result = self.execute_module(changed=True) + config = [ + "interface Ethernet10", + "ip address 1.2.3.4/5", + "no shutdown", + ] + + self.assertEqual(config, result["commands"], result["commands"]) + + def test_eos_config_src_and_lines_fails(self): + args = dict(src="foo", lines="foo") + set_module_args(args) + self.execute_module(failed=True) + + def test_eos_config_match_exact_requires_lines(self): + args = dict(match="exact") + set_module_args(args) + self.execute_module(failed=True) + + def test_eos_config_match_strict_requires_lines(self): + args = dict(match="strict") + set_module_args(args) + self.execute_module(failed=True) + + def test_eos_config_replace_block_requires_lines(self): + args = dict(replace="block") + set_module_args(args) + self.execute_module(failed=True) + + def test_eos_config_replace_config_requires_src(self): + args = dict(replace="config") + set_module_args(args) + self.execute_module(failed=True) + + def test_eos_config_backup_returns__backup__(self): + args = dict(backup=True) + set_module_args(args) + result = self.execute_module() + self.assertIn("__backup__", result) + + def test_eos_config_save_when(self): + mock_run_commands = patch( + "ansible_collections.arista.eos.plugins.modules.eos_config.run_commands" + ) + run_commands = mock_run_commands.start() + + run_commands.return_value = [ + load_fixture("eos_config_config.cfg"), + load_fixture("eos_config_config.cfg"), + ] + + args = dict(save_when="modified") + set_module_args(args) + self.execute_module() + + run_commands.return_value = [ + load_fixture("eos_config_config.cfg"), + load_fixture("eos_config_config_updated.cfg"), + ] + + args = dict(save_when="modified") + set_module_args(args) + self.execute_module(changed=True) + + mock_run_commands.stop() + + def test_eos_config_save_changed_true(self): + commands = [ + "hostname foo", + "interface GigabitEthernet0/0", + "no ip address", + ] + set_module_args(dict(save_when="changed", lines=commands)) + self.execute_module(changed=True) + self.assertEqual(self.run_commands.call_count, 1) + self.assertEqual(self.get_config.call_count, 1) + self.assertEqual(self.load_config.call_count, 1) + args = self.run_commands.call_args[0][1][0]["command"] + self.assertIn("copy running-config startup-config", args) + + def test_eos_config_save_changed_false(self): + set_module_args(dict(save_when="changed")) + self.execute_module(changed=False) + self.assertEqual(self.run_commands.call_count, 0) + self.assertEqual(self.get_config.call_count, 0) + self.assertEqual(self.load_config.call_count, 0) + + def test_eos_config_save_always(self): + self.run_commands.return_value = "hostname foo" + set_module_args(dict(save_when="always")) + self.execute_module(changed=True) + self.assertEqual(self.run_commands.call_count, 1) + self.assertEqual(self.get_config.call_count, 0) + self.assertEqual(self.load_config.call_count, 0) + args = self.run_commands.call_args[0][1][0]["command"] + self.assertIn("copy running-config startup-config", args) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_eapi.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_eapi.py new file mode 100644 index 00000000..a01bf1eb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_eapi.py @@ -0,0 +1,191 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_eapi +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosEapiModule(TestEosModule): + + module = eos_eapi + + def setUp(self): + super(TestEosEapiModule, self).setUp() + + self.mock_run_commands = patch( + "ansible_collections.arista.eos.plugins.modules.eos_eapi.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_eapi.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_verify_state = patch( + "ansible_collections.arista.eos.plugins.modules.eos_eapi.verify_state" + ) + self.verify_state = self.mock_verify_state.start() + + self.command_fixtures = {} + + def tearDown(self): + super(TestEosEapiModule, self).tearDown() + + self.mock_run_commands.stop() + self.mock_load_config.stop() + + # hack for older version of mock + # should be using patch.stopall() but CI is still failing + try: + self.mock_verify_state.stop() + except RuntimeError: + pass + + def load_fixtures(self, commands=None, transport="eapi"): + def run_commands(module, commands, **kwargs): + output = list() + for cmd in commands: + output.append(load_fixture(self.command_fixtures[cmd])) + return output + + self.run_commands.side_effect = run_commands + self.load_config.return_value = dict(diff=None, session="session") + + def start_configured(self, *args, **kwargs): + self.command_fixtures = { + "show vrf": "eos_eapi_show_vrf.text", + "show management api http-commands | json": "eos_eapi_show_mgmt.json", + } + return self.execute_module(*args, **kwargs) + + def start_unconfigured(self, *args, **kwargs): + self.command_fixtures = { + "show vrf": "eos_eapi_show_vrf.text", + "show management api http-commands | json": "eos_eapi_show_mgmt_unconfigured.json", + } + return self.execute_module(*args, **kwargs) + + def test_eos_eapi_http_enable(self): + set_module_args(dict(http=True)) + commands = [ + "management api http-commands", + "protocol http port 80", + "no shutdown", + ] + self.start_unconfigured(changed=True, commands=commands) + + def test_eos_eapi_http_disable(self): + set_module_args(dict(http=False)) + commands = ["management api http-commands", "no protocol http"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_http_port(self): + set_module_args(dict(http_port=81)) + commands = ["management api http-commands", "protocol http port 81"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_http_invalid(self): + set_module_args(dict(http_port=80000)) + self.start_unconfigured(failed=True) + + def test_eos_eapi_https_enable(self): + set_module_args(dict(https=True)) + commands = [ + "management api http-commands", + "protocol https port 443", + "no shutdown", + ] + self.start_unconfigured(changed=True, commands=commands) + + def test_eos_eapi_https_disable(self): + set_module_args(dict(https=False)) + commands = ["management api http-commands", "no protocol https"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_https_port(self): + set_module_args(dict(https_port=8443)) + commands = ["management api http-commands", "protocol https port 8443"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_local_http_enable(self): + set_module_args(dict(local_http=True)) + commands = [ + "management api http-commands", + "protocol http localhost port 8080", + "no shutdown", + ] + self.start_unconfigured(changed=True, commands=commands) + + def test_eos_eapi_local_http_disable(self): + set_module_args(dict(local_http=False)) + commands = [ + "management api http-commands", + "no protocol http localhost", + ] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_local_http_port(self): + set_module_args(dict(local_http_port=81)) + commands = [ + "management api http-commands", + "protocol http localhost port 81", + ] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_vrf(self): + set_module_args(dict(vrf="test")) + commands = [ + "management api http-commands", + "no shutdown", + "vrf test", + "no shutdown", + ] + self.start_unconfigured(changed=True, commands=commands) + + def test_eos_eapi_change_from_default_vrf(self): + set_module_args(dict(vrf="test")) + commands = ["management api http-commands", "vrf test", "no shutdown"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_default(self): + set_module_args(dict()) + self.start_configured(changed=False, commands=[]) + + def test_eos_eapi_vrf_missing(self): + set_module_args(dict(vrf="missing")) + self.start_unconfigured(failed=True) + + def test_eos_eapi_state_absent(self): + set_module_args(dict(state="stopped")) + commands = ["management api http-commands", "shutdown"] + self.start_configured(changed=True, commands=commands) + + def test_eos_eapi_state_failed(self): + self.mock_verify_state.stop() + set_module_args(dict(state="stopped", timeout=1)) + result = self.start_configured(failed=True) + "timeout expired before eapi running state changed" in result["msg"] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_interfaces.py new file mode 100644 index 00000000..861f292e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_interfaces.py @@ -0,0 +1,251 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosInterfacesModule(TestEosModule): + module = eos_interfaces + + def setUp(self): + super(TestEosInterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.interfaces.interfaces.InterfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet3", + description="Ethernet_3", + mode="layer2", + ) + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet3", + "description Ethernet_3", + "switchport", + "no shutdown", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[dict(name="Ethernet1", description="Interface 1")], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_interfaces_merged_speed_idempotent(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet4", speed="forced 10", duplex="full") + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet2", description="Ethernet_2", mtu=1000) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet2", + "description Ethernet_2", + "mtu 1000", + "switchport", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_delete(self): + set_module_args(dict(config=[dict(name="Ethernet1")], state="deleted")) + commands = ["interface Ethernet1", "no description", "no shutdown"] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_delete_switchport(self): + set_module_args(dict(config=[dict(name="Ethernet2")], state="deleted")) + commands = ["interface Ethernet2", "switchport", "no shutdown"] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_speed_forced(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + description="Interface_1", + speed="forced 40g", + mode="layer3", + duplex="full", + ) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet1", + "description Interface_1", + "no switchport", + "speed forced 40gfull", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_speed_full(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + description="Interface_1", + speed="1000g", + duplex="full", + ) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet1", + "description Interface_1", + "speed 1000gfull", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_speed_auto(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + description="Interface_1", + speed="auto", + duplex="full", + ) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet1", + "description Interface_1", + "speed auto", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_speed_half(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + description="Interface_1", + speed="1000g", + duplex="half", + ) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet1", + "description Interface_1", + "speed 1000ghalf", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet2", description="Ethernet_2", mtu=1000), + dict(name="Ethernet1", description="Ethernet 1"), + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet2", + "description Ethernet_2", + "mtu 1000", + "switchport", + "interface Ethernet1", + "description Ethernet 1", + "interface Management1", + "no description", + "no shutdown", + "interface Ethernet4", + "speed auto", + "no shutdown", + ] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l2_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l2_interfaces.py new file mode 100644 index 00000000..1c07ef5c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l2_interfaces.py @@ -0,0 +1,222 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_l2_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosL2InterfacesModule(TestEosModule): + module = eos_l2_interfaces + + def setUp(self): + super(TestEosL2InterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.l2_interfaces.l2_interfaces.L2_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosL2InterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_l2_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_l2_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + trunk=dict( + native_vlan=10, trunk_allowed_vlans=["20-25"] + ), + ), + dict(name="Ethernet2", access=dict(vlan=30)), + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet1", + "switchport trunk native vlan 10", + "switchport trunk allowed vlan add 20,21,22,23,24,25", + "interface Ethernet2", + "switchport access vlan 30", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l2_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet2", trunk=dict(native_vlan=20)), + dict( + name="Ethernet1", + access=dict(vlan=20), + trunk=dict(trunk_allowed_vlans=["7-10"]), + ), + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l2_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + mode="trunk", + trunk=dict( + native_vlan=50, trunk_allowed_vlans=[3, "5"] + ), + ), + dict(name="Ethernet3", access=dict(vlan=30)), + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet2", + "switchport trunk native vlan 50", + "switchport trunk allowed vlan 3,5", + "interface Ethernet3", + "switchport access vlan 30", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l2_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + mode="trunk", + trunk=dict(native_vlan=20), + ), + dict( + name="Ethernet1", + access=dict(vlan=20), + trunk=dict(trunk_allowed_vlans=["7-10"]), + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l2_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + mode="trunk", + trunk=dict(native_vlan=50), + ) + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet2", + "switchport trunk native vlan 50", + "interface Ethernet1", + "no switchport access vlan", + "no switchport trunk allowed vlan", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l2_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + mode="trunk", + trunk=dict(native_vlan=20), + ), + dict( + name="Ethernet1", + access=dict(vlan=20), + trunk=dict(trunk_allowed_vlans=["7-10"]), + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l2_interfaces_deleted(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + mode="trunk", + trunk=dict(native_vlan=20), + ), + dict(name="Ethernet1", access=dict(vlan=20)), + ], + state="deleted", + ) + ) + commands = [ + "interface Ethernet2", + "no switchport mode", + "no switchport trunk native vlan", + "interface Ethernet1", + "no switchport access vlan", + "no switchport trunk allowed vlan", + ] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l3_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l3_interfaces.py new file mode 100644 index 00000000..ea6b1dca --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_l3_interfaces.py @@ -0,0 +1,269 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_l3_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosL3InterfacesModule(TestEosModule): + module = eos_l3_interfaces + + def setUp(self): + super(TestEosL3InterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.l3_interfaces.l3_interfaces.L3_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosL3InterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_l3_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_l3_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + ipv4=[dict(address="198.51.100.14/24")], + ), + dict( + name="Ethernet2", + ipv4=[dict(address="203.0.113.27/24")], + ), + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet1", + "ip address 198.51.100.14/24", + "interface Ethernet2", + "ip address 203.0.113.27/24", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l3_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", ipv4=[dict(address="192.0.2.12/24")] + ), + dict( + name="Ethernet2", ipv6=[dict(address="2001:db8::1/64")] + ), + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l3_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + ipv4=[dict(address="203.0.113.27/24")], + ), + dict( + name="Management1", + ipv4=[dict(address="dhcp")], + ipv6=[dict(address="auto-config")], + ), + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet2", + "no ipv6 address 2001:db8::1/64", + "ip address 203.0.113.27/24", + "interface Ethernet1", + "no ip address", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l3_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", ipv6=[dict(address="2001:db8::1/64")] + ), + dict( + name="Ethernet1", ipv4=[dict(address="192.0.2.12/24")] + ), + dict( + name="Management1", + ipv4=[dict(address="dhcp")], + ipv6=[dict(address="auto-config")], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l3_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", + ipv4=[dict(address="203.0.113.27/24")], + ) + ], + state="replaced", + ) + ) + commands = [ + "interface Ethernet2", + "ip address 203.0.113.27/24", + "no ipv6 address 2001:db8::1/64", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_l3_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", ipv6=[dict(address="2001:db8::1/64")] + ), + dict( + name="Ethernet1", ipv4=[dict(address="192.0.2.12/24")] + ), + dict( + name="Management1", + ipv4=[dict(address="dhcp")], + ipv6=[dict(address="auto-config")], + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l3_interfaces_deleted(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet2", ipv6=[dict(address="2001:db8::1/64")] + ) + ], + state="deleted", + ) + ) + commands = ["interface Ethernet2", "no ipv6 address 2001:db8::1/64"] + self.execute_module(changed=True, commands=commands) + + def test_eos_l3_interfaces_rendered(self): + set_module_args( + dict( + config=[ + dict( + name="Ethernet1", + ipv4=[dict(address="198.51.100.14/24")], + ), + dict( + name="Ethernet2", + ipv4=[dict(address="203.0.113.27/24")], + ), + ], + state="rendered", + ) + ) + commands = [ + "interface Ethernet1", + "ip address 198.51.100.14/24", + "interface Ethernet2", + "ip address 203.0.113.27/24", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_l3_interfaces_parsed(self): + commands = [ + "interface Ethernet1", + "ip address 198.51.100.14/24", + "interface Ethernet2", + "ip address 203.0.113.27/24", + ] + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = [ + {"name": "Ethernet1", "ipv4": [{"address": "198.51.100.14/24"}]}, + {"name": "Ethernet2", "ipv4": [{"address": "203.0.113.27/24"}]}, + ] + self.assertEqual(parsed_list, result["parsed"]) + + def test_eos_l3_interfaces_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module(changed=False) + gather_list = [ + {"name": "Ethernet1", "ipv4": [{"address": "192.0.2.12/24"}]}, + {"name": "Ethernet2", "ipv6": [{"address": "2001:db8::1/64"}]}, + { + "name": "Management1", + "ipv4": [{"address": "dhcp"}], + "ipv6": [{"address": "auto-config"}], + }, + ] + self.assertEqual(gather_list, result["gathered"]) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp.py new file mode 100644 index 00000000..a3524280 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp.py @@ -0,0 +1,110 @@ +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_lacp +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosLacpInterfacesModule(TestEosModule): + module = eos_lacp + + def setUp(self): + super(TestEosLacpInterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.lacp.lacp.LacpFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosLacpInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_lacp_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_lacp_default(self): + set_module_args(dict(config=dict(system=dict(priority=50)))) + commands = ["lacp system-priority 50"] + self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_default_idempotent(self): + set_module_args(dict(config=dict(system=dict(priority=10)))) + self.execute_module(changed=False, commands=[]) + + def test_eos_lacp_merged(self): + set_module_args( + dict(config=dict(system=dict(priority=50)), state="merged") + ) + commands = ["lacp system-priority 50"] + self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_merged_idempotent(self): + set_module_args( + dict(config=dict(system=dict(priority=10)), state="merged") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l3_interfaces_replaced(self): + set_module_args( + dict(config=dict(system=dict(priority=20)), state="replaced") + ) + commands = ["lacp system-priority 20"] + self.execute_module(changed=True, commands=commands) + + def test_eos_l3_interfaces_replaced_idempotent(self): + set_module_args( + dict(config=dict(system=dict(priority=10)), state="replaced") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_l3_interfaces_deleted(self): + set_module_args(dict(state="deleted")) + commands = ["no lacp system-priority"] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp_interfaces.py new file mode 100644 index 00000000..62a8f6f3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lacp_interfaces.py @@ -0,0 +1,170 @@ +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_lacp_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosLacpInterfacesModule(TestEosModule): + module = eos_lacp_interfaces + + def setUp(self): + super(TestEosLacpInterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.lacp_interfaces.lacp_interfaces.Lacp_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosLacpInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_lacp_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_lacp_interfaces_default(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet1", port_priority=45, rate="normal") + ] + ) + ) + commands = [ + "interface Ethernet1", + "lacp port-priority 45", + "lacp rate normal", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_interfaces_default_idempotent(self): + set_module_args(dict(config=[dict(name="Ethernet2", rate="fast")])) + self.execute_module(changed=False, commands=[]) + + def test_eos_lacp_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet1", port_priority=45, rate="normal"), + dict(name="Ethernet2", rate="normal"), + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet1", + "lacp port-priority 45", + "lacp rate normal", + "interface Ethernet2", + "lacp rate normal", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_interfaces_merged_idempotent(self): + set_module_args( + dict(config=[dict(name="Ethernet2", rate="fast")], state="merged") + ) + self.execute_module(changed=False, commands=[]) + + # Bug #64453 + # def test_eos_lacp_interfaces_replaced(self): + # set_module_args(dict( + # config=[dict( + # name="Ethernet1", + # port_priority=45, + # rate="normal" + # )], state="replaced" + # )) + # commands = ['interface Ethernet1', 'lacp port-priority 45', 'lacp rate normal'] + # self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[dict(name="Ethernet2", rate="fast")], state="replaced" + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_lacp_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet1", port_priority=45, rate="normal") + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet1", + "lacp port-priority 45", + "lacp rate normal", + "interface Ethernet2", + "no lacp port-priority", + "no lacp rate", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lacp_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict(name="Ethernet1", port_priority=30), + dict(name="Ethernet2", rate="fast"), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_lacp_interfaces_deleted(self): + set_module_args(dict(config=[dict(name="Ethernet2")], state="deleted")) + commands = ["interface Ethernet2", "no lacp rate"] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lag_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lag_interfaces.py new file mode 100644 index 00000000..b930a50e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lag_interfaces.py @@ -0,0 +1,289 @@ +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_lag_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosLagInterfacesModule(TestEosModule): + module = eos_lag_interfaces + + def setUp(self): + super(TestEosLagInterfacesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.lag_interfaces.lag_interfaces.Lag_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosLagInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_lag_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_lag_interfaces_digit_name_only(self): + set_module_args( + dict( + config=[ + dict( + name="1", + members=[ + dict(member="Ethernet1", mode="on"), + dict(member="Ethernet2", mode="on"), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet1", + "channel-group 1 mode on", + "interface Ethernet2", + "channel-group 1 mode on", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_portchannel_and_digit_name(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel1", + members=[ + dict(member="Ethernet1", mode="on"), + dict(member="Ethernet2", mode="on"), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "interface Ethernet1", + "channel-group 1 mode on", + "interface Ethernet2", + "channel-group 1 mode on", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel5", + members=[dict(member="Ethernet3", mode="passive")], + ) + ], + state="merged", + ) + ) + self.execute_module(changed=False) + + def test_eos_lag_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel1", + members=[dict(member="Ethernet3", mode="on")], + ) + ], + state="replaced", + ) + ) + commands = ["interface Ethernet3", "channel-group 1 mode on"] + + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel5", + members=[dict(member="Ethernet3", mode="passive")], + ) + ], + state="replaced", + ) + ) + self.execute_module(changed=False) + + def test_eos_lag_interfaces_overridden_newchannel(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel1", + members=[dict(member="Ethernet2", mode="on")], + ) + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet2", + "channel-group 1 mode on", + "no interface Port-Channel5", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_overridden_samechannel(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel5", + members=[dict(member="Ethernet2", mode="on")], + ) + ], + state="overridden", + ) + ) + commands = [ + "interface Ethernet2", + "channel-group 5 mode on", + "interface Ethernet3", + "no channel-group", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel5", + members=[dict(member="Ethernet3", mode="passive")], + ) + ], + state="overridden", + ) + ) + self.execute_module(changed=False) + + def test_eos_lag_interfaces_deleted(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel5", + members=[dict(member="Ethernet3", mode="passive")], + ) + ], + state="deleted", + ) + ) + commands = ["no interface Port-Channel5"] + + self.execute_module(changed=True, commands=commands) + + def test_eos_lag_interfaces_rendered(self): + set_module_args( + dict( + config=[ + dict( + name="Port-Channel1", + members=[ + dict(member="Ethernet1", mode="on"), + dict(member="Ethernet2", mode="on"), + ], + ) + ], + state="rendered", + ) + ) + commands = [ + "interface Ethernet1", + "channel-group 1 mode on", + "interface Ethernet2", + "channel-group 1 mode on", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_lag_interfaces_parsed(self): + commands = [ + "interface Ethernet1", + "channel-group 1 mode on", + "interface Ethernet2", + "channel-group 1 mode on", + ] + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = [ + { + "name": "Port-Channel1", + "members": [ + {"member": "Ethernet1", "mode": "on"}, + {"member": "Ethernet2", "mode": "on"}, + ], + } + ] + self.assertEqual(parsed_list, result["parsed"]) + + def test_eos_lag_interfaces_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module(changed=False) + gather_list = [ + { + "name": "Port-Channel5", + "members": [{"member": "Ethernet3", "mode": "passive"}], + } + ] + self.assertEqual(gather_list, result["gathered"]) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lldp_global.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lldp_global.py new file mode 100644 index 00000000..a1b9d840 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_lldp_global.py @@ -0,0 +1,218 @@ +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_lldp_global +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosLldpGlobalModule(TestEosModule): + module = eos_lldp_global + + def setUp(self): + super(TestEosLldpGlobalModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.lldp_global.lldp_global.Lldp_globalFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosLldpGlobalModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + def load_from_file(*args, **kwargs): + return load_fixture("eos_lldp_global_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_eos_lldp_global_merged(self): + set_module_args( + dict( + config=dict( + holdtime=100, + tlv_select=dict( + management_address=False, + port_description=False, + system_description=True, + ), + ), + state="merged", + ) + ) + commands = [ + "lldp holdtime 100", + "lldp tlv-select system-description", + "no lldp tlv-select port-description", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lldp_global_merged_idempotent(self): + set_module_args( + dict( + config=dict( + holdtime=200, + reinit=5, + timer=3000, + tlv_select=dict( + management_address=False, system_description=False + ), + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_lldp_global_replaced(self): + set_module_args( + dict( + config=dict( + holdtime=100, + tlv_select=dict( + management_address=False, + port_description=False, + system_description=True, + ), + ), + state="replaced", + ) + ) + commands = [ + "no lldp holdtime", + "no lldp reinit", + "no lldp timer", + "lldp holdtime 100", + "lldp tlv-select system-description", + "no lldp tlv-select port-description", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lldp_global_replaced_idempotent(self): + set_module_args( + dict( + config=dict( + holdtime=200, + reinit=5, + timer=3000, + tlv_select=dict( + management_address=False, system_description=False + ), + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_lldp_global_deleted(self): + set_module_args(dict(state="deleted")) + commands = [ + "no lldp holdtime", + "no lldp reinit", + "no lldp timer", + "lldp tlv-select management-address", + "lldp tlv-select system-description", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_lldp_global_parsed(self): + commands = [ + "lldp holdtime 100", + "lldp tlv-select system-description", + "lldp reinit 5", + "no lldp tlv-select port-description", + ] + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = { + "holdtime": "100", + "reinit": "5", + "tlv_select": {"port_description": False}, + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_eos_lldp_global_rendered(self): + set_module_args( + dict( + config=dict( + holdtime=100, + reinit=5, + timer=400, + tlv_select=dict( + management_address=False, + port_description=False, + system_description=True, + ), + ), + state="rendered", + ) + ) + commands = [ + "lldp holdtime 100", + "lldp reinit 5", + "lldp timer 400", + "lldp tlv-select system-description", + "no lldp tlv-select port-description", + "no lldp tlv-select management-address", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_lldp_global_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module(changed=False) + gather_list = { + "holdtime": "200", + "reinit": "5", + "timer": "3000", + "tlv_select": { + "management_address": False, + "system_description": False, + }, + } + self.assertEqual(sorted(gather_list), sorted(result["gathered"])) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_logging.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_logging.py new file mode 100644 index 00000000..b757eedd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_logging.py @@ -0,0 +1,112 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_logging +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosLoggingModule(TestEosModule): + + module = eos_logging + + def setUp(self): + super(TestEosLoggingModule, self).setUp() + self._log_config = load_fixture("eos_logging_config.cfg") + + self.mock_get_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_logging.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_logging.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestEosLoggingModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture("eos_logging_config.cfg") + self.load_config.return_value = dict(diff=None, session="session") + + def test_eos_setup_host_logging_idempotenet(self): + set_module_args(dict(dest="host", name="175.16.0.10", state="present")) + self.execute_module(changed=False, commands=[]) + + def test_eos_setup_host_logging(self): + set_module_args(dict(dest="host", name="175.16.0.1", state="present")) + commands = ["logging host 175.16.0.1"] + self.execute_module(changed=True, commands=commands) + + def test_eos_buffer_size_outofrange(self): + set_module_args(dict(dest="buffered", size=5)) + result = self.execute_module(failed=True) + self.assertEqual( + result["msg"], "size must be between 10 and 2147483647" + ) + + def test_eos_buffer_size_datatype(self): + set_module_args(dict(dest="buffered", size="ten")) + result = self.execute_module(failed=True) + self.assertIn("we were unable to convert to int", result["msg"]) + + def test_eos_buffer_size(self): + set_module_args(dict(dest="buffered", size=5000)) + commands = ["logging buffered 5000"] + self.execute_module(changed=True, commands=commands) + + def test_eos_buffer_size_idempotent(self): + set_module_args( + dict(dest="buffered", size=50000, level="informational") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_facilty(self): + set_module_args(dict(facility="local2")) + commands = ["logging facility local2"] + self.execute_module(changed=True, commands=commands) + + def test_eos_facility_idempotent(self): + set_module_args(dict(facility="local7")) + self.execute_module(changed=False, commands=[]) + + def test_eos_level(self): + set_module_args(dict(dest="console", level="critical")) + commands = ["logging console critical"] + self.execute_module(changed=True, commands=commands) + + def test_eos_level_idempotent(self): + set_module_args(dict(dest="console", level="warnings")) + self.execute_module(changed=False, commands=[]) + + def test_eos_logging_state_absent(self): + set_module_args(dict(dest="host", name="175.16.0.10", state="absent")) + commands = ["no logging host 175.16.0.10"] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospf_interfaces.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospf_interfaces.py new file mode 100644 index 00000000..5884f4c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospf_interfaces.py @@ -0,0 +1,632 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_ospf_interfaces +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosOspf_InterfacesModule(TestEosModule): + module = eos_ospf_interfaces + + def setUp(self): + super(TestEosOspf_InterfacesModule, self).setUp() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_config" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosOspf_InterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_ospf_interfaces_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_ospf_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + area=dict(area_id="0.0.0.10"), + cost=100, + mtu_ignore=True, + ), + dict( + afi="ipv6", + dead_interval=44, + ip_params=[ + dict( + afi="ipv6", + mtu_ignore=True, + network="point-to-point", + ) + ], + ), + ], + ), + dict( + name="Vlan2", + address_family=[ + dict( + afi="ipv6", + retransmit_interval=144, + authentication_v3=dict( + spi=30, + algorithm="md5", + keytype=7, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + ), + ip_params=[ + dict( + afi="ipv4", + priority=9, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ] + ) + ) + commands = [ + "interface Vlan1", + "ip ospf cost 100", + "ip ospf area 0.0.0.10", + "ospfv3 dead-interval 44", + "interface Vlan2", + "ospfv3 retransmit-interval 144", + "ospfv3 authentication ipsec spi 30 md5 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ==", + "ospfv3 ipv4 priority 9", + "ospfv3 ipv4 area 0.0.0.6", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospf_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + dead_interval=29, + hello_interval=66, + mtu_ignore=True, + ), + dict( + afi="ipv6", + bfd=True, + cost=106, + hello_interval=77, + transmit_delay=100, + ip_params=[ + dict( + afi="ipv4", + priority=45, + area=dict(area_id="0.0.0.5"), + ), + dict( + afi="ipv6", + passive_interface=True, + dead_interval=56, + retransmit_interval=115, + mtu_ignore=True, + network="point-to-point", + ), + ], + ), + ], + ), + dict( + name="Vlan3", + address_family=[ + dict( + afi="ipv6", + ip_params=[ + dict( + afi="ipv4", + hello_interval=45, + retransmit_interval=100, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ] + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospf_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + area=dict(area_id="0.0.0.10"), + cost=100, + mtu_ignore=True, + ), + dict( + afi="ipv6", + dead_interval=44, + ip_params=[ + dict( + afi="ipv6", + mtu_ignore=True, + network="point-to-point", + ) + ], + ), + ], + ), + dict( + name="Vlan2", + address_family=[ + dict( + afi="ipv6", + retransmit_interval=144, + authentication_v3=dict( + spi=30, + algorithm="md5", + keytype=7, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + ), + ip_params=[ + dict( + afi="ipv4", + priority=9, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ], + state="replaced", + ) + ) + commands = [ + "interface Vlan1", + "ip ospf cost 100", + "ip ospf area 0.0.0.10", + "ospfv3 dead-interval 44", + "no ospfv3 ipv4 priority 45", + "no ospfv3 ipv4 area 0.0.0.5", + "no ospfv3 ipv6 passive-interface", + "no ospfv3 ipv6 dead-interval 56", + "no ospfv3 ipv6 retransmit-interval 115", + "no ospfv3 bfd", + "no ospfv3 cost 106", + "no ospfv3 hello-interval 77", + "no ospfv3 transmit-delay 100", + "no ip ospf dead-interval 29", + "no ip ospf hello-interval 66", + "interface Vlan2", + "ospfv3 retransmit-interval 144", + "ospfv3 authentication ipsec spi 30 md5 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ==", + "ospfv3 ipv4 priority 9", + "ospfv3 ipv4 area 0.0.0.6", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospf_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + dead_interval=29, + hello_interval=66, + mtu_ignore=True, + ), + dict( + afi="ipv6", + bfd=True, + cost=106, + hello_interval=77, + transmit_delay=100, + ip_params=[ + dict( + afi="ipv4", + priority=45, + area=dict(area_id="0.0.0.5"), + ), + dict( + afi="ipv6", + passive_interface=True, + dead_interval=56, + retransmit_interval=115, + mtu_ignore=True, + network="point-to-point", + ), + ], + ), + ], + ), + dict( + name="Vlan3", + address_family=[ + dict( + afi="ipv6", + ip_params=[ + dict( + afi="ipv4", + hello_interval=45, + retransmit_interval=100, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospf_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + area=dict(area_id="0.0.0.10"), + cost=100, + mtu_ignore=True, + ), + dict( + afi="ipv6", + dead_interval=44, + ip_params=[ + dict( + afi="ipv6", + mtu_ignore=True, + network="point-to-point", + ) + ], + ), + ], + ), + dict( + name="Vlan2", + address_family=[ + dict( + afi="ipv6", + retransmit_interval=144, + authentication_v3=dict( + spi=30, + algorithm="md5", + keytype=7, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + ), + ip_params=[ + dict( + afi="ipv4", + priority=9, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ], + state="overridden", + ) + ) + commands = [ + "interface Vlan3", + "no ospfv3 ipv4 hello-interval 45", + "no ospfv3 ipv4 retransmit-interval 100", + "no ospfv3 ipv4 area 0.0.0.6", + "interface Vlan1", + "ip ospf area 0.0.0.10", + "ip ospf cost 100", + "no ip ospf dead-interval 29", + "no ip ospf hello-interval 66", + "ospfv3 dead-interval 44", + "no ospfv3 ipv4 priority 45", + "no ospfv3 ipv4 area 0.0.0.5", + "no ospfv3 ipv6 passive-interface", + "no ospfv3 ipv6 dead-interval 56", + "no ospfv3 ipv6 retransmit-interval 115", + "no ospfv3 bfd", + "no ospfv3 cost 106", + "no ospfv3 hello-interval 77", + "no ospfv3 transmit-delay 100", + "interface Vlan2", + "ospfv3 retransmit-interval 144", + "ospfv3 authentication ipsec spi 30 md5 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ==", + "ospfv3 ipv4 priority 9", + "ospfv3 ipv4 area 0.0.0.6", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_ospf_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + dead_interval=29, + hello_interval=66, + mtu_ignore=True, + ), + dict( + afi="ipv6", + bfd=True, + cost=106, + hello_interval=77, + transmit_delay=100, + ip_params=[ + dict( + afi="ipv4", + priority=45, + area=dict(area_id="0.0.0.5"), + ), + dict( + afi="ipv6", + passive_interface=True, + dead_interval=56, + retransmit_interval=115, + mtu_ignore=True, + network="point-to-point", + ), + ], + ), + ], + ), + dict( + name="Vlan3", + address_family=[ + dict( + afi="ipv6", + ip_params=[ + dict( + afi="ipv4", + hello_interval=45, + retransmit_interval=100, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospf_interfaces_deleted(self): + set_module_args(dict(config=[dict(name="Vlan1")], state="deleted")) + commands = [ + "interface Vlan1", + "no ospfv3 bfd", + "no ip ospf dead-interval 29", + "no ip ospf hello-interval 66", + "no ip ospf mtu-ignore", + "no ospfv3 cost 106", + "no ospfv3 hello-interval 77", + "no ospfv3 transmit-delay 100", + "no ospfv3 ipv4 priority 45", + "no ospfv3 ipv4 area 0.0.0.5", + "no ospfv3 ipv6 dead-interval 56", + "no ospfv3 ipv6 mtu-ignore", + "no ospfv3 ipv6 network point-to-point", + "no ospfv3 ipv6 passive-interface", + "no ospfv3 ipv6 retransmit-interval 115", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospf_interfaces_rendered(self): + set_module_args( + dict( + config=[ + dict( + name="Vlan1", + address_family=[ + dict( + afi="ipv4", + area=dict(area_id="0.0.0.10"), + cost=100, + mtu_ignore=True, + ), + dict( + afi="ipv6", + dead_interval=44, + ip_params=[ + dict( + afi="ipv6", + mtu_ignore=True, + network="point-to-point", + ) + ], + ), + ], + ), + dict( + name="Vlan2", + address_family=[ + dict( + afi="ipv6", + retransmit_interval=144, + authentication_v3=dict( + spi=30, + algorithm="md5", + keytype=7, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + ), + ip_params=[ + dict( + afi="ipv4", + priority=9, + area=dict(area_id="0.0.0.6"), + ) + ], + ) + ], + ), + ], + state="rendered", + ) + ) + commands = [ + "interface Vlan1", + "ip ospf cost 100", + "ip ospf area 0.0.0.10", + "ospfv3 dead-interval 44", + "ip ospf mtu-ignore", + "ospfv3 ipv6 mtu-ignore", + "ospfv3 ipv6 network point-to-point", + "interface Vlan2", + "ospfv3 retransmit-interval 144", + "ospfv3 authentication ipsec spi 30 md5 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ==", + "ospfv3 ipv4 priority 9", + "ospfv3 ipv4 area 0.0.0.6", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_vyos_ospf_interfaces_parsed(self): + commands = [ + "interface Vlan1", + "ip ospf cost 500", + "ip ospf mtu-ignore", + "ip ospf area 0.0.0.10", + "ospfv3 dead-interval 44", + "ospfv3 ipv6 mtu-ignore", + "ospfv3 ipv6 network point-to-point", + ] + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = [ + { + "address_family": [ + { + "afi": "ipv4", + "area": {"area_id": "0.0.0.10"}, + "mtu_ignore": True, + }, + { + "afi": "ipv6", + "ip_params": [ + { + "afi": "ipv6", + "mtu_ignore": True, + "network": "point-to-point", + } + ], + }, + ], + "name": "Vlan1", + } + ] + + self.assertEqual(parsed_list, result["parsed"]) + + def test_vyos_ospf_interfaces_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_ospf_interfaces_config.cfg" + ) + gathered_list = { + "Vlan1": [ + { + "afi": "ipv4", + "dead_interval": 29, + "hello_interval": 66, + "mtu_ignore": True, + }, + { + "afi": "ipv6", + "bfd": True, + "cost": 106, + "hello_interval": 77, + "ip_params": [ + { + "afi": "ipv4", + "area": {"area_id": "0.0.0.5"}, + "priority": 45, + }, + { + "afi": "ipv6", + "dead_interval": 56, + "mtu_ignore": True, + "network": "point-to-point", + "passive_interface": True, + "retransmit_interval": 115, + }, + ], + "transmit_delay": 100, + }, + ], + "Vlan3": [ + { + "afi": "ipv6", + "ip_params": [ + { + "afi": "ipv4", + "area": {"area_id": "0.0.0.6"}, + "hello_interval": 45, + "retransmit_interval": 100, + } + ], + } + ], + } + for entry in result["gathered"]: + if entry.get("name") in ["Vlan1", "Vlan3"]: + self.assertEqual( + gathered_list[entry["name"]], entry["address_family"] + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv2.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv2.py new file mode 100644 index 00000000..ecbe0e21 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv2.py @@ -0,0 +1,756 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_ospfv2 +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosOspfv2Module(TestEosModule): + module = eos_ospfv2 + + def setUp(self): + super(TestEosOspfv2Module, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosOspfv2Module, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_ospfv2_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_ospfv2_merged_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + adjacency=dict( + exchange_start=dict(threshold=20045623) + ), + areas=[ + dict( + filter=dict(address="10.1.1.0/24"), + area_id="0.0.0.2", + ), + dict( + area_id="0.0.0.50", + range=dict( + address="172.20.0.0/16", cost=34 + ), + ), + ], + default_information=dict( + metric=100, metric_type=1, originate=True + ), + distance=dict(intra_area=85), + max_lsa=dict( + count=80000, + threshold=40, + ignore_count=3, + ignore_time=6, + reset_time=20, + ), + networks=[ + dict(area="0.0.0.0", prefix="10.10.2.0/24"), + dict(area="0.0.0.0", prefix="10.10.3.0/24"), + ], + redistribute=[dict(routes="static")], + router_id="170.21.0.4", + ), + dict( + process_id=2, + vrf="vrf01", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + max_lsa=dict( + count=80000, + ignore_count=3, + ignore_time=6, + reset_time=20, + threshold=40, + ), + ), + dict( + process_id=3, + vrf="vrf02", + redistribute=[dict(routes="static")], + ), + ] + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv2_merged_partly_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + adjacency=dict( + exchange_start=dict(threshold=20045623) + ), + areas=[ + dict( + filter=dict(address="10.1.1.0/24"), + area_id="0.0.0.2", + ) + ], + distance=dict(intra_area=85), + max_lsa=dict( + count=80000, + threshold=40, + ignore_count=3, + ignore_time=6, + reset_time=20, + ), + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + redistribute=[dict(routes="static")], + router_id="170.21.0.4", + ), + dict( + process_id=2, + vrf="vrf01", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + ), + ] + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv2_merged(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + areas=[ + dict( + filter=dict(address="10.2.1.0/24"), + area_id="0.0.0.12", + ) + ], + redistribute=[ + dict(routes="isis", isis_level="level-1") + ], + ), + dict( + process_id=4, + vrf="vrftest", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + ), + ] + ), + state="merged", + ) + ) + commands = [ + "router ospf 1", + "area 0.0.0.12 filter 10.2.1.0/24", + "redistribute isis level-1", + "exit", + "router ospf 4 vrf vrftest", + "area 0.0.0.9 default-cost 20", + "network 10.10.3.0/24 area 0.0.0.0", + "exit", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv2_replaced(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + areas=[ + dict( + filter=dict(address="10.2.1.0/24"), + area_id="0.0.0.12", + ) + ], + redistribute=[ + dict(routes="isis", isis_level="level-1") + ], + ), + dict( + process_id=3, + vrf="vrf02", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + ), + ] + ), + state="replaced", + ) + ) + commands = [ + "router ospf 1", + "no adjacency exchange-start threshold 20045623", + "no area 0.0.0.2 filter 10.1.1.0/24", + "no area 0.0.0.50 range 172.20.0.0/16 cost 34", + "no default-information originate metric 100 metric-type 1", + "no distance ospf intra-area 85", + "no max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20", + "no network 10.10.2.0/24 area 0.0.0.0", + "no network 10.10.3.0/24 area 0.0.0.0", + "no redistribute static", + "no router-id 170.21.0.4", + "area 0.0.0.12 filter 10.2.1.0/24", + "redistribute isis level-1", + "exit", + "router ospf 3 vrf vrf02", + "no redistribute static", + "area 0.0.0.9 default-cost 20", + "network 10.10.3.0/24 area 0.0.0.0", + "exit", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv2_replaced_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + adjacency=dict( + exchange_start=dict(threshold=20045623) + ), + areas=[ + dict( + filter=dict(address="10.1.1.0/24"), + area_id="0.0.0.2", + ), + dict( + area_id="0.0.0.50", + range=dict( + address="172.20.0.0/16", cost=34 + ), + ), + ], + default_information=dict( + metric=100, metric_type=1, originate=True + ), + distance=dict(intra_area=85), + max_lsa=dict( + count=80000, + threshold=40, + ignore_count=3, + ignore_time=6, + reset_time=20, + ), + networks=[ + dict(area="0.0.0.0", prefix="10.10.2.0/24"), + dict(area="0.0.0.0", prefix="10.10.3.0/24"), + ], + redistribute=[dict(routes="static")], + router_id="170.21.0.4", + ), + dict( + process_id=2, + vrf="vrf01", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + max_lsa=dict( + count=80000, + ignore_count=3, + ignore_time=6, + reset_time=20, + threshold=40, + ), + ), + dict( + process_id=3, + vrf="vrf02", + redistribute=[dict(routes="static")], + ), + ] + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv2_overridden(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + areas=[ + dict( + filter=dict(address="10.2.1.0/24"), + area_id="0.0.0.12", + ) + ], + redistribute=[ + dict(routes="isis", isis_level="level-1") + ], + ), + dict( + process_id=3, + vrf="vrf02", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + ), + ] + ), + state="overridden", + ) + ) + commands = [ + "router ospf 1", + "no adjacency exchange-start threshold 20045623", + "no area 0.0.0.2 filter 10.1.1.0/24", + "no area 0.0.0.50 range 172.20.0.0/16 cost 34", + "no default-information originate metric 100 metric-type 1", + "no distance ospf intra-area 85", + "no max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20", + "no network 10.10.2.0/24 area 0.0.0.0", + "no network 10.10.3.0/24 area 0.0.0.0", + "no redistribute static", + "no router-id 170.21.0.4", + "area 0.0.0.12 filter 10.2.1.0/24", + "redistribute isis level-1", + "exit", + "no router ospf 2", + "router ospf 3 vrf vrf02", + "no redistribute static", + "area 0.0.0.9 default-cost 20", + "network 10.10.3.0/24 area 0.0.0.0", + "exit", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv2_overridden_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + adjacency=dict( + exchange_start=dict(threshold=20045623) + ), + areas=[ + dict( + filter=dict(address="10.1.1.0/24"), + area_id="0.0.0.2", + ), + dict( + area_id="0.0.0.50", + range=dict( + address="172.20.0.0/16", cost=34 + ), + ), + ], + default_information=dict( + metric=100, metric_type=1, originate=True + ), + distance=dict(intra_area=85), + max_lsa=dict( + count=80000, + threshold=40, + ignore_count=3, + ignore_time=6, + reset_time=20, + ), + networks=[ + dict(area="0.0.0.0", prefix="10.10.2.0/24"), + dict(area="0.0.0.0", prefix="10.10.3.0/24"), + ], + redistribute=[dict(routes="static")], + router_id="170.21.0.4", + ), + dict( + process_id=2, + vrf="vrf01", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + max_lsa=dict( + count=80000, + ignore_count=3, + ignore_time=6, + reset_time=20, + threshold=40, + ), + ), + dict( + process_id=3, + vrf="vrf02", + redistribute=[dict(routes="static")], + ), + ] + ), + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv2_error1(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + areas=[ + dict( + filter=dict(address="10.2.1.0/24"), + area_id="0.0.0.12", + ) + ], + redistribute=[ + dict(routes="isis", isis_level="level-1") + ], + ), + dict( + process_id=5, + vrf="vrf02", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + ), + ] + ) + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "Value of vrf and process_id does not match the config present in the device", + result["msg"], + ) + + def test_eos_ospfv2_error2(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + areas=[ + dict( + filter=dict(address="10.2.1.0/24"), + area_id="0.0.0.12", + ) + ], + redistribute=[ + dict(routes="isis", isis_level="level-1") + ], + ), + dict( + process_id=2, + vrf="vrf02", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + networks=[ + dict(area="0.0.0.0", prefix="10.10.3.0/24") + ], + ), + ] + ), + state="overridden", + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "Value of vrf and process_id does not match the config present in the device", + result["msg"], + ) + + def test_eos_ospfv2_rendered(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + process_id="1", + adjacency=dict( + exchange_start=dict(threshold=20045623) + ), + areas=[ + dict( + filter=dict(address="10.1.1.0/24"), + area_id="0.0.0.2", + ), + dict( + area_id="0.0.0.50", + range=dict( + address="172.20.0.0/16", cost=34 + ), + ), + ], + default_information=dict( + metric=100, metric_type=1, originate=True + ), + distance=dict(intra_area=85), + max_lsa=dict( + count=80000, + threshold=40, + ignore_count=3, + ignore_time=6, + reset_time=20, + ), + networks=[ + dict(area="0.0.0.0", prefix="10.10.2.0/24"), + dict(area="0.0.0.0", prefix="10.10.3.0/24"), + ], + redistribute=[dict(routes="static")], + router_id="170.21.0.4", + ), + dict( + process_id=2, + vrf="vrf01", + areas=[dict(default_cost=20, area_id="0.0.0.9")], + max_lsa=dict( + count=80000, + ignore_count=3, + ignore_time=6, + reset_time=20, + threshold=40, + ), + ), + dict( + process_id=3, + vrf="vrf02", + redistribute=[dict(routes="static")], + ), + ] + ), + state="rendered", + ) + ) + commands = [ + "router ospf 1", + "adjacency exchange-start threshold 20045623", + "area 0.0.0.2 filter 10.1.1.0/24", + "area 0.0.0.50 range 172.20.0.0/16 cost 34", + "default-information originate metric 100 metric-type 1", + "distance ospf intra-area 85", + "max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20", + "network 10.10.2.0/24 area 0.0.0.0", + "network 10.10.3.0/24 area 0.0.0.0", + "redistribute static", + "router-id 170.21.0.4", + "exit", + "router ospf 2 vrf vrf01", + "area 0.0.0.9 default-cost 20", + "max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20", + "exit", + "router ospf 3 vrf vrf02", + "redistribute static", + "exit", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_ospfv2_parsed(self): + commands = [ + "router ospf 1", + "adjacency exchange-start threshold 20045623", + "area 0.0.0.2 filter 10.1.1.0/24", + "area 0.0.0.50 range 172.20.0.0/16 cost 34", + "default-information originate metric 100 metric-type 1", + "distance ospf intra-area 85", + "max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20", + "network 10.10.2.0/24 area 0.0.0.0", + "network 10.10.3.0/24 area 0.0.0.0", + "redistribute static", + "router-id 170.21.0.4", + "exit", + "router ospf 3 vrf vrf02", + "redistribute static", + "exit", + ] + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = { + "processes": [ + { + "adjacency": {"exchange_start": {"threshold": 20045623}}, + "areas": [ + { + "filter": {"address": "10.1.1.0/24"}, + "area_id": "0.0.0.2", + }, + { + "area_id": "0.0.0.50", + "range": {"address": "172.20.0.0/16", "cost": 34}, + }, + ], + "default_information": { + "metric": 100, + "metric_type": 1, + "originate": True, + }, + "distance": {"intra_area": 85}, + "max_lsa": { + "count": 80000, + "ignore_count": 3, + "ignore_time": 6, + "reset_time": 20, + "threshold": 40, + }, + "networks": [ + {"area": "0.0.0.0", "prefix": "10.10.2.0/24"}, + {"area": "0.0.0.0", "prefix": "10.10.3.0/24"}, + ], + "process_id": 1, + "redistribute": [{"routes": "static"}], + "router_id": "170.21.0.4", + }, + { + "process_id": 3, + "redistribute": [{"routes": "static"}], + "vrf": "vrf02", + }, + ] + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_eos_ospfv2_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_ospfv2_config_gather.cfg" + ) + gather_list = { + "processes": [ + { + "adjacency": {"exchange_start": {"threshold": 20045623}}, + "areas": [ + { + "filter": {"address": "10.1.1.0/24"}, + "area_id": "0.0.0.2", + }, + { + "area_id": "0.0.0.50", + "range": {"address": "172.20.0.0/16", "cost": 34}, + }, + ], + "default_information": { + "metric": 100, + "metric_type": 1, + "originate": True, + }, + "distance": {"intra_area": 85}, + "max_lsa": { + "count": 80000, + "ignore_count": 3, + "ignore_time": 6, + "reset_time": 20, + "threshold": 40, + }, + "networks": [ + {"area": "0.0.0.0", "prefix": "10.10.2.0/24"}, + {"area": "0.0.0.0", "prefix": "10.10.3.0/24"}, + ], + "process_id": 1, + "redistribute": [{"routes": "static"}], + "router_id": "170.21.0.4", + }, + { + "process_id": 3, + "redistribute": [{"routes": "static"}], + "vrf": "vrf02", + }, + ] + } + self.assertEqual(sorted(gather_list), sorted(result["gathered"])) + + def test_eos_ospfv2_deleted(self): + set_module_args( + dict( + config=dict( + processes=[ + dict(process_id="1"), + dict( + process_id=3, + vrf="vrf02", + redistribute=[dict(routes="static")], + ), + ] + ), + state="deleted", + ) + ) + commands = [ + "no router ospf 1", + "router ospf 3 vrf vrf02", + "no redistribute static", + "exit", + ] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv3.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv3.py new file mode 100644 index 00000000..27199964 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_ospfv3.py @@ -0,0 +1,794 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_ospfv3 +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosOspfv3Module(TestEosModule): + module = eos_ospfv3 + + def setUp(self): + super(TestEosOspfv3Module, self).setUp() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.ospfv3.ospfv3.Ospfv3Facts.get_config" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosOspfv3Module, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_ospfv3_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_ospfv3_merged_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="default", + adjacency=dict(exchange_start=dict(threshold=11)), + areas=[ + dict(stub=dict(set=True), area_id="0.0.0.20"), + dict( + area_id="0.0.0.40", + stub=dict(set=True), + default_cost=45, + ), + ], + timers=dict(pacing=7), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[dict(routes="connected")], + ), + dict( + afi="ipv6", + fips_restrictions=True, + router_id="10.1.1.1", + ), + ], + ), + dict( + vrf="vrf01", + bfd=dict(all_interfaces=True), + log_adjacency_changes=dict(detail=True), + areas=[ + dict( + area_id="0.0.0.0", + encryption=dict( + algorithm="sha1", + hidden_key=True, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + encryption="null", + spi=44, + ), + ) + ], + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[ + dict( + routes="connected", + route_map="MAP01", + ) + ], + passive_interface=True, + maximum_paths=100, + ), + dict( + afi="ipv6", + fips_restrictions=True, + areas=[ + dict( + area_id="0.0.0.10", + nssa=dict(no_summary=True), + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + max_metric=dict( + router_lsa=dict( + external_lsa=dict( + max_metric_value=25 + ), + summary_lsa=dict(set=True), + ) + ), + ), + ], + ), + dict( + vrf="vrf02", + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + fips_restrictions=True, + areas=[ + dict( + area_id="0.0.0.1", + stub=dict(set=True), + ) + ], + distance=200, + router_id="10.17.0.3", + timers=dict( + out_delay=10, + throttle=dict( + initial=56, + max=56, + min=56, + spf=True, + ), + ), + ) + ], + ), + ] + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv3_merged(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="default", + areas=[ + dict( + area_id="0.0.0.20", + authentication=dict( + algorithm="sha1", + spi="33", + hidden_key=True, + passphrase="4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + ), + ) + ], + timers=dict(pacing=7), + ), + dict( + vrf="vrf03", + log_adjacency_changes=dict(detail=True), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + areas=[ + dict( + area_id="0.0.0.43", + nssa=dict(no_summary=True), + ranges=[ + dict( + address="20.1.1.0/24", + advertise=False, + ) + ], + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + graceful_restart=dict(set=True), + ) + ], + ), + ] + ), + state="merged", + ) + ) + commands = [ + "router ospfv3", + "area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + "exit", + "router ospfv3 vrf vrf03", + "fips restrictions", + "log-adjacency-changes detail", + "address-family ipv6", + "area 0.0.0.43 nssa no-summary", + "area 0.0.0.43 range 20.1.1.0/24 not-advertise", + "default-information originate route-map DefaultRouteFilter", + "graceful-restart", + "exit", + "exit", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv3_replaced(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="vrf02", + areas=[ + dict( + area_id="0.0.0.20", + authentication=dict( + algorithm="sha1", + spi="33", + hidden_key=True, + passphrase="4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + ), + ) + ], + log_adjacency_changes=dict(detail=True), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + areas=[ + dict( + area_id="0.0.0.43", + nssa=dict(no_summary=True), + ranges=[ + dict( + address="20.1.1.0/24", + advertise=False, + ) + ], + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + graceful_restart=dict(set=True), + ) + ], + ) + ] + ), + state="replaced", + ) + ) + commands = [ + "router ospfv3 vrf vrf02", + "address-family ipv6", + "no area 0.0.0.1 stub", + "no distance ospf intra-area 200", + "no fips restrictions", + "no router-id", + "no timers out-delay 10", + "no timers throttle spf 56 56 56", + "area 0.0.0.43 nssa no-summary", + "area 0.0.0.43 range 20.1.1.0/24 not-advertise", + "default-information originate route-map DefaultRouteFilter", + "graceful-restart", + "exit", + "area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + "log-adjacency-changes detail", + "exit", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv3_replaced_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="vrf01", + bfd=dict(all_interfaces=True), + log_adjacency_changes=dict(detail=True), + areas=[ + dict( + area_id="0.0.0.0", + encryption=dict( + algorithm="sha1", + hidden_key=True, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + encryption="null", + spi=44, + ), + ) + ], + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[ + dict( + routes="connected", + route_map="MAP01", + ) + ], + passive_interface=True, + maximum_paths=100, + ), + dict( + afi="ipv6", + fips_restrictions=True, + areas=[ + dict( + area_id="0.0.0.10", + nssa=dict(no_summary=True), + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + max_metric=dict( + router_lsa=dict( + external_lsa=dict( + max_metric_value=25 + ), + summary_lsa=dict(set=True), + ) + ), + ), + ], + ) + ] + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv3_overridden_idempotent(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="default", + adjacency=dict(exchange_start=dict(threshold=11)), + areas=[ + dict(stub=dict(set=True), area_id="0.0.0.20"), + dict( + area_id="0.0.0.40", + stub=dict(set=True), + default_cost=45, + ), + ], + timers=dict(pacing=7), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[dict(routes="connected")], + ), + dict( + afi="ipv6", + fips_restrictions=True, + router_id="10.1.1.1", + ), + ], + ), + dict( + vrf="vrf01", + bfd=dict(all_interfaces=True), + log_adjacency_changes=dict(detail=True), + areas=[ + dict( + area_id="0.0.0.0", + encryption=dict( + algorithm="sha1", + hidden_key=True, + passphrase="7hl8FV3lZ6H1mAKpjL47hQ==", + encryption="null", + spi=44, + ), + ) + ], + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[ + dict( + routes="connected", + route_map="MAP01", + ) + ], + passive_interface=True, + maximum_paths=100, + ), + dict( + afi="ipv6", + fips_restrictions=True, + areas=[ + dict( + area_id="0.0.0.10", + nssa=dict(no_summary=True), + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + max_metric=dict( + router_lsa=dict( + external_lsa=dict( + max_metric_value=25 + ), + summary_lsa=dict(set=True), + ) + ), + ), + ], + ), + dict( + vrf="vrf02", + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + fips_restrictions=True, + areas=[ + dict( + area_id="0.0.0.1", + stub=dict(set=True), + ) + ], + distance=200, + router_id="10.17.0.3", + timers=dict( + out_delay=10, + throttle=dict( + initial=56, + max=56, + min=56, + spf=True, + ), + ), + ) + ], + ), + ] + ), + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_ospfv3_overridden(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="default", + adjacency=dict(exchange_start=dict(threshold=11)), + areas=[ + dict(stub=dict(set=True), area_id="0.0.0.20"), + dict( + area_id="0.0.0.40", + stub=dict(set=True), + default_cost=45, + ), + ], + timers=dict(pacing=7), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv4", + fips_restrictions=True, + redistribute=[dict(routes="connected")], + ), + dict( + afi="ipv6", + fips_restrictions=True, + router_id="10.1.1.1", + ), + ], + ), + dict( + vrf="vrf02", + areas=[ + dict( + area_id="0.0.0.20", + authentication=dict( + algorithm="sha1", + spi="33", + hidden_key=True, + passphrase="4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + ), + ) + ], + log_adjacency_changes=dict(detail=True), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + areas=[ + dict( + area_id="0.0.0.43", + nssa=dict(no_summary=True), + ranges=[ + dict( + address="20.1.1.0/24", + advertise=False, + ) + ], + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + graceful_restart=dict(set=True), + ) + ], + ), + ] + ), + state="overridden", + ) + ) + commands = [ + "router ospfv3 vrf vrf02", + "address-family ipv6", + "no area 0.0.0.1 stub", + "no distance ospf intra-area 200", + "no fips restrictions", + "no router-id", + "no timers out-delay 10", + "no timers throttle spf 56 56 56", + "area 0.0.0.43 nssa no-summary", + "area 0.0.0.43 range 20.1.1.0/24 not-advertise", + "default-information originate route-map DefaultRouteFilter", + "graceful-restart", + "exit", + "area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + "log-adjacency-changes detail", + "exit", + "no router ospfv3 vrf vrf01", + ] + + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv3_deleted(self): + set_module_args( + dict( + config=dict( + processes=[dict(vrf="default"), dict(vrf="vrf02")] + ), + state="deleted", + ) + ) + commands = ["no router ospfv3 vrf vrf02", "no router ospfv3"] + + self.execute_module(changed=True, commands=commands) + + def test_eos_ospfv3_rendered(self): + set_module_args( + dict( + config=dict( + processes=[ + dict( + vrf="default", + areas=[ + dict( + area_id="0.0.0.20", + authentication=dict( + algorithm="sha1", + spi="33", + hidden_key=True, + passphrase="4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + ), + ) + ], + timers=dict(pacing=7), + ), + dict( + vrf="vrf03", + log_adjacency_changes=dict(detail=True), + fips_restrictions=True, + address_family=[ + dict( + afi="ipv6", + areas=[ + dict( + area_id="0.0.0.43", + nssa=dict(no_summary=True), + ranges=[ + dict( + address="20.1.1.0/24", + advertise=False, + ) + ], + ) + ], + default_information=dict( + originate=True, + route_map="DefaultRouteFilter", + ), + graceful_restart=dict(set=True), + ) + ], + ), + ] + ), + state="rendered", + ) + ) + commands = [ + "router ospfv3", + "area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + "timers pacing flood 7", + "exit", + "router ospfv3 vrf vrf03", + "fips restrictions", + "log-adjacency-changes detail", + "address-family ipv6", + "area 0.0.0.43 nssa no-summary", + "area 0.0.0.43 range 20.1.1.0/24 not-advertise", + "default-information originate route-map DefaultRouteFilter", + "graceful-restart", + "exit", + "exit", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_ospfv3_parsed(self): + commands = [ + "router ospfv3", + "area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + "timers pacing flood 7", + "exit", + "router ospfv3 vrf vrf03", + "fips restrictions", + "log-adjacency-changes detail", + "address-family ipv6", + "area 0.0.0.43 nssa no-summary", + "area 0.0.0.43 range 20.1.1.0/24 not-advertise", + "default-information originate route-map DefaultRouteFilter", + "graceful-restart", + "exit", + "exit", + ] + + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = { + "processes": [ + { + "vrf": "default", + "areas": [ + { + "area_id": "0.0.0.20", + "authentication": { + "algorithm": "sha1", + "spi": 33, + "hidden_key": True, + "passphrase": "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + }, + } + ], + "timers": {"pacing": 7}, + }, + { + "vrf": "vrf03", + "log_adjacency_changes": {"detail": True}, + "fips_restrictions": True, + "address_family": [ + { + "afi": "ipv6", + "areas": [ + { + "area_id": "0.0.0.43", + "nssa": {"no_summary": True}, + "ranges": [ + { + "address": "20.1.1.0/24", + "advertise": False, + } + ], + } + ], + "default_information": { + "originate": True, + "route_map": "DefaultRouteFilter", + }, + "graceful_restart": {"set": True}, + } + ], + }, + ] + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_eos_ospfv3_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="eos_ospfv3_config_gather.cfg" + ) + gather_list = { + "processes": [ + { + "vrf": "default", + "areas": [ + { + "area_id": "0.0.0.20", + "authentication": { + "algorithm": "sha1", + "spi": 33, + "hidden_key": True, + "passphrase": "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w", + }, + } + ], + "timers": {"pacing": 7}, + }, + { + "vrf": "vrf03", + "log_adjacency_changes": {"detail": True}, + "fips_restrictions": True, + "address_family": [ + { + "afi": "ipv6", + "areas": [ + { + "area_id": "0.0.0.43", + "nssa": {"no_summary": True}, + "ranges": [ + { + "address": "20.1.1.0/24", + "advertise": False, + } + ], + } + ], + "default_information": { + "originate": True, + "route_map": "DefaultRouteFilter", + }, + "graceful_restart": {"set": True}, + } + ], + }, + ] + } + self.assertEqual(sorted(gather_list), sorted(result["gathered"])) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_static_routes.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_static_routes.py new file mode 100644 index 00000000..fc99f153 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_static_routes.py @@ -0,0 +1,437 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_static_routes +from ansible_collections.arista.eos.plugins.module_utils.network.eos.config.static_routes.static_routes import ( + add_commands, +) +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture +import itertools + + +class TestEosStaticRoutesModule(TestEosModule): + module = eos_static_routes + + def setUp(self): + super(TestEosStaticRoutesModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.facts.static_routes.static_routes.Static_routesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosStaticRoutesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "eos_static_routes_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_eos_static_routes_merged(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1200:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=55, + ) + ], + ) + ], + ) + ], + ) + ], + state="merged", + ) + ) + commands = ["ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55"] + self.execute_module(changed=True, commands=commands) + + def test_eos_static_routes_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="120.1.1.0/24", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=23, + ) + ], + ) + ], + ) + ], + ) + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_static_routes_default(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1200:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=55, + ) + ], + ) + ], + ) + ], + ) + ] + ) + ) + commands = ["ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55"] + self.execute_module(changed=True, commands=commands) + + def test_eos_static_routes_default_idempotent(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="120.1.1.0/24", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=23, + ) + ], + ) + ], + ) + ], + ) + ] + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_static_routes_replaced(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1000:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=55, + ) + ], + ) + ], + ) + ] + ) + ], + state="replaced", + ) + ) + commands = [ + "ipv6 route 1000:10::/64 Ethernet1 55", + "no ipv6 route 1000:10::/64 Ethernet1 67 tag 98", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_static_routes_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="120.1.1.0/24", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=23, + ) + ], + ) + ], + ) + ], + ) + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_static_routes_overridden(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1200:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=55, + ) + ], + ) + ], + ) + ], + ) + ], + state="overridden", + ) + ) + commands = [ + "ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55", + "no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23", + "no ip route 10.1.1.0/24 Management1", + "no ipv6 route 1000:10::/64 Ethernet1 67 tag 98", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_static_routes_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="120.1.1.0/24", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=23, + ) + ], + ) + ], + ) + ], + ), + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="10.1.1.0/24", + next_hops=[ + dict(interface="Management1") + ], + ) + ], + ) + ] + ), + dict( + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1000:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=67, + tag=98, + ) + ], + ) + ], + ) + ] + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_static_routes_deletedafi(self): + set_module_args( + dict( + config=[dict(address_families=[dict(afi="ipv4")])], + state="deleted", + ) + ) + commands = [ + "no ip route 10.1.1.0/24 Management1", + "no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_static_routes_gathered(self): + set_module_args(dict(config=[], state="gathered")) + result = self.execute_module( + changed=False, filename="eos_static_routes_config.cfg" + ) + commands = [] + for gathered_cmds in result["gathered"]: + cfg = add_commands(gathered_cmds) + commands.append(cfg) + commands = list(itertools.chain(*commands)) + config_commands = [ + "ip route 10.1.1.0/24 Management1", + "ipv6 route 1000:10::/64 Ethernet1 67 tag 98", + "ip route vrf testvrf 120.1.1.0/24 Ethernet1 23", + ] + self.assertEqual( + sorted(config_commands), sorted(commands), result["gathered"] + ) + + def test_eos_static_routes_rendered(self): + set_module_args( + dict( + config=[ + dict( + vrf="testvrf", + address_families=[ + dict( + afi="ipv6", + routes=[ + dict( + dest="1200:10::/64", + next_hops=[ + dict( + interface="Ethernet1", + admin_distance=55, + ) + ], + ) + ], + ) + ], + ) + ], + state="rendered", + ) + ) + commands = ["ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55"] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_eos_static_routes_parsed(self): + set_module_args( + dict( + running_config="ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55", + state="parsed", + ) + ) + commands = ["ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55"] + result = self.execute_module(changed=False) + parsed_commands = [] + for cmds in result["parsed"]: + cfg = add_commands(cmds) + parsed_commands.append(cfg) + parsed_commands = list(itertools.chain(*parsed_commands)) + self.assertEqual( + sorted(parsed_commands), sorted(commands), result["parsed"] + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_system.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_system.py new file mode 100644 index 00000000..2b4fd8b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_system.py @@ -0,0 +1,127 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_system +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosSystemModule(TestEosModule): + + module = eos_system + + def setUp(self): + super(TestEosSystemModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_system.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_system.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestEosSystemModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture("eos_system_config.cfg") + self.load_config.return_value = dict(diff=None, session="session") + + def test_eos_system_hostname_changed(self): + set_module_args(dict(hostname="foo")) + commands = ["hostname foo"] + self.execute_module(changed=True, commands=commands) + + def test_eos_system_domain_name(self): + set_module_args(dict(domain_name="test.com")) + commands = ["ip domain-name test.com"] + self.execute_module(changed=True, commands=commands) + + def test_eos_system_domain_list(self): + set_module_args(dict(domain_list=["ansible.com", "redhat.com"])) + commands = [ + "no ip domain-list ops.ansible.com", + "ip domain-list redhat.com", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_system_lookup_source(self): + set_module_args(dict(lookup_source=["Ethernet1"])) + commands = [ + "no ip domain lookup source-interface Management1", + "ip domain lookup source-interface Ethernet1", + ] + self.execute_module(changed=True, commands=commands) + + def test_eos_system_lookup_source_complex(self): + lookup_source = [ + {"interface": "Management1", "vrf": "mgmt"}, + {"interface": "Ethernet1"}, + ] + set_module_args(dict(lookup_source=lookup_source)) + commands = [ + "no ip domain lookup source-interface Management1", + "ip domain lookup vrf mgmt source-interface Management1", + "ip domain lookup source-interface Ethernet1", + ] + self.execute_module(changed=True, commands=commands) + + # def test_eos_system_name_servers(self): + # name_servers = ['8.8.8.8', '8.8.4.4'] + # set_module_args(dict(name_servers=name_servers)) + # commands = ['ip name-server 8.8.4.4', + # 'no ip name-server vrf mgmt 8.8.4.4'] + # self.execute_module(changed=True, commands=commands) + + # def rest_eos_system_name_servers_complex(self): + # name_servers = dict(server='8.8.8.8', vrf='test') + # set_module_args(dict(name_servers=name_servers)) + # commands = ['ip name-server vrf test 8.8.8.8', + # 'no ip name-server vrf default 8.8.8.8', + # 'no ip name-server vrf mgmt 8.8.4.4'] + # self.execute_module(changed=True, commands=commands) + + def test_eos_system_state_absent(self): + set_module_args(dict(state="absent")) + commands = ["no ip domain-name", "no hostname"] + self.execute_module(changed=True, commands=commands) + + def test_eos_system_no_change(self): + set_module_args( + dict(hostname="switch01", domain_name="eng.ansible.com") + ) + commands = [] + self.execute_module(commands=commands) + + def test_eos_system_missing_vrf(self): + name_servers = dict(server="8.8.8.8", vrf="missing") + set_module_args(dict(name_servers=name_servers)) + self.execute_module(failed=True) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_user.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_user.py new file mode 100644 index 00000000..40ae0f41 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_user.py @@ -0,0 +1,131 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_user +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosUserModule(TestEosModule): + + module = eos_user + + def setUp(self): + super(TestEosUserModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_user.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.arista.eos.plugins.modules.eos_user.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestEosUserModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture("eos_user_config.cfg") + self.load_config.return_value = dict(diff=None, session="session") + + def test_eos_user_create(self): + set_module_args(dict(name="test", nopassword=True)) + commands = ["username test nopassword"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_delete(self): + set_module_args(dict(name="ansible", state="absent")) + commands = ["no username ansible"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_password(self): + set_module_args(dict(name="ansible", configured_password="test")) + commands = ["username ansible secret test"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_privilege(self): + set_module_args( + dict(name="ansible", privilege=15, configured_password="test") + ) + result = self.execute_module(changed=True) + self.assertIn("username ansible privilege 15", result["commands"]) + + def test_eos_user_privilege_invalid(self): + set_module_args( + dict(name="ansible", privilege=25, configured_password="test") + ) + self.execute_module(failed=True) + + def test_eos_user_purge(self): + set_module_args(dict(purge=True)) + commands = ["no username ansible"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_role(self): + set_module_args( + dict(name="ansible", role="test", configured_password="test") + ) + result = self.execute_module(changed=True) + self.assertIn("username ansible role test", result["commands"]) + + def test_eos_user_sshkey(self): + set_module_args(dict(name="ansible", sshkey="test")) + commands = ["username ansible sshkey test"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_update_password_changed(self): + set_module_args( + dict( + name="test", + configured_password="test", + update_password="on_create", + ) + ) + commands = ["username test secret test"] + self.execute_module(changed=True, commands=commands) + + def test_eos_user_update_password_on_create_ok(self): + set_module_args( + dict( + name="ansible", + configured_password="test", + update_password="on_create", + ) + ) + self.execute_module() + + def test_eos_user_update_password_always(self): + set_module_args( + dict( + name="ansible", + configured_password="test", + update_password="always", + ) + ) + commands = ["username ansible secret test"] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_vlans.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_vlans.py new file mode 100644 index 00000000..7c9a5814 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/network/eos/test_eos_vlans.py @@ -0,0 +1,165 @@ +# +# (c) 2019, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible_collections.arista.eos.plugins.modules import eos_vlans +from ansible_collections.arista.eos.tests.unit.modules.utils import ( + set_module_args, +) +from .eos_module import TestEosModule, load_fixture + + +class TestEosVlansModule(TestEosModule): + module = eos_vlans + + def setUp(self): + super(TestEosVlansModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_edit_config = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.providers.providers.CliProvider.edit_config" + ) + self.edit_config = self.mock_edit_config.start() + + self.mock_execute_show_command = patch( + "ansible_collections.arista.eos.plugins.module_utils.network.eos.config.vlans.vlans.Vlans.get_vlans_facts" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestEosVlansModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_edit_config.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + file_cmd = load_fixture("eos_vlan_config.cfg").split() + file_cmd_dict = {} + for i in range(0, len(file_cmd), 2): + if file_cmd[i] == "vlan_id": + y = int(file_cmd[i + 1]) + else: + y = file_cmd[i + 1] + file_cmd_dict.update({file_cmd[i]: y}) + self.execute_show_command.return_value = [file_cmd_dict] + + def test_eos_vlan_default(self): + self.execute_show_command.return_value = [] + set_module_args(dict(config=[dict(vlan_id=30, name="thirty")])) + commands = ["vlan 30", "name thirty"] + self.execute_module(changed=True, commands=commands) + + def test_eos_vlan_default_idempotent(self): + self.execute_show_command.return_value = load_fixture( + "eos_vlan_config.cfg" + ) + set_module_args(dict(config=[dict(vlan_id=10, name="ten")])) + self.execute_module(changed=False, commands=[]) + + def test_eos_vlan_merged(self): + self.execute_show_command.return_value = [] + set_module_args( + dict(config=[dict(vlan_id=30, name="thirty")], state="merged") + ) + commands = ["vlan 30", "name thirty"] + self.execute_module(changed=True, commands=commands) + + def test_eos_vlan_merged_idempotent(self): + self.execute_show_command.return_value = load_fixture( + "eos_vlan_config.cfg" + ) + set_module_args( + dict(config=[dict(vlan_id=10, name="ten")], state="merged") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_vlan_replaced(self): + self.execute_show_command.return_value = [] + set_module_args( + dict( + config=[dict(vlan_id=10, name="tenreplaced", state="suspend")], + state="replaced", + ) + ) + commands = ["vlan 10", "name tenreplaced", "state suspend"] + self.execute_module(changed=True, commands=commands) + + def test_eos_vlan_replaced_idempotent(self): + self.execute_show_command.return_value = load_fixture( + "eos_vlan_config.cfg" + ) + set_module_args( + dict(config=[dict(vlan_id=10, name="ten")], state="replaced") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_vlan_overridden(self): + self.execute_show_command.return_value = [] + set_module_args( + dict( + config=[dict(vlan_id=30, name="thirty", state="suspend")], + state="overridden", + ) + ) + commands = ["no vlan 10", "vlan 30", "name thirty", "state suspend"] + self.execute_module(changed=True, commands=commands) + + def test_eos_vlan_overridden_idempotent(self): + self.execute_show_command.return_value = load_fixture( + "eos_vlan_config.cfg" + ) + set_module_args( + dict(config=[dict(vlan_id=10, name="ten")], state="overridden") + ) + self.execute_module(changed=False, commands=[]) + + def test_eos_vlan_deleted(self): + set_module_args( + dict(config=[dict(vlan_id=10, name="ten")], state="deleted") + ) + commands = ["no vlan 10"] + self.execute_module(changed=True, commands=commands) + + def test_eos_vlan_id_datatype(self): + set_module_args(dict(config=[dict(vlan_id="thirty")])) + result = self.execute_module(failed=True) + self.assertIn("we were unable to convert to int", result["msg"]) + + def test_eos_vlan_state_datatype(self): + set_module_args(dict(config=[dict(vlan_id=30, state=10)])) + result = self.execute_module(failed=True) + self.assertIn( + "value of state must be one of: active, suspend", result["msg"] + ) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/utils.py b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/utils.py new file mode 100644 index 00000000..9550952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/modules/utils.py @@ -0,0 +1,51 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import json + +from ansible_collections.arista.eos.tests.unit.compat import unittest +from ansible_collections.arista.eos.tests.unit.compat.mock import patch +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes + + +def set_module_args(args): + if "_ansible_remote_tmp" not in args: + args["_ansible_remote_tmp"] = "/tmp" + if "_ansible_keep_remote_files" not in args: + args["_ansible_keep_remote_files"] = False + + args = json.dumps({"ANSIBLE_MODULE_ARGS": args}) + basic._ANSIBLE_ARGS = to_bytes(args) + + +class AnsibleExitJson(Exception): + pass + + +class AnsibleFailJson(Exception): + pass + + +def exit_json(*args, **kwargs): + if "changed" not in kwargs: + kwargs["changed"] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): + kwargs["failed"] = True + raise AnsibleFailJson(kwargs) + + +class ModuleTestCase(unittest.TestCase): + def setUp(self): + self.mock_module = patch.multiple( + basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json + ) + self.mock_module.start() + self.mock_sleep = patch("time.sleep") + self.mock_sleep.start() + set_module_args({}) + self.addCleanup(self.mock_module.stop) + self.addCleanup(self.mock_sleep.stop) diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/unit/requirements.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/requirements.txt new file mode 100644 index 00000000..a9772bea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/unit/requirements.txt @@ -0,0 +1,42 @@ +boto3 +placebo +pycrypto +passlib +pypsrp +python-memcached +pytz +pyvmomi +redis +requests +setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok) +unittest2 ; python_version < '2.7' +importlib ; python_version < '2.7' +netaddr +ipaddress +netapp-lib +solidfire-sdk-python + +# requirements for F5 specific modules +f5-sdk ; python_version >= '2.7' +f5-icontrol-rest ; python_version >= '2.7' +deepdiff + +# requirement for Fortinet specific modules +pyFMG + +# requirement for aci_rest module +xmljson + +# requirement for winrm connection plugin tests +pexpect + +# requirement for the linode module +linode-python # APIv3 +linode_api4 ; python_version > '2.6' # APIv4 + +# requirement for the gitlab module +python-gitlab +httmock + +# requirment for kubevirt modules +openshift ; python_version >= '2.7' |