diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2019-08-08 18:23:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-08 18:23:54 +0530 |
commit | 6f0aae256db139588a578f78d65407b01fee062e (patch) | |
tree | 9791716d8a068442fa4d3df7b8d451843068a3eb /test | |
parent | f6ae6eb3e0d709404cc6f47b27c047b4dc9538cf (diff) | |
download | ansible-6f0aae256db139588a578f78d65407b01fee062e.tar.gz |
Add [junos_lldp_interfaces] model (#59720)
* Add [junos_lldp_interfaces] model
* Add new resource module junos_lldp_interface
* Targets model https://github.com/ansible-network/resource_module_models/pull/40
* Deprecate junos_lldp_interface module
* Fix CI issues
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/targets/junos_interfaces/meta/main.yaml (renamed from test/integration/targets/junos_interfaces/meta/main.yml) | 0 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/defaults/main.yaml | 3 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/meta/main.yaml | 2 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tasks/main.yaml | 2 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml | 17 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml | 11 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml | 87 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml | 58 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml | 63 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml | 66 | ||||
-rw-r--r-- | test/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml | 72 | ||||
-rw-r--r-- | test/sanity/ignore.txt | 8 |
12 files changed, 385 insertions, 4 deletions
diff --git a/test/integration/targets/junos_interfaces/meta/main.yml b/test/integration/targets/junos_interfaces/meta/main.yaml index 191a0f2ea1..191a0f2ea1 100644 --- a/test/integration/targets/junos_interfaces/meta/main.yml +++ b/test/integration/targets/junos_interfaces/meta/main.yaml diff --git a/test/integration/targets/junos_lldp_interfaces/defaults/main.yaml b/test/integration/targets/junos_lldp_interfaces/defaults/main.yaml new file mode 100644 index 0000000000..164afead28 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/test/integration/targets/junos_lldp_interfaces/meta/main.yaml b/test/integration/targets/junos_lldp_interfaces/meta/main.yaml new file mode 100644 index 0000000000..191a0f2ea1 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_junos_tests diff --git a/test/integration/targets/junos_lldp_interfaces/tasks/main.yaml b/test/integration/targets/junos_lldp_interfaces/tasks/main.yaml new file mode 100644 index 0000000000..cc27f174fd --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: netconf.yaml, tags: ['netconf'] } diff --git a/test/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml b/test/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml new file mode 100644 index 0000000000..73b91adfaa --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all netconf test cases + find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=netconf) + include: "{{ test_case_to_run }} ansible_connection=netconf" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 0000000000..3ab8d02f21 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,11 @@ +--- +- debug: + msg: "Start junos_lldp_interfaces deleted remove interface config ansible_connection={{ ansible_connection }}" + +- name: "Setup - remove lldp interfaces config" + junos_config: + lines: + - delete protocols lldp + +- debug: + msg: "End junos_lldp_interfaces deleted remove interface config ansible_connection={{ ansible_connection }}" diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 0000000000..0d12fceae2 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,87 @@ +--- +- debug: + msg: "START junos_lldp_interfaces deleted integration tests on connection={{ ansible_connection }}" + +- name: get supported protocols + junos_command: + commands: show lldp + register: result + ignore_errors: yes + +- name: lldp supported + set_fact: + lldp_supported: True + when: not result.failed + +- name: lldp not supported + set_fact: + lldp_supported: False + when: result.failed + +- block: + - include_tasks: _remove_config.yaml + + - set_fact: + expected_deleted_output: + - name: ge-0/0/1 + + - name: Configure initial state for lldp interfaces + junos_lldp_interfaces: &initial + config: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + state: merged + register: result + + - name: Delete the provided lldp interface configuration from running configuration + junos_lldp_interfaces: &deleted + config: + - name: ge-0/0/2 + state: deleted + register: result + + - name: Assert the configuration is reflected on host + assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after']) |length == 0 }}" + + - name: Delete the provided lldp interface configuration from running configuration (IDEMPOTENT) + junos_lldp_interfaces: *deleted + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + - name: Configure initial state for interface + junos_lldp_interfaces: *initial + register: result + + - name: Delete the all lldp interface configuration from running configuration + junos_lldp_interfaces: + state: deleted + register: result + + - name: Assert the configuration is reflected on host + assert: + that: + - "{{ result['after'] == []}}" + + - name: Delete the all lldp interface configuration from running configuration (IDEMPOTENT) + junos_lldp_interfaces: + state: deleted + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml + when: lldp_supported + +- debug: + msg: "END junos_lldp_interfaces deleted integration tests on connection={{ ansible_connection }}" diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml new file mode 100644 index 0000000000..cb04cfab63 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,58 @@ +--- +- debug: + msg: "START junos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}" + +- name: get supported protocols + junos_command: + commands: show lldp + register: result + ignore_errors: yes + +- name: lldp supported + set_fact: + lldp_supported: True + when: not result.failed + +- name: lldp not supported + set_fact: + lldp_supported: False + when: result.failed + +- block: + - include_tasks: _remove_config.yaml + + - set_fact: + expected_merged_output: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + + - name: Merge the provided configuration with the exisiting running configuration + junos_lldp_interfaces: &merged + config: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + state: merged + register: result + + - name: Assert the configuration is reflected on host + assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_lldp_interfaces: *merged + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml + when: lldp_supported + +- debug: + msg: "END junos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}" diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 0000000000..886612b3e0 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: "START junos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}" + +- name: get supported protocols + junos_command: + commands: show lldp + register: result + ignore_errors: yes + +- name: lldp supported + set_fact: + lldp_supported: True + when: not result.failed + +- name: lldp not supported + set_fact: + lldp_supported: False + when: result.failed + +- block: + - include_tasks: _remove_config.yaml + + - set_fact: + expected_overridden_output: + - name: ge-0/0/2 + + - name: Configure initial state for interface + junos_lldp_interfaces: + config: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + state: merged + register: result + + - name: Override the provided configuration with the exisiting running configuration + junos_lldp_interfaces: &overridden + config: + - name: ge-0/0/2 + state: overridden + register: result + + - name: Assert the configuration is reflected on host + assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after']) |length == 0 }}" + + - name: Override the provided configuration with the existing running configuration (IDEMPOTENT) + junos_lldp_interfaces: *overridden + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml + when: lldp_supported + +- debug: + msg: "END junos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}" diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 0000000000..248787a53b --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,66 @@ +--- +- debug: + msg: "START junos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}" + +- name: get supported protocols + junos_command: + commands: show lldp + register: result + ignore_errors: yes + +- name: lldp supported + set_fact: + lldp_supported: True + when: not result.failed + +- name: lldp not supported + set_fact: + lldp_supported: False + when: result.failed + +- block: + - include_tasks: _remove_config.yaml + + - set_fact: + expected_replaced_output: + - name: ge-0/0/1 + enable: False + - name: ge-0/0/2 + enable: False + + - name: Configure initial state for interface + junos_lldp_interfaces: + config: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + register: result + + - name: Replace the provided configuration with the exisiting running configuration + junos_lldp_interfaces: &replaced + config: + - name: ge-0/0/1 + enable: False + state: replaced + register: result + + - name: Assert the configuration is reflected on host + assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after']) |length == 0 }}" + + - name: Replace the provided configuration with the existing running configuration (IDEMPOTENT) + junos_lldp_interfaces: *replaced + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml + when: lldp_supported + +- debug: + msg: "END junos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}" diff --git a/test/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml b/test/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml new file mode 100644 index 0000000000..92425ddb20 --- /dev/null +++ b/test/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml @@ -0,0 +1,72 @@ +--- +- debug: + msg: "START junos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}" + +- name: get supported protocols + junos_command: + commands: show lldp + register: result + ignore_errors: yes + +- name: lldp supported + set_fact: + lldp_supported: True + when: not result.failed + +- name: lldp not supported + set_fact: + lldp_supported: False + when: result.failed + +- block: + - include_tasks: _remove_config.yaml + + - set_fact: + expected_revert_output: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + + - name: Apply the provided configuration (base config) + junos_lldp_interfaces: + config: + - name: ge-0/0/1 + - name: ge-0/0/2 + enable: False + state: merged + register: base_config + + - name: Gather interfaces facts + junos_facts: + gather_subset: + - default + gather_network_resources: + - lldp_interfaces + + - name: Apply the provided configuration (config to be reverted) + junos_lldp_interfaces: + config: + - name: ge-0/0/2 + state: overridden + register: result + + - name: Assert that changes were applied + assert: + that: "result['changed'] == true" + + - name: Revert back to base config using facts round trip + junos_lldp_interfaces: + config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" + state: replaced + register: revert + + - name: Assert that config was reverted + assert: + that: "{{ expected_revert_output | symmetric_difference(revert['after']) |length == 0 }}" + + always: + - include_tasks: _remove_config.yaml + when: lldp_supported + +- debug: + msg: "END junos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}" diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index c993fbcd4b..8f000c8f7f 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -4396,16 +4396,16 @@ lib/ansible/modules/network/junos/_junos_l3_interface.py validate-modules:E326 lib/ansible/modules/network/junos/_junos_l3_interface.py validate-modules:E337 lib/ansible/modules/network/junos/_junos_l3_interface.py validate-modules:E338 lib/ansible/modules/network/junos/_junos_l3_interface.py validate-modules:E340 +lib/ansible/modules/network/junos/_junos_lldp_interface.py validate-modules:E322 +lib/ansible/modules/network/junos/_junos_lldp_interface.py validate-modules:E324 +lib/ansible/modules/network/junos/_junos_lldp_interface.py validate-modules:E326 +lib/ansible/modules/network/junos/_junos_lldp_interface.py validate-modules:E338 lib/ansible/modules/network/junos/junos_lag_interfaces.py validate-modules:E338 lib/ansible/modules/network/junos/junos_lldp.py validate-modules:E322 lib/ansible/modules/network/junos/junos_lldp.py validate-modules:E324 lib/ansible/modules/network/junos/junos_lldp.py validate-modules:E326 lib/ansible/modules/network/junos/junos_lldp.py validate-modules:E337 lib/ansible/modules/network/junos/junos_lldp.py validate-modules:E338 -lib/ansible/modules/network/junos/junos_lldp_interface.py validate-modules:E322 -lib/ansible/modules/network/junos/junos_lldp_interface.py validate-modules:E324 -lib/ansible/modules/network/junos/junos_lldp_interface.py validate-modules:E326 -lib/ansible/modules/network/junos/junos_lldp_interface.py validate-modules:E338 lib/ansible/modules/network/junos/junos_logging.py validate-modules:E322 lib/ansible/modules/network/junos/junos_logging.py validate-modules:E324 lib/ansible/modules/network/junos/junos_logging.py validate-modules:E326 |