diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 81172b94e..c73a5fc13 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,7 +4,7 @@ gather_facts: true tasks: - - name: Set variables for Patroni cluster deployment test + - name: Set variables for PostgreSQL Cluster deployment test ansible.builtin.set_fact: firewall_enabled_at_boot: false firewall_enable_ipv6: false # Added to prevent test failures in CI. @@ -30,6 +30,10 @@ - not (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '<')) - not (ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '>')) # TODO Debian 12 + - name: Set variables for PostgreSQL Cluster update test + ansible.builtin.set_fact: + target: system # includes updates to Postgres, Patroni, and all system packages + - name: Clean yum cache (molecule containers) ansible.builtin.command: yum clean all when: @@ -71,5 +75,11 @@ path: /run/nologin state: absent -- name: Deploy PostgreSQL Cluster +- name: Deploy PostgreSQL Cluster test ansible.builtin.import_playbook: ../../deploy_pgcluster.yml + +- name: Config PostgreSQL Cluster test + ansible.builtin.import_playbook: ../../config_pgcluster.yml + +- name: Update PostgreSQL Cluster test + ansible.builtin.import_playbook: ../../update_pgcluster.yml diff --git a/molecule/tests/postgres/replication.yml b/molecule/tests/postgres/replication.yml index b4c369669..2e3bb09f9 100644 --- a/molecule/tests/postgres/replication.yml +++ b/molecule/tests/postgres/replication.yml @@ -1,12 +1,10 @@ --- - name: Check PostgreSQL replication status postgresql_query: - query: "SELECT * FROM pg_stat_wal_receiver;" - login_host: "127.0.0.1" + query: "SELECT pg_is_in_recovery(), count(*) FROM pg_stat_wal_receiver;" + login_unix_socket: "{{ postgresql_unix_socket_dir }}" login_port: "{{ postgresql_port }}" login_user: "{{ patroni_superuser_username }}" - login_password: "{{ patroni_superuser_password }}" login_db: template1 register: pg_replication_status - failed_when: "pg_replication_status.rowcount == 0" - when: "'replica' in group_names" + failed_when: "pg_replication_status.query_result[0].pg_is_in_recovery and pg_replication_status.query_result[0].count == 0" diff --git a/update_pgcluster.yml b/update_pgcluster.yml index 9cf091857..c3f49619e 100644 --- a/update_pgcluster.yml +++ b/update_pgcluster.yml @@ -49,6 +49,8 @@ become: true become_user: postgres any_errors_fatal: true + vars_files: + - vars/main.yml vars: max_replication_lag_bytes: 10485760 # 10 MiB max_transaction_sec: 15 # seconds