From f2b2e85be8c6e9d0008b9d12ee07ecb752540294 Mon Sep 17 00:00:00 2001 From: Parsa Date: Sun, 1 Oct 2023 21:34:55 +0330 Subject: [PATCH] fix(deployment): Fix integration-test to use run for different postgres versions --- deployment/Dockerfile | 1 + deployment/integration-test.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 394a8a6..b9ce4cf 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y \ RUN echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - ARG POSTGRES_VERSION=13 +ENV POSTGRES_VERSION=${POSTGRES_VERSION} RUN apt-get update && apt-get install -y postgresql-${POSTGRES_VERSION} RUN pip3 install pyyaml diff --git a/deployment/integration-test.py b/deployment/integration-test.py index 665ef11..7739770 100644 --- a/deployment/integration-test.py +++ b/deployment/integration-test.py @@ -6,8 +6,8 @@ from pgkit.application.settings import DB_PATH - -EXPECTED_CONFIG = '{"config": {"1": {"name": "main", "version": "12", "host": "master", "port": 5432, "dbname": "test", "slot": "replicaslottest", "username": "testuser", "password": "test-pass", "replica_port": "5432", "use_separate_receivewal_service": false, "max_connections": 100, "max_worker_processes": 8}}}' +POSTGRES_VERSION = os.getenv("POSTGRES_VERSION") +EXPECTED_CONFIG = f'{{"config": {{"1": {{"name": "main", "version": "{POSTGRES_VERSION}", "host": "master", "port": 5432, "dbname": "test", "slot": "replicaslottest", "username": "testuser", "password": "test-pass", "replica_port": "5432", "use_separate_receivewal_service": false, "max_connections": 100, "max_worker_processes": 8}}}}}}' pgpass_file = str(pathlib.Path.home()) + '/.pgpass' with open(pgpass_file, 'w+') as f: @@ -43,8 +43,8 @@ def check_successful_insert(host, port, dbname, username, id, lastname, firstnam def open_pg_hba(cluster_name): - subprocess.run(f"echo \"host all all 0.0.0.0/0 md5\" >> /etc/postgresql/12/{cluster_name}/pg_hba.conf", shell=True) - subprocess.run(f"systemctl reload postgresql@12-{cluster_name}.service", shell=True) + subprocess.run(f"echo \"host all all 0.0.0.0/0 md5\" >> /etc/postgresql/{POSTGRES_VERSION}/{cluster_name}/pg_hba.conf", shell=True) + subprocess.run(f"systemctl reload postgresql@{POSTGRES_VERSION}-{cluster_name}.service", shell=True) def check_config(actual_config): @@ -75,7 +75,7 @@ def check_same_query_on_replica_and_master_expect_unsync(replica_host, replica_p def add_config(cluster_name, master_host, replica_slot, replica_port, use_separate_receivewal_service=False): command = (f"pgkit config add --name {cluster_name} " + - f"--version 12 --host {master_host}" + + f"--version {POSTGRES_VERSION} --host {master_host}" + f" --port 5432 --dbname test --slot {replica_slot}" + f" --username testuser --password test-pass" + f" --replica-port {replica_port}" @@ -110,7 +110,7 @@ def test_get_config(): assert output[8] == "slot: replicaslottest" assert output[9] == "use_separate_receivewal_service: false" assert output[10] == "username: testuser" - assert output[11] == "version: '12'" + assert output[11] == f"version: '{POSTGRES_VERSION}'" def test_pitr_0_delay_backup():