diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..aa03755d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 + +RUN \ + apt-get update && \ + \ + DEBIAN_FRONTEND=noninteractive apt-get -y install \ + libicu70 \ + libncurses5 \ + libtommath1 \ + python3 \ + python3-pip \ + sudo && \ + \ + rm -rf /var/lib/apt/lists/* && \ + \ + ln -s /usr/lib/x86_64-linux-gnu/libtommath.so.1 /usr/lib/x86_64-linux-gnu/libtommath.so.0 + +ARG UID=1000 + +COPY setup.cfg pyproject.toml /qa-run/ + +RUN \ + useradd -u $UID user -G sudo && \ + groupadd firebird && \ + useradd --non-unique -M -b /opt -s /sbin/nologin -g firebird -u $UID firebird && \ + usermod -G sudo firebird && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ + \ + mkdir /qa-out && \ + chown -R user:user /qa-out && \ + chown -R firebird:firebird /qa-run && \ + cd /qa-run && \ + pip install -e . && \ + pip install pytest-md-report pytest-timeout + +USER user + +ENV PATH=/opt/firebird/bin:$PATH +ENV TERMINFO_DIRS=/lib/terminfo +ENV LD_LIBRARY_PATH=/opt/firebird/lib + +CMD /qa/docker/run.sh diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 00000000..18b31eff --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +sudo /qa/docker/setup.sh + +cd /qa-run + +pytest \ + --server local \ + --save-output \ + --extend-xml \ + --junitxml /qa-out/junit.xml \ + --disable-warnings \ + -vv \ + --tb=long \ + --basetemp=/tmp/pytest-tmp \ + --timeout 250 \ + --md-report \ + --md-report-flavor gfm \ + --md-report-verbose 1 \ + --md-report-color never \ + --md-report-output /qa-out/md_report.md \ + --ignore=tests/functional/replication \ + --ignore=tests/functional/basic/isql/test_08.py \ + ./tests/ diff --git a/docker/setup.sh b/docker/setup.sh new file mode 100755 index 00000000..7261fd4b --- /dev/null +++ b/docker/setup.sh @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +mkdir /tmp/firebird-installer +cd /tmp/firebird-installer +tar xzvf /firebird-installer.tar.gz --strip=1 +./install.sh -silent +echo + +/etc/init.d/firebird stop +echo + +echo Changing SYSDBA password +echo "alter user sysdba password 'masterkey';" | /opt/firebird/bin/isql -q employee + +echo Configuring + +cat < /opt/firebird/firebird.conf +BugcheckAbort = 1 +ExternalFileAccess = Full +AuthServer = Srp, Win_Sspi, Legacy_Auth +UserManager = Srp, Legacy_UserManager +ReadConsistency = 0 +WireCrypt = Enabled +ExtConnPoolSize = 10 +ExtConnPoolLifeTime = 10 +UseFileSystemCache = true +IpcName = xnet_fb4x_qa +DefaultDbCachePages = 2048 +MaxUnflushedWrites = -1 +MaxUnflushedWriteTime = -1 +StatementTimeout = 7200 +KeyHolderPlugin = fbSampleKeyHolder +RemoteServicePort = 3050 +ParallelWorkers = 1 +MaxParallelWorkers = 8 +EOF + +if test -f /opt/firebird/examples/prebuilt/plugins/fbSampleDbCrypt.conf; then + cp /opt/firebird/examples/prebuilt/plugins/fbSampleDbCrypt.conf /opt/firebird/plugins/ + cp /opt/firebird/examples/prebuilt/plugins/libfbSample*.so /opt/firebird/plugins/ + + cat < /opt/firebird/plugins/fbSampleKeyHolder.conf +Auto = true +KeyRed=111 +KeyGreen = 119 +EOF +fi + +cat < /opt/firebird/databases.conf +employee.fdb = \$(dir_sampleDb)/employee.fdb +employee = \$(dir_sampleDb)/employee.fdb + +security.db = \$(dir_secDb)/$(basename $(ls /opt/firebird/security*.fdb)) +{ + RemoteAccess = true + DefaultDbCachePages = 256 +} +EOF + +cat /qa/files/qa-databases.conf >> /opt/firebird/databases.conf + +/etc/init.d/firebird start +echo + +rm -r /tmp/firebird-installer + +mkdir /opt/firebird/examples/empbuild/qa +chmod -R 777 /opt/firebird/examples/empbuild + +cp -rn /qa/* /qa-run/ diff --git a/run-docker.sh b/run-docker.sh new file mode 100755 index 00000000..2cc56502 --- /dev/null +++ b/run-docker.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +# Syntax: +# Run this script passing environment variables: +# FBQA_OUT=/path/to/out FBQA_INSTALLER=/path/to/Firebird.tar.gz ./run-docker.sh + +THIS_DIR=`readlink -f $0` +THIS_DIR=`dirname $THIS_DIR` + +if [ -z "$FBQA_OUT" ]; then + echo \$FBQA_OUT is not defined. +fi + +if [ -z "$FBQA_INSTALLER" ]; then + echo \$FBQA_INSTALLER is not defined. +fi + +if [ -z "$FBQA_OUT" ] || [ -z "$FBQA_INSTALLER" ]; then + exit 1 +fi + +docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --progress=plain -t firebird-qa $THIS_DIR +mkdir -p $FBQA_OUT/tests +docker run --user $(id -u) --rm -v `realpath $FBQA_OUT`:/qa-out -v `realpath $FBQA_OUT/tests`:/qa-run/out/tests -v `realpath $THIS_DIR`:/qa -v `realpath $FBQA_INSTALLER`:/firebird-installer.tar.gz firebird-qa