Run Python tests against all supported PostgreSQL versions.

This commit is contained in:
Dave Page
2023-03-30 15:54:06 +01:00
parent 374941bfab
commit 222de66a83

View File

@@ -9,7 +9,7 @@ on:
workflow_dispatch: workflow_dispatch:
env: env:
POSTGRESQL_VERSION: 15 POSTGRESQL_VERSIONS: 15 14 13 12 11
jobs: jobs:
build: build:
@@ -22,37 +22,56 @@ jobs:
run: | run: |
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- name: Install platform dependencies - name: Install platform dependencies
run: | run: |
PACKAGES=
for VERSION in ${POSTGRESQL_VERSIONS};
do
PACKAGES="${PACKAGES} postgresql-${VERSION} postgresql-${VERSION}-pldebugger"
done
sudo apt update sudo apt update
sudo apt install -y build-essential python3-dev python3-pip libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev postgresql-${POSTGRESQL_VERSION} postgresql-${POSTGRESQL_VERSION}-pldebugger pgagent sudo apt install -y build-essential python3-dev python3-pip libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev ${PACKAGES} pgagent
- name: Create the tablespace directory - name: Create the tablespace directory
run: | run: |
sudo mkdir -p /var/lib/postgresql/tablespaces/${POSTGRESQL_VERSION} for VERSION in ${POSTGRESQL_VERSIONS};
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${POSTGRESQL_VERSION} do
sudo mkdir -p /var/lib/postgresql/tablespaces/${VERSION}
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${VERSION}
done
- name: Start PostgreSQL - name: Start PostgreSQL
run: | run: |
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed # Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
sudo su -c "echo local all all trust > /etc/postgresql/${POSTGRESQL_VERSION}/main/pg_hba.conf" for VERSION in ${POSTGRESQL_VERSIONS};
sudo sed -i "s/port = 543[0-9]/port = 59${POSTGRESQL_VERSION}/g" /etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf do
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf sudo su -c "echo local all all trust > /etc/postgresql/${VERSION}/main/pg_hba.conf"
sudo su - postgres -c "/usr/lib/postgresql/${POSTGRESQL_VERSION}/bin/postgres -D /var/lib/postgresql/${POSTGRESQL_VERSION}/main -c config_file=/etc/postgresql/${POSTGRESQL_VERSION}/main/postgresql.conf &" sudo sed -i "s/port = 543[0-9]/port = 59${VERSION}/g" /etc/postgresql/${VERSION}/main/postgresql.conf
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${VERSION}/main/postgresql.conf
sudo su - postgres -c "/usr/lib/postgresql/${VERSION}/bin/postgres -D /var/lib/postgresql/${VERSION}/main -c config_file=/etc/postgresql/${VERSION}/main/postgresql.conf &"
until sudo runuser -l postgres -c "pg_isready -p 59${POSTGRESQL_VERSION}" 2>/dev/null; do until sudo runuser -l postgres -c "pg_isready -p 59${VERSION}" 2>/dev/null; do
>&2 echo "Postgres is unavailable - sleeping for 2 seconds" >&2 echo "Postgres is unavailable - sleeping for 2 seconds"
sleep 2 sleep 2
done done
psql -U postgres -p 59${POSTGRESQL_VERSION} -c 'CREATE EXTENSION pgagent;'
psql -U postgres -p 59${POSTGRESQL_VERSION} -c 'CREATE EXTENSION pldbgapi;' psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pgagent;'
psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pldbgapi;'
done
- name: Install Python dependencies - name: Install Python dependencies
run: | run: |
sudo pip install --upgrade pip sudo pip install --upgrade pip
sudo pip install -r web/regression/requirements.txt sudo pip install -r web/regression/requirements.txt
sudo pip install "pyOpenSSL>=23.*" sudo pip install "pyOpenSSL>=23.*"
- name: Create the test configuration - name: Create the test configuration
run: | run: |
cat <<EOF > web/config_local.py cat <<EOF > web/config_local.py
from config import * from config import *
# Debug mode # Debug mode
DEBUG = True DEBUG = True
@@ -74,6 +93,7 @@ jobs:
TEST_SQLITE_PATH = "$(pwd)/var/pgadmin4.db" TEST_SQLITE_PATH = "$(pwd)/var/pgadmin4.db"
AZURE_CREDENTIAL_CACHE_DIR = "$(pwd)/var/azurecredentialcache" AZURE_CREDENTIAL_CACHE_DIR = "$(pwd)/var/azurecredentialcache"
EOF EOF
cat <<EOF > web/regression/test_config.json cat <<EOF > web/regression/test_config.json
{ {
"pgAdmin4_login_credentials": { "pgAdmin4_login_credentials": {
@@ -93,22 +113,41 @@ jobs:
}, },
"server_group": 1, "server_group": 1,
"server_credentials": [ "server_credentials": [
EOF
function add_server_def() {
SEP=","
if [ "$1" = "$2" ]; then
SEP=""
fi
cat <<EOF >> web/regression/test_config.json
{ {
"name": "PostgreSQL ${POSTGRESQL_VERSION}", "name": "PostgreSQL $1",
"comment": "PostgreSQL ${POSTGRESQL_VERSION} Server", "comment": "PostgreSQL $1 Server",
"db_username": "postgres", "db_username": "postgres",
"host": "/var/run/postgresql", "host": "/var/run/postgresql",
"db_password": "postgres", "db_password": "postgres",
"db_port": 59${POSTGRESQL_VERSION}, "db_port": 59$1,
"maintenance_db": "postgres", "maintenance_db": "postgres",
"sslmode": "prefer", "sslmode": "prefer",
"tablespace_path": "/var/lib/postgresql/tablespaces/${POSTGRESQL_VERSION}", "tablespace_path": "/var/lib/postgresql/tablespaces/$1",
"enabled": true, "enabled": true,
"default_binary_paths": { "default_binary_paths": {
"pg": "/usr/lib/postgresql/${POSTGRESQL_VERSION}/bin", "pg": "/usr/lib/postgresql/$1/bin",
"ppas": "" "ppas": ""
} }
}${SEP}
EOF
} }
LAST_VERSION=$(echo ${POSTGRESQL_VERSIONS} | awk '{print $NF}')
for VERSION in ${POSTGRESQL_VERSIONS};
do
add_server_def ${VERSION} ${LAST_VERSION}
done
cat <<EOF >> web/regression/test_config.json
], ],
"server_update_data": [ "server_update_data": [
{ {
@@ -117,6 +156,7 @@ jobs:
] ]
} }
EOF EOF
- name: Run the tests - name: Run the tests
run: make check-python run: make check-python