ansible/test/integration/targets/postgresql/tasks/postgresql_set.yml
Andrey Klychkov cf5aceb482 New module postgresql_set - Change a PostgreSQL server configuration parameter (#51875)
* New module postgresql_set - Change a PostgreSQL server configuration parameter

* New module postgresql_set - fix

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* New module postgresql_set - fix tests

* Various cosmetic and docs changes

* New module postgresql_set - add returned value

* New module postgresql_set - add returned value

* New module postgresql_set - add check mode

* New module postgresql_set - fix comment

* New module postgresql_set - added CI tests for check_mode

* New module postgresql_set - added aliases, fix typos

* New module postgresql_set - fix

* New module postgresql_set - fix sanity

* New module postgresql_set - fixes

* New module postgresql_set - fixes

* New module postgresql_set - fixes
2019-03-18 11:39:10 +00:00

232 lines
6.6 KiB
YAML

# Test code for the postgresql_set module
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Notice: assertions are different for Ubuntu 16.04 and FreeBSD because they don't work
# correctly for these tests. There are some stranges exactly in Shippable CI.
# However I checked it manually for all points and it worked as expected.
- name: postgresql_set - preparation to the next step
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
reset: yes
ignore_errors: yes
- name: postgresql_set - set work_mem (restart is not required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
value: 12MB
register: set_wm
ignore_errors: yes
- assert:
that:
- set_wm.name == 'work_mem'
- set_wm.changed == true
- set_wm.value_pretty == '12MB'
- set_wm.value_pretty != set_wm.prev_val_pretty
- set_wm.restart_required == false
- set_wm.value.value == 12582912
- set_wm.value.unit == 'b'
when: ansible_distribution != "Ubuntu" and ansible_distribution_major_version != '16' and ansible_distribution != "FreeBSD"
- assert:
that:
- set_wm.name == 'work_mem'
- set_wm.changed == true
- set_wm.restart_required == false
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == '16'
- name: postgresql_set - reset work_mem (restart is not required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
reset: yes
register: reset_wm
ignore_errors: yes
- assert:
that:
- reset_wm.name == 'work_mem'
- reset_wm.changed == true
- reset_wm.value_pretty != reset_wm.prev_val_pretty
- reset_wm.restart_required == false
- reset_wm.value.value != '12582912'
when: ansible_distribution != "Ubuntu" and ansible_distribution_major_version != '16' and ansible_distribution != "FreeBSD"
- assert:
that:
- reset_wm.name == 'work_mem'
- reset_wm.changed == true
- reset_wm.restart_required == false
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == '16'
- name: postgresql_set - reset work_mem again to check that nothing changed (restart is not required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
reset: yes
register: reset_wm2
ignore_errors: yes
- assert:
that:
- reset_wm2.name == 'work_mem'
- reset_wm2.changed == false
- reset_wm2.value_pretty == reset_wm2.prev_val_pretty
- reset_wm2.restart_required == false
when: ansible_distribution != "Ubuntu" and ansible_distribution_major_version != '16'
- assert:
that:
- reset_wm2.name == 'work_mem'
- reset_wm2.changed == false
- reset_wm2.restart_required == false
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == '16'
- name: postgresql_set - preparation to the next step
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
value: 14MB
ignore_errors: yes
- name: postgresql_set - set work_mem to initial state (restart is not required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: work_mem
value: default
register: def_wm
ignore_errors: yes
- assert:
that:
- def_wm.name == 'work_mem'
- def_wm.changed == true
- def_wm.value_pretty != def_wm.prev_val_pretty
- def_wm.restart_required == false
- def_wm.value.value != '14680064'
when: ansible_distribution != "Ubuntu" and ansible_distribution_major_version != '16' and ansible_distribution != 'FreeBSD'
- assert:
that:
- def_wm.name == 'work_mem'
- def_wm.changed == true
- def_wm.restart_required == false
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == '16' and ansible_distribution != 'FreeBSD'
- name: postgresql_set - set shared_buffers (restart is required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: shared_buffers
value: 111MB
register: set_shb
ignore_errors: yes
- assert:
that:
- set_shb.name == 'shared_buffers'
- set_shb.changed == true
- set_shb.restart_required == true
# We don't check value.utin because it is none
- name: postgresql_set - set autovacuum (enabled by default, restart is not required)
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: autovacuum
value: off
register: set_aut
ignore_errors: yes
- assert:
that:
- set_aut.name == 'autovacuum'
- set_aut.changed == true
- set_aut.restart_required == false
- set_aut.value.value == 'off'
# Test check_mode, step 1. At the previous test we set autovacuum = 'off'
- name: postgresql - try to change autovacuum again in check_mode
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: autovacuum
value: on
register: set_aut
ignore_errors: yes
check_mode: yes
- assert:
that:
- set_aut.name == 'autovacuum'
- set_aut.changed == true
- set_aut.restart_required == false
- set_aut.value.value == 'off'
# Test check_mode, step 2
- name: postgresql - check that autovacuum wasn't actually changed after change in check_mode
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: autovacuum
value: off
register: set_aut
ignore_errors: yes
check_mode: yes
- assert:
that:
- set_aut.name == 'autovacuum'
- set_aut.changed == false
- set_aut.restart_required == false
- set_aut.value.value == 'off'
# Test check_mode, step 3. It is different from the prev test - it runs without check_mode: yes
# Before the check_mode tests autovacuum was off
- name: postgresql - check that autovacuum wasn't actually changed after change in check_mode
become_user: "{{ pg_user }}"
become: yes
postgresql_set:
db: postgres
login_user: "{{ pg_user }}"
name: autovacuum
value: off
register: set_aut
ignore_errors: yes
- assert:
that:
- set_aut.name == 'autovacuum'
- set_aut.changed == false
- set_aut.restart_required == false
- set_aut.value.value == 'off'