diff options
author | ansible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com> | 2020-05-08 21:04:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-08 21:04:05 +0000 |
commit | 790f63be8a22e6f95eddc2c23bf7a0945f48f2bb (patch) | |
tree | 27929c7452cce28f82193ae9cd9189c76699904c /tests | |
parent | 07a53b4407c46dc19cdbde092fbf96970bb61306 (diff) | |
parent | bd128df488162da0691596560ce9b395d707a503 (diff) | |
download | vyos-ansible-collection-790f63be8a22e6f95eddc2c23bf7a0945f48f2bb.tar.gz vyos-ansible-collection-790f63be8a22e6f95eddc2c23bf7a0945f48f2bb.zip |
Merge pull request #28 from rohitthakur2590/lldp_interfaces_states_added
[VyOS] LLDP interfaces resource module updated with new states
Reviewed-by: Sumit Jaiswal <sjaiswal@redhat.com>
https://github.com/justjais
Diffstat (limited to 'tests')
6 files changed, 133 insertions, 4 deletions
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 0000000..40c96c4 --- /dev/null +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,6 @@ +set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +set service lldp interface eth1 location civic-based country-code 'US' +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 latitude '33.524449N' +set service lldp interface eth2 location coordinate-based longitude '222.267255W'
\ No newline at end of file diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml index a5ff0a8..4ef40c9 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml @@ -35,3 +35,26 @@ - assert: that: - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml new file mode 100644 index 0000000..180b62f --- /dev/null +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml @@ -0,0 +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: + 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 new file mode 100644 index 0000000..0ca52be --- /dev/null +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- 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 new file mode 100644 index 0000000..342e64b --- /dev/null +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,37 @@ +--- +- debug: + msg: START vyos_lldp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.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 3cb684e..092f653 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml @@ -9,10 +9,6 @@ merged: - 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 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 @@ -44,6 +40,16 @@ populate: 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 @@ -91,6 +97,22 @@ overridden: - 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 |