diff options
author | Matt Clay <mclay@redhat.com> | 2020-02-28 20:37:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 20:37:50 -0800 |
commit | 7c8b046b5fac7342fcf7882d4c84efc089e7866f (patch) | |
tree | 22c3b9ac4cb671951e7f20457269f63c1caf91f8 /test/integration/targets/incidental_consul/tasks/consul_session.yml | |
parent | 04666c9fa1eb2f367cf3b1c9c6853828bdcb813f (diff) | |
download | ansible-7c8b046b5fac7342fcf7882d4c84efc089e7866f.tar.gz |
Fourth batch of incidental integration tests. (#67873)
* Copy in incidental posix tests.
* Update incidental test aliases.
* Update target names.
* Add support plugins.
* Fix paths.
* Update ignores.
* Update integration-aliases sanity test.
* Add incidental tests to CI.
Diffstat (limited to 'test/integration/targets/incidental_consul/tasks/consul_session.yml')
-rw-r--r-- | test/integration/targets/incidental_consul/tasks/consul_session.yml | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_consul/tasks/consul_session.yml b/test/integration/targets/incidental_consul/tasks/consul_session.yml new file mode 100644 index 0000000000..a5490ec6c2 --- /dev/null +++ b/test/integration/targets/incidental_consul/tasks/consul_session.yml @@ -0,0 +1,162 @@ +- name: list sessions + consul_session: + state: list + register: result + +- assert: + that: + - result is changed + - "'sessions' in result" + +- name: create a session + consul_session: + state: present + name: testsession + register: result + +- assert: + that: + - result is changed + - result['name'] == 'testsession' + - "'session_id' in result" + +- set_fact: + session_id: "{{ result['session_id'] }}" + +- name: list sessions after creation + consul_session: + state: list + register: result + +- set_fact: + session_count: "{{ result['sessions'] | length }}" + +- assert: + that: + - result is changed + # selectattr not available on Jinja 2.2 provided by CentOS 6 + # hence the two following tasks (set_fact/assert) are used + # - (result['sessions'] | selectattr('ID', 'match', '^' ~ session_id ~ '$') | first)['Name'] == 'testsession' + +- name: search created session + set_fact: + test_session_found: True + loop: "{{ result['sessions'] }}" + when: "item.get('ID') == session_id and item.get('Name') == 'testsession'" + +- name: ensure session was created + assert: + that: + - test_session_found|default(False) + +- name: fetch info about a session + consul_session: + state: info + id: '{{ session_id }}' + register: result + +- assert: + that: + - result is changed + +- name: ensure 'id' parameter is required when state=info + consul_session: + state: info + name: test + register: result + ignore_errors: True + +- assert: + that: + - result is failed + +- name: ensure unknown scheme fails + consul_session: + state: info + id: '{{ session_id }}' + scheme: non_existent + register: result + ignore_errors: True + +- assert: + that: + - result is failed + +- when: pyopenssl_version.stdout is version('0.15', '>=') + block: + - name: ensure SSL certificate is checked + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + register: result + ignore_errors: True + + - name: previous task should fail since certificate is not known + assert: + that: + - result is failed + - "'certificate verify failed' in result.msg" + + - name: ensure SSL certificate isn't checked when validate_certs is disabled + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + validate_certs: False + register: result + + - name: previous task should succeed since certificate isn't checked + assert: + that: + - result is changed + + - name: ensure a secure connection is possible + consul_session: + state: info + id: '{{ session_id }}' + port: 8501 + scheme: https + environment: + REQUESTS_CA_BUNDLE: '{{ remote_dir }}/cert.pem' + register: result + + - assert: + that: + - result is changed + +- name: delete a session + consul_session: + state: absent + id: '{{ session_id }}' + register: result + +- assert: + that: + - result is changed + +- name: list sessions after deletion + consul_session: + state: list + register: result + +- assert: + that: + - result is changed + # selectattr and equalto not available on Jinja 2.2 provided by CentOS 6 + # hence the two following tasks (command/assert) are used + # - (result['sessions'] | selectattr('ID', 'equalto', session_id) | list | length) == 0 + +- name: search deleted session + command: echo 'session found' + loop: "{{ result['sessions'] }}" + when: "item.get('ID') == session_id and item.get('Name') == 'testsession'" + register: search_deleted + +- name: ensure session was deleted + assert: + that: + - search_deleted is skipped # each iteration is skipped + - search_deleted is not changed # and then unchanged |