diff --git a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml index c9efc7e9..5be79118 100644 --- a/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml +++ b/roles/execute_binary_upgrade/tasks/upgrade_standbys_link_Debian.yml @@ -196,9 +196,9 @@ when: - "'standby' in group_names" -- name: Remove /tmp/pgupgrade +- name: Remove /tmp/pgupgrade and sudoers file ansible.builtin.file: - path: /tmp/pgupgrade + path: "{{ item }}" state: absent become: true loop: @@ -207,6 +207,12 @@ when: - "'standby' in group_names" +- name: Force systemd to reread sudoers.d config file + ansible.builtin.systemd: + daemon_reload: true + when: + - "'standby' in group_names" + - name: Enable and start systemd service on standby's ansible.builtin.systemd: name: "{{ new_pg_service }}" diff --git a/tests/cases/execute_binary_upgrade/vars.json b/tests/cases/execute_binary_upgrade/vars.json index 31800240..e65784ec 100644 --- a/tests/cases/execute_binary_upgrade/vars.json +++ b/tests/cases/execute_binary_upgrade/vars.json @@ -1,5 +1,7 @@ { "use_hostname": false, "pg_ssl": false, - "use_link_method": true + "use_link_method": true, + "old_pg_version": 13, + "new_pg_version": 15 } \ No newline at end of file diff --git a/tests/tests/test_execute_binary_upgrade.py b/tests/tests/test_execute_binary_upgrade.py index e69de29b..04948c81 100644 --- a/tests/tests/test_execute_binary_upgrade.py +++ b/tests/tests/test_execute_binary_upgrade.py @@ -0,0 +1,54 @@ +import pytest + +from conftest import ( + load_ansible_vars, + get_hosts, + os_family, + get_pg_type, + get_primary, + get_standbys, +) + + +def test_configuration_files(): + ansible_vars = load_ansible_vars() + + new_pg_version = ansible_vars['new_pg_version'] + + if os_family() == 'RedHat': + new_pg_config_file = '/var/lib/pgsql/%s/main/data/postgresql.conf' % new_pg_version + if get_pg_type() == 'EPAS': + new_pg_config_file = '/var/lib/edb/as%s/main/data/postgresql.conf' % new_pg_version + elif os_family() == 'Debian': + new_pg_config_file = '/etc/postgresql/%s/main/postgresql.conf' % new_pg_version + if get_pg_type() == 'EPAS': + new_pg_config_file = '/etc/edb-as/%s/main/postgresql.conf' % new_pg_version + + host = get_primary() + + assert host.file(new_pg_config_file).exists, \ + "New cluster configuration files were not properly created." + + +def test_new_pg_service(): + ansible_vars = load_ansible_vars() + + new_pg_version = ansible_vars['new_pg_version'] + + if get_pg_type() == 'EPAS': + if os_family() == 'RedHat': + service = 'edb-as-%s' % new_pg_version + elif os_family() == 'Debian': + service = 'edb-as@%s-main' % new_pg_version + elif get_pg_type() == 'PG': + if os_family() == 'RedHat': + service = 'postgresql-%s' % new_pg_version + elif os_family() == 'Debian': + service = 'postgresql@%s' % new_pg_version + + host = get_primary() + + assert host.service(service).is_running, \ + "new postgres service not running" + +