diff options
Diffstat (limited to 'tests/integration/targets/vyos_ntp_global')
6 files changed, 40 insertions, 42 deletions
diff --git a/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml index 4147e6d..0ed3e42 100644 --- a/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml +++ b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml @@ -9,7 +9,7 @@ - name: Set test_items ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" + test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}" - name: Run test case (connection=httpapi) ansible.builtin.include_tasks: "{{ test_case_to_run }}" diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml index 957e119..d831f18 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml @@ -3,9 +3,9 @@ msg: START vyos_ntp_global deleted integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - - block: + - include_tasks: _populate_config.yaml + - name: Delete all NTP configuration register: result vyos.rest.vyos_ntp_global: &id001 @@ -20,7 +20,7 @@ that: - result.after.allow_clients == [] - result.after.listen_addresses == [] - - result.after.servers == {} + - result.after.servers == [] - name: Delete the existing configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml index 73ee1ff..61a7d3d 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml @@ -3,9 +3,9 @@ msg: START vyos_ntp_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - - block: + - include_tasks: _populate_config.yaml + - name: Gather NTP configuration register: result vyos.rest.vyos_ntp_global: @@ -16,8 +16,8 @@ - result.changed == false - "'10.4.9.0/24' in result.gathered.allow_clients" - "'10.1.9.16' in result.gathered.listen_addresses" - - "'10.3.6.5' in result.gathered.servers" - - "'server4.example.com' in result.gathered.servers" + - "'10.3.6.5' in result.gathered.servers | map(attribute='server')" + - "'server4.example.com' in result.gathered.servers | map(attribute='server')" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml index deee2c0..a405b81 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml @@ -3,9 +3,9 @@ msg: START vyos_ntp_global overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - - block: + - include_tasks: _populate_config.yaml + - name: Override the existing configuration with the provided configuration register: result vyos.rest.vyos_ntp_global: &id001 diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml index 77136fc..cd21412 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml @@ -3,9 +3,9 @@ msg: START vyos_ntp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml -- include_tasks: _populate_config.yaml - - block: + - include_tasks: _populate_config.yaml + - name: Replace the existing configuration with the provided configuration register: result vyos.rest.vyos_ntp_global: &id001 @@ -31,8 +31,8 @@ that: - "'10.4.9.0/24' not in gathered.gathered.allow_clients" - "'10.99.99.0/24' in gathered.gathered.allow_clients" - - "'server-new.example.com' in gathered.gathered.servers" - - "'10.3.6.5' not in gathered.gathered.servers" + - "'server-new.example.com' in gathered.gathered.servers | map(attribute='server')" + - "'10.3.6.5' not in gathered.gathered.servers | map(attribute='server')" - name: Replace the provided configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml index d05e203..41daa42 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml @@ -8,58 +8,56 @@ - name: RTT - Apply base configuration vyos.rest.vyos_ntp_global: config: + allow_clients: + - 10.5.5.0/24 + - 10.6.6.0/24 + listen_addresses: + - 10.1.2.3 servers: - - server: 10.3.6.5 + - server: 203.0.113.10 options: - - noselect - prefer - - server: server4.example.com - options: - - pool - allow_clients: - - 10.4.9.0/24 - listen_addresses: - - 10.1.9.16 state: merged - - name: RTT - Gather configuration + - name: RTT - Gather register: gathered vyos.rest.vyos_ntp_global: state: gathered - - name: RTT - Assert gathered matches applied + - name: RTT - Assert base configuration present assert: that: - - "'10.3.6.5' in gathered.gathered.servers" - - "'10.4.9.0/24' in gathered.gathered.allow_clients" - - "'10.1.9.16' in gathered.gathered.listen_addresses" + - "'10.5.5.0/24' in gathered.gathered.allow_clients" + - "'10.6.6.0/24' in gathered.gathered.allow_clients" + - "'10.1.2.3' in gathered.gathered.listen_addresses" + - "'203.0.113.10' in gathered.gathered.servers | map(attribute='server')" + - (gathered.gathered.servers | selectattr('server', 'eq', '203.0.113.10') | first).options == ['prefer'] - - name: RTT - Modify configuration + - name: RTT - Modify configuration (remove a stale allow_client, add a server option) vyos.rest.vyos_ntp_global: config: - servers: - - server: 10.3.6.5 - options: - - noselect - - server: server5.example.com allow_clients: - - 10.4.8.0/24 + - 10.5.5.0/24 listen_addresses: - - 10.1.9.16 + - 10.1.2.3 + servers: + - server: 203.0.113.10 + options: + - prefer + - nts state: replaced - - name: RTT - Gather modified configuration + - name: RTT - Gather after modify register: gathered2 vyos.rest.vyos_ntp_global: state: gathered - - name: RTT - Assert modification applied correctly + - name: RTT - Assert stale entry removed and update applied assert: that: - - "'server5.example.com' in gathered2.gathered.servers" - - "'server4.example.com' not in gathered2.gathered.servers" - - "'10.4.8.0/24' in gathered2.gathered.allow_clients" - - "'10.4.9.0/24' not in gathered2.gathered.allow_clients" + - "'10.5.5.0/24' in gathered2.gathered.allow_clients" + - "'10.6.6.0/24' not in gathered2.gathered.allow_clients" + - (gathered2.gathered.servers | selectattr('server', 'eq', '203.0.113.10') | first).options | sort == ['nts', 'prefer'] always: - include_tasks: _remove_config.yaml |
