diff --git a/.github/workflows/run-python-tests-epas.yml b/.github/workflows/run-python-tests-epas.yml new file mode 100644 index 000000000..416dcbcd8 --- /dev/null +++ b/.github/workflows/run-python-tests-epas.yml @@ -0,0 +1,186 @@ +# This workflow requires the following configuration in Github +# +# Vars: +# ENABLE_EPAS_TESTS - Set to true to enable this test +# +# Secrets: +# EDB_REPO_USERNAME - Username for accessing EDB Repos 1.0 +# EDB_REPO_PASSWORD - Password for accessing EDB Repos 1.0 + +name: Run Python tests on EPAS + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + workflow_dispatch: + +env: + # Note that EDB only support all current EPAS versions on Ubuntu 18.04 + # which pgAdmin doesn't support as Python is v3.6. Github don't support + # Debian or EL runners, so we're stuck with Ubuntu 20.04 and EPAS 13+ + # for the best coverage. + POSTGRESQL_VERSIONS: 15 14 13 + +jobs: + build: + # Only run if the EDB repo username and password are set + if: vars.ENABLE_EPAS_TESTS == 'true' + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - name: Setup the EDB APT repo + run: | + sudo su -c 'echo "deb [arch=amd64] https://apt.enterprisedb.com/$(lsb_release -cs)-edb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/edb-$(lsb_release -cs).list' + sudo su -c 'echo "machine apt.enterprisedb.com login ${{ secrets.EDB_REPO_USERNAME }} password ${{ secrets.EDB_REPO_PASSWORD }}" > /etc/apt/auth.conf.d/edb.conf' + sudo wget -q -O - https://apt.enterprisedb.com/edb-deb.gpg.key | sudo apt-key add - + - name: Install platform dependencies + run: | + PACKAGES= + for VERSION in ${POSTGRESQL_VERSIONS}; + do + PACKAGES="${PACKAGES} edb-as${VERSION}-server edb-as${VERSION}-server-pldebugger edb-as${VERSION}-pgagent" + done + sudo apt update + sudo apt install -y build-essential python3-dev python3-pip libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev ${PACKAGES} + - name: Create the tablespace directory + run: | + for VERSION in ${POSTGRESQL_VERSIONS}; + do + sudo mkdir -p /var/lib/edb-as/tablespaces/${VERSION} + sudo chown enterprisedb:enterprisedb /var/lib/edb-as/tablespaces/${VERSION} + done + - name: Start PostgreSQL + run: | + # Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed + for VERSION in ${POSTGRESQL_VERSIONS}; + do + sudo su -c "echo local all all trust > /etc/edb-as/${VERSION}/main/pg_hba.conf" + sudo sed -i "s/port = 544[0-9]/port = 58${VERSION}/g" /etc/edb-as/${VERSION}/main/postgresql.conf + sudo sed -i "s/shared_preload_libraries = '/shared_preload_libraries = '\$libdir\/plugin_debugger,/g" /etc/edb-as/${VERSION}/main/postgresql.conf + sudo su - enterprisedb -c "mkdir -p /var/run/edb-as/${VERSION}-main.epas_stat_tmp" + sudo systemctl restart edb-as@${VERSION}-main + + until sudo runuser -l enterprisedb -c "/usr/lib/edb-as/${VERSION}/bin/pg_isready -p 58${VERSION}" 2>/dev/null; do + >&2 echo "EPAS is unavailable - sleeping for 2 seconds" + sleep 2 + done + + psql -U enterprisedb -d postgres -p 58${VERSION} -c 'CREATE EXTENSION IF NOT EXISTS pgagent;' + done + + - name: Install Python dependencies + run: | + sudo pip install --upgrade pip + sudo pip install -r web/regression/requirements.txt + sudo pip install "pyOpenSSL>=23.*" + - name: Create the test configuration + run: | + cat < web/config_local.py + from config import * + + # Debug mode + DEBUG = True + + # App mode + SERVER_MODE = False + + # Log + CONSOLE_LOG_LEVEL = DEBUG + FILE_LOG_LEVEL = DEBUG + + DEFAULT_SERVER = '127.0.0.1' + + UPGRADE_CHECK_ENABLED = False + + LOG_FILE = "$(pwd)/var/pgadmin4.log" + SESSION_DB_PATH = "$(pwd)/var/sessions" + STORAGE_DIR = "$(pwd)/var/storage" + SQLITE_PATH = "$(pwd)/var/pgadmin4.db" + TEST_SQLITE_PATH = "$(pwd)/var/pgadmin4.db" + AZURE_CREDENTIAL_CACHE_DIR = "$(pwd)/var/azurecredentialcache" + EOF + + cat < web/regression/test_config.json + { + "pgAdmin4_login_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER@EXAMPLE.COM" + }, + "pgAdmin4_test_user_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER2@EXAMPLE.COM" + }, + "pgAdmin4_test_non_admin_credentials": { + "new_password": "NEWPASSWORD", + "login_password": "PASSWORD", + "login_username": "USER@EXAMPLE.COM" + }, + "server_group": 1, + "server_credentials": [ + EOF + + function add_server_def() { + SEP="," + if [ "$1" = "$2" ]; then + SEP="" + fi + + cat <> web/regression/test_config.json + { + "name": "EPAS $1", + "comment": "EPAS $1 Server", + "db_username": "enterprisedb", + "host": "/var/run/edb-as", + "db_password": "", + "db_port": 58$1, + "maintenance_db": "postgres", + "sslmode": "prefer", + "tablespace_path": "/var/lib/edb-as/tablespaces/$1", + "enabled": true, + "default_binary_paths": { + "pg": "", + "ppas": "/usr/lib/edb-as/$1/bin" + } + }${SEP} + EOF + } + + LAST_VERSION=$(echo ${POSTGRESQL_VERSIONS} | awk '{print $NF}') + for VERSION in ${POSTGRESQL_VERSIONS}; + do + add_server_def ${VERSION} ${LAST_VERSION} + done + + cat <> web/regression/test_config.json + ], + "server_update_data": [ + { + "comment": "This is test update comment" + } + ] + } + EOF + - name: Run the tests + run: make check-python + + - name: Archive server log + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: server-log + path: var/pgadmin4.log + + - name: Archive regression log + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: regression-log + path: web/regression/regression.log diff --git a/.github/workflows/run-python-tests.yml b/.github/workflows/run-python-tests-pg.yml similarity index 99% rename from .github/workflows/run-python-tests.yml rename to .github/workflows/run-python-tests-pg.yml index 0a1f347b5..82936619f 100644 --- a/.github/workflows/run-python-tests.yml +++ b/.github/workflows/run-python-tests-pg.yml @@ -1,4 +1,4 @@ -name: Run Python tests +name: Run Python tests on PostgreSQL on: push: