diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml index 30b804a..180b62f 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml @@ -1,25 +1,25 @@ --- - debug: msg: START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Gather the provided configuration with the exisiting running configuration register: result - vyos.vyos.vyos_lldp_interfaces: &id001 + vyos.vyos.vyos_lldp_interfaces: config: state: gathered - name: Assert that gathered dicts was correctly generated assert: that: - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ \ }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml index c549ce7..0ca52be 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml @@ -1,33 +1,16 @@ --- - debug: - msg: START vyos_lldp_interfaces parsed integration tests on connection={{ ansible_connection + msg: START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection }} -- include_tasks: _remove_config.yaml - -- include_tasks: _populate.yaml - -- block: - - - name: Gather lldp_interfaces facts - register: lldp_interfaces_facts - vyos.vyos.vyos_facts: - gather_subset: - - default - gather_network_resources: - - lldp_interfaces - - - name: Provide the running configuration for parsing (config to be parsed) - register: result - vyos.vyos.vyos_lldp_interfaces: - running_config: "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['lldp_interfaces'] | symmetric_difference(result['parsed'])\ - \ |length == 0 }}" - - always: - - - include_tasks: _remove_config.yaml +- name: Parse externally provided interfaces config to agnostic model + register: result + vyos.vyos.vyos_lldp_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml index d69e1c5..342e64b 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml @@ -1,39 +1,37 @@ --- - debug: msg: START vyos_lldp_interfaces 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 register: result vyos.vyos.vyos_lldp_interfaces: config: - name: eth1 location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH - name: eth2 location: coordinate_based: altitude: 2200 datum: WGS84 longitude: 222.267255W latitude: 33.524449N state: rendered - name: Assert that correct set of commands were generated assert: that: - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ \ |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml index 506bdf7..092f653 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml @@ -1,120 +1,136 @@ --- merged: before: [] commands: - set service lldp interface eth1 location civic-based country-code 'US' - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' - set service lldp interface eth1 - set service lldp interface eth2 location coordinate-based latitude '33.524449N' - set service lldp interface eth2 location coordinate-based altitude '2200' - set service lldp interface eth2 location coordinate-based datum 'WGS84' - set service lldp interface eth2 location coordinate-based longitude '222.267255W' - set service lldp interface eth2 after: - name: eth1 location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH - name: eth2 location: coordinate_based: altitude: 2200 datum: WGS84 longitude: 222.267255W latitude: 33.524449N populate: - name: eth1 location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH - name: eth2 location: coordinate_based: altitude: 2200 datum: WGS84 longitude: 222.267255W latitude: 33.524449N rendered: commands: - set service lldp interface eth1 location civic-based country-code 'US' - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' - set service lldp interface eth1 - set service lldp interface eth2 location coordinate-based latitude '33.524449N' - set service lldp interface eth2 location coordinate-based altitude '2200' - set service lldp interface eth2 location coordinate-based datum 'WGS84' - set service lldp interface eth2 location coordinate-based longitude '222.267255W' - set service lldp interface eth2 replaced: commands: - delete service lldp interface eth2 location - set service lldp interface eth2 'disable' - set service lldp interface eth2 location civic-based country-code 'US' - set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' - delete service lldp interface eth1 location - set service lldp interface eth1 'disable' - set service lldp interface eth1 location coordinate-based latitude '33.524449N' - set service lldp interface eth1 location coordinate-based altitude '2200' - set service lldp interface eth1 location coordinate-based datum 'WGS84' - set service lldp interface eth1 location coordinate-based longitude '222.267255W' after: - name: eth2 enable: false location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH - name: eth1 enable: false location: coordinate_based: altitude: 2200 datum: WGS84 longitude: 222.267255W latitude: 33.524449N populate_intf: - name: eth2 enable: false location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH overridden: commands: - delete service lldp interface eth2 location - delete service lldp interface eth2 'disable' - set service lldp interface eth2 location elin '0000000911' after: - name: eth2 location: elin: 0000000911 +parsed: + after: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N deleted: commands: - delete service lldp interface eth1 - delete service lldp interface eth2 after: [] round_trip: after: - name: eth1 location: civic_based: country_code: US ca_info: - ca_type: 0 ca_value: ENGLISH - name: eth2 location: coordinate_based: altitude: 2200 datum: WGS84 longitude: 222.267255W latitude: 33.524449N