generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests_versions.yml which will install/remove/confirm all supported versions. Signed-off-by: Rich Megginson <[email protected]>
- Loading branch information
Showing
5 changed files
with
169 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Test default settings | ||
block: | ||
- name: Run postgresql role | ||
include_role: | ||
name: linux-system-roles.postgresql | ||
public: true | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers | ||
|
||
- name: Test - postgresql-server running | ||
# noqa command-instead-of-module | ||
command: systemctl is-active postgresql | ||
changed_when: false | ||
|
||
- name: Test - postgresql-server is enabled | ||
# noqa command-instead-of-module | ||
command: systemctl is-enabled postgresql | ||
changed_when: false | ||
|
||
- name: Test - database is accessible for super user using Unix socket | ||
become: true | ||
become_user: postgres | ||
shell: | | ||
set -euo pipefail | ||
echo '\q' | psql | ||
async: 3 # in case of password prompt we need to fail | ||
changed_when: false | ||
when: __test_check_unix_socket | d(true) | ||
|
||
- name: Check - server tuning is used - shared buffers | ||
become: true | ||
become_user: postgres | ||
shell: | | ||
set -euo pipefail | ||
echo "SHOW shared_buffers;" | psql | ||
register: result | ||
changed_when: false | ||
when: __test_check_unix_socket | d(true) | ||
|
||
- name: Test - server tuning is used - shared buffers | ||
assert: | ||
that: > | ||
(ansible_memory_mb.real.total/4) | int | abs | string | ||
in result.stdout | ||
when: __test_check_unix_socket | d(true) | ||
|
||
- name: Check - server tuning is used - effective cache size | ||
become: true | ||
become_user: postgres | ||
shell: | | ||
set -euo pipefail | ||
echo "SHOW effective_cache_size;" | psql | ||
register: result | ||
changed_when: false | ||
when: __test_check_unix_socket | d(true) | ||
|
||
- name: Test - server tuning is used - effective cache size | ||
assert: | ||
that: > | ||
(ansible_memory_mb.real.total/2) | int | abs | string | ||
in result.stdout | ||
when: __test_check_unix_socket | d(true) | ||
|
||
- name: Check postgresql version matches postgresql_version | ||
command: postgres --version | ||
when: __test_check_version | d(false) | ||
register: __version | ||
changed_when: false | ||
failed_when: not __version.stdout is | ||
search(" " ~ postgresql_version ~ "[^0-9]") | ||
|
||
always: | ||
- name: Clean up | ||
include_tasks: clean_instance.yml | ||
when: __test_clean_instance | d(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Test installing and uninstalling all supported versions | ||
hosts: all | ||
tasks: | ||
- name: Skip test if distro does not support multiple versions | ||
meta: end_host | ||
when: ansible_facts['distribution'] not in ['CentOS', 'RedHat'] or | ||
ansible_facts['distribution_major_version'] not in ["8", "9"] | ||
|
||
- name: Install and cleanup default version | ||
include_tasks: tasks/install_and_check.yml | ||
vars: | ||
__test_check_version: true | ||
|
||
- name: Save default postgresql_version | ||
set_fact: | ||
__default_version: "{{ postgresql_version }}" | ||
|
||
- name: Install and cleanup the other supported versions | ||
include_tasks: tasks/install_and_check.yml | ||
loop: "{{ __versions }}" | ||
when: item != __default_version # we already installed it | ||
vars: | ||
__test_check_version: true | ||
postgresql_version: "{{ item }}" | ||
__versions: "{{ __postgresql_versions_el8 | ||
if ansible_facts['distribution_major_version'] == '8' | ||
else __postgresql_versions_el9 | ||
if ansible_facts['distribution_major_version'] == '9' | ||
else [] }}" |