Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Molecule: Add config_pgcluster.yml and update_pgcluster.yml playbooks to tests #478

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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
8 changes: 3 additions & 5 deletions molecule/tests/postgres/replication.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions update_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down