diff --git a/.github/workflows/run-python-tests-epas.yml b/.github/workflows/run-python-tests-epas.yml index deb360ab2..ddf118041 100644 --- a/.github/workflows/run-python-tests-epas.yml +++ b/.github/workflows/run-python-tests-epas.yml @@ -6,6 +6,7 @@ # Secrets: # EDB_REPO_USERNAME - Username for accessing EDB Repos 1.0 # EDB_REPO_PASSWORD - Password for accessing EDB Repos 1.0 +# EDB_SBP_URL - URL to the EDB StackBuilder Plus catalog name: Run Python tests on EPAS @@ -30,30 +31,55 @@ jobs: strategy: fail-fast: false matrix: + os: [ubuntu-22.04, windows-latest] pgver: [11, 12, 13, 14, 15] - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Setup the EDB APT repo + - name: Setup the EDB APT repo on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} 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 + - name: Install platform dependencies on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: | sudo apt update sudo apt install -y libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev edb-as${{ matrix.pgver }}-server edb-as${{ matrix.pgver }}-server-pldebugger edb-as${{ matrix.pgver }}-pgagent - - name: Create the tablespace directory + - name: Install platform dependencies on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + FOR /f "delims=" %%F IN ('python tools\get_sb_package.py "${{ secrets.EDB_SBP_URL }}" "edb_as${{ matrix.pgver }}_dbserver" "windows-x64"') DO SET INSTALLER_EXE=%%F + ECHO Running %INSTALLER_EXE%... + %INSTALLER_EXE% --prefix C:\EPAS\${{ matrix.pgver }} --datadir C:\EPAS\${{ matrix.pgver }}\data --serverport 58${{ matrix.pgver }} --superpassword enterprisedb --create_samples no --install_runtimes 0 --mode unattended --unattendedmodeui none --disable-components stackbuilderplus${{ matrix.pgver < 15 && ',pgadmin4' || '' }} + + choco install -y mitkerberos + + REM Ignore error 3010 (reboot required) + IF %ERRORLEVEL% EQU 3010 cmd /c "exit /b 0" + shell: cmd + + - name: Create the tablespace directory on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: | sudo mkdir -p /var/lib/edb-as/tablespaces/${{ matrix.pgver }} sudo chown enterprisedb:enterprisedb /var/lib/edb-as/tablespaces/${{ matrix.pgver }} - - name: Start PostgreSQL + - name: Create the tablespace directory on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + mkdir "C:\EPAS\${{ matrix.pgver }}\tablespaces" + icacls "C:\EPAS\${{ matrix.pgver }}\tablespaces" /grant "NETWORK SERVICE":(OI)(CI)F /T + shell: cmd + + - name: Start PostgreSQL on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: | # 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/edb-as/${{ matrix.pgver }}/main/pg_hba.conf" @@ -69,10 +95,23 @@ jobs: psql -U enterprisedb -d postgres -p 58${{ matrix.pgver }} -c 'CREATE EXTENSION IF NOT EXISTS pgagent;' - - name: Install Python dependencies + - name: Install Python dependencies on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: make install-python-testing - - name: Create the test configuration + - name: Install Python dependencies on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + SET LIB=C:\EPAS\${{ matrix.pgver }}\lib;%LIB% + SET INCLUDE=C:\EPAS\${{ matrix.pgver }}\include;%INCLUDE% + python -m venv venv + call venv\Scripts\activate.bat + python -m pip install --upgrade pip + pip install wheel sphinx sphinxcontrib-youtube -r web\regression\requirements.txt + shell: cmd + + - name: Create the test configuration on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: | cat < web/config_local.py from config import * @@ -143,21 +182,104 @@ jobs: } EOF - - name: Run the tests + - name: Create the test configuration on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + FOR /f "delims=" %%D IN ('python -c "import os; print(os.getcwd().replace('\\', '\\\\'))"') DO SET WORKING_DIR=%%D + + > web\config_local.py ( + @echo.from config import * + @echo. + @echo.# Debug mode + @echo.DEBUG = True + @echo. + @echo.# App mode + @echo.SERVER_MODE = False + @echo. + @echo.# Log + @echo.CONSOLE_LOG_LEVEL = DEBUG + @echo.FILE_LOG_LEVEL = DEBUG + @echo. + @echo.DEFAULT_SERVER = '127.0.0.1' + @echo. + @echo.UPGRADE_CHECK_ENABLED = False + @echo. + @echo.LOG_FILE = "%WORKING_DIR%\\var\\pgadmin4.log" + @echo.SESSION_DB_PATH = "%WORKING_DIR%\\var\\sessions" + @echo.STORAGE_DIR = "%WORKING_DIR%\\var\\storage" + @echo.SQLITE_PATH = "%WORKING_DIR%\\var\\pgadmin4.db" + @echo.TEST_SQLITE_PATH = "%WORKING_DIR%\\var\\test_pgadmin4.db" + @echo.AZURE_CREDENTIAL_CACHE_DIR = "%WORKING_DIR%\\var\\azurecredentialcache" + ) + + > web\regression\test_config.json ( + @echo.{ + @echo. "pgAdmin4_login_credentials": { + @echo. "new_password": "NEWPASSWORD", + @echo. "login_password": "PASSWORD", + @echo. "login_username": "USER@EXAMPLE.COM" + @echo. }, + @echo. "pgAdmin4_test_user_credentials": { + @echo. "new_password": "NEWPASSWORD", + @echo. "login_password": "PASSWORD", + @echo. "login_username": "USER2@EXAMPLE.COM" + @echo. }, + @echo. "pgAdmin4_test_non_admin_credentials": { + @echo. "new_password": "NEWPASSWORD", + @echo. "login_password": "PASSWORD", + @echo. "login_username": "USER@EXAMPLE.COM" + @echo. }, + @echo. "server_group": 1, + @echo. "server_credentials": [ + @echo. { + @echo. "name": "EPAS ${{ matrix.pgver }}", + @echo. "comment": "EPAS ${{ matrix.pgver }} Server", + @echo. "db_username": "enterprisedb", + @echo. "host": "127.0.0.1", + @echo. "db_password": "enterprisedb", + @echo. "db_port": 58${{ matrix.pgver }}, + @echo. "maintenance_db": "postgres", + @echo. "sslmode": "prefer", + @echo. "tablespace_path": "C:\\EPAS\\${{ matrix.pgver }}\\tablespaces", + @echo. "enabled": true, + @echo. "default_binary_paths": { + @echo. "pg": "", + @echo. "ppas": "C:\\EPAS\\${{ matrix.pgver }}\\bin" + @echo. } + @echo. } + @echo. ], + @echo. "server_update_data": [ + @echo. { + @echo. "comment": "This is test update comment" + @echo. } + @echo. ] + @echo.} + ) + shell: cmd + + - name: Run the tests on Linux + if: ${{ matrix.os == 'ubuntu-22.04' }} run: | . venv/bin/activate make check-python + - name: Run the tests on Windows + if: ${{ matrix.os == 'windows-latest' }} + run: | + call venv\Scripts\activate.bat + python web\regression\runtests.py --exclude feature_tests + shell: cmd + - name: Archive server log if: success() || failure() uses: actions/upload-artifact@v3 with: - name: server-log-pg${{ matrix.pgver }} + name: server-log-epas${{ matrix.pgver }} path: var/pgadmin4.log - name: Archive regression log if: success() || failure() uses: actions/upload-artifact@v3 with: - name: regression-log-pg${{ matrix.pgver }} + name: regression-log-epas${{ matrix.pgver }} path: web/regression/regression.log diff --git a/tools/get_sb_package.py b/tools/get_sb_package.py new file mode 100755 index 000000000..ff418dca5 --- /dev/null +++ b/tools/get_sb_package.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +########################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2023, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +# Get the URL to the latest version of a package in a StackBuilder catalog + +import os +import sys + +from urllib.request import urlopen, urlretrieve +import xml.etree.ElementTree as ET + +if len(sys.argv) != 4: + print('Usage: {} '.\ + format(sys.argv[0])) + sys.exit(1) + +# Get the catalog +catalog = urlopen(sys.argv[1]).read().decode('utf-8') +apps = ET.fromstring(catalog) + +downloads = [] +for a in apps: + if a.find('id').text == sys.argv[2] and \ + a.find('platform').text == sys.argv[3]: + downloads.append({'version': a.find('version').text, + 'url': a.find('alturl').text, + 'format': a.find('format').text}) + +if len(downloads) == 0: + print('No matching URLs found.') + sys.exit(1) + +# Make sure we're looking at the latest version +downloads = sorted(downloads, key=lambda d: d['version'], reverse=True) + +# Get the file +filename, headers = urlretrieve(downloads[0]['url']) + +if sys.argv[3].startswith('windows') and downloads[0]['format'] == 'exe': + os.rename(filename, '{}.exe'.format(filename)) + filename = '{}.exe'.format(filename) + +print(filename)