diff options
author | CaptTrews <capttrews@gmail.com> | 2020-01-16 15:50:24 +0000 |
---|---|---|
committer | CaptTrews <capttrews@gmail.com> | 2020-01-16 15:50:24 +0000 |
commit | 6b6166151faa3d811ae0ec3010a89e518a26287b (patch) | |
tree | 9cf59872c2ddc7e99595db4f47c72a7ce08b6c10 /tests/integration/targets/vyos_lldp_global | |
parent | d31b74ba6c74a6e3cdebd80b9eb5272aeb9b0fb4 (diff) | |
download | vyos-ansible-old-6b6166151faa3d811ae0ec3010a89e518a26287b.tar.gz vyos-ansible-old-6b6166151faa3d811ae0ec3010a89e518a26287b.zip |
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
Diffstat (limited to 'tests/integration/targets/vyos_lldp_global')
11 files changed, 99 insertions, 95 deletions
diff --git a/tests/integration/targets/vyos_lldp_global/defaults/main.yaml b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml index 164afea..852a6be 100644 --- a/tests/integration/targets/vyos_lldp_global/defaults/main.yaml +++ b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml @@ -1,3 +1,3 @@ --- -testcase: "[^_].*" +testcase: '[^_].*' test_items: [] diff --git a/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml b/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml index 655e51e..93eb2fe 100644 --- a/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml +++ b/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml @@ -1,8 +1,8 @@ --- - name: Collect all cli test cases find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' use_regex: true register: test_cases delegate_to: localhost @@ -10,10 +10,10 @@ - name: Set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: Run test case (connection=network_cli) - include: "{{ test_case_to_run }}" +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' loop_control: loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_lldp_global/tasks/main.yaml b/tests/integration/targets/vyos_lldp_global/tasks/main.yaml index d4cf26f..a3db933 100644 --- a/tests/integration/targets/vyos_lldp_global/tasks/main.yaml +++ b/tests/integration/targets/vyos_lldp_global/tasks/main.yaml @@ -1,2 +1,4 @@ --- -- {include: cli.yaml, tags: ['cli']} +- include: cli.yaml + tags: + - cli diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml index 088aa7b..e439242 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml @@ -1,9 +1,7 @@ --- - name: Setup - network.cli.cli_config: - config: "{{ lines }}" vars: - lines: | - set service lldp - set service lldp legacy-protocols 'cdp' - set service lldp management-address '192.0.2.17' + lines: "set service lldp\nset service lldp legacy-protocols 'cdp'\nset service\ + \ lldp management-address '192.0.2.17'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml index b000a94..b823449 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml @@ -1,9 +1,7 @@ --- - name: Remove Config - network.cli.cli_config: - config: "{{ lines }}" vars: - lines: | - delete service lldp legacy-protocols - delete service lldp management-address - delete service lldp + lines: "delete service lldp legacy-protocols\ndelete service lldp management-address\n\ + delete service lldp\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml index 8017e93..f4c6cbc 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml @@ -1,15 +1,17 @@ --- - debug: - msg: "Start vyos_lldp_global deleted integration tests ansible_connection={{ ansible_connection }}" + msg: Start vyos_lldp_global deleted integration tests ansible_connection={{ + ansible_connection }} - include_tasks: _populate.yaml - block: + - name: Delete attributes of LLDP service. - vyos.vyos.vyos_lldp_global: &deleted + register: result + vyos.vyos.vyos_lldp_global: &id001 config: state: deleted - register: result - name: Assert that the before dicts were correctly generated assert: @@ -19,7 +21,8 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" - name: Assert that the after dicts were correctly generated assert: @@ -27,18 +30,18 @@ - "{{ deleted['after'] == result['after']}}" - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos.vyos.vyos_lldp_global: *deleted register: result + vyos.vyos.vyos_lldp_global: *id001 - name: Assert that the previous task was idempotent assert: that: - - "result.changed == false" + - result.changed == false - name: Assert that the before dicts were correctly generated assert: that: - "{{ deleted['after'] == result['before'] }}" - always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml index 05609b6..a197c45 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml @@ -1,24 +1,25 @@ --- - debug: - msg: "START vyos_lldp_global empty_config integration tests on connection={{ ansible_connection }}" + msg: START vyos_lldp_global empty_config integration tests on connection={{ + ansible_connection }} - name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true vyos.vyos.vyos_lldp_global: config: state: merged - register: result - ignore_errors: 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 vyos.vyos.vyos_lldp_global: config: state: replaced - register: result - ignore_errors: true - assert: that: diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml index a17bd61..aeabc9f 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml @@ -1,21 +1,23 @@ --- - debug: - msg: "START vyos_lldp_global merged integration tests on connection={{ ansible_connection }}" + msg: START vyos_lldp_global merged integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: + - name: Merge the provided configuration with the exisiting running configuration - vyos.vyos.vyos_lldp_global: &merged + register: result + vyos.vyos.vyos_lldp_global: &id001 config: legacy_protocols: - - 'fdp' - - 'cdp' + - fdp + - cdp address: 192.0.2.11 state: merged - register: result - name: Assert that before dicts were correctly generated assert: @@ -24,26 +26,28 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos.vyos.vyos_lldp_global: *merged + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) register: result + vyos.vyos.vyos_lldp_global: *id001 - name: Assert that the previous task was idempotent assert: that: - - "result['changed'] == false" + - result['changed'] == false - name: Assert that before dicts were correctly generated assert: that: - "{{ merged['after'] == result['before'] }}" - always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml index 371e7f3..9a833f5 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml @@ -1,27 +1,30 @@ --- - debug: - msg: "START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}" + msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: + - name: Replace device configurations of LLDP service with provided configurations - vyos.vyos.vyos_lldp_global: &replaced + register: result + vyos.vyos.vyos_lldp_global: &id001 config: legacy_protocols: - - 'edp' - - 'sonmp' - - 'cdp' + - edp + - sonmp + - cdp address: 192.0.2.14 state: replaced - register: result - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -33,19 +36,20 @@ that: - "{{ replaced['after'] == result['after'] }}" - - name: Replace device configurations of LLDP service with provided configurarions (IDEMPOTENT) - vyos.vyos.vyos_lldp_global: *replaced + - name: Replace device configurations of LLDP service with provided configurarions + (IDEMPOTENT) register: result + vyos.vyos.vyos_lldp_global: *id001 - name: Assert that task was idempotent assert: that: - - "result['changed'] == false" + - result['changed'] == false - name: Assert that before dict is correctly generated assert: that: - "{{ replaced['after'] == result['before'] }}" - always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml index 02902bc..2e8284f 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml @@ -1,19 +1,21 @@ --- - debug: - msg: "START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }}" + msg: START vyos_lldp_global round trip integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - block: + - name: Apply the provided configuration (base config) + register: base_config vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - 'fdp' - - 'cdp' + - fdp + - cdp address: 192.0.2.11 state: merged - register: base_config - name: Gather vyos_lldp_global facts vyos.vyos.vyos_facts: @@ -23,29 +25,29 @@ - lldp_global - name: Apply the provided configuration (config to be reverted) + register: result vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - 'edp' - - 'sonmp' - - 'cdp' + - edp + - sonmp + - cdp address: 192.0.2.14 state: merged - register: result - name: Assert that changes were applied assert: that: "{{ round_trip['after'] == result['after'] }}" - name: Revert back to base config using facts round trip + register: revert vyos.vyos.vyos_lldp_global: config: "{{ ansible_facts['network_resources']['lldp_global'] }}" state: replaced - register: revert - name: Assert that config was reverted assert: that: "{{ base_config['after'] == revert['after'] }}" - always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_global/vars/main.yaml b/tests/integration/targets/vyos_lldp_global/vars/main.yaml index 420b2b4..81e71be 100644 --- a/tests/integration/targets/vyos_lldp_global/vars/main.yaml +++ b/tests/integration/targets/vyos_lldp_global/vars/main.yaml @@ -1,56 +1,48 @@ --- merged: before: - address: '192.0.2.17' + address: 192.0.2.17 enable: true legacy_protocols: - - 'cdp' - + - cdp commands: - - "set service lldp management-address '192.0.2.11'" - - "set service lldp legacy-protocols 'fdp'" - + - set service lldp management-address '192.0.2.11' + - set service lldp legacy-protocols 'fdp' after: - address: '192.0.2.11' + address: 192.0.2.11 enable: true legacy_protocols: - - 'cdp' - - 'fdp' - + - cdp + - fdp populate: - address: '192.0.2.17' + address: 192.0.2.17 enable: true legacy_protocols: - - 'cdp' - + - cdp replaced: commands: - - "set service lldp legacy-protocols 'edp'" - - "set service lldp legacy-protocols 'sonmp'" - - "set service lldp management-address '192.0.2.14'" - + - set service lldp legacy-protocols 'edp' + - set service lldp legacy-protocols 'sonmp' + - set service lldp management-address '192.0.2.14' after: - address: '192.0.2.14' + address: 192.0.2.14 enable: true legacy_protocols: - - 'cdp' - - 'edp' - - 'sonmp' - + - cdp + - edp + - sonmp deleted: commands: - - "delete service lldp management-address" - - "delete service lldp legacy-protocols" - + - delete service lldp management-address + - delete service lldp legacy-protocols after: - "enable": true - + enable: true round_trip: after: - address: '192.0.2.14' + address: 192.0.2.14 enable: true legacy_protocols: - - 'cdp' - - 'edp' - - 'fdp' - - 'sonmp' + - cdp + - edp + - fdp + - sonmp |