Sunil Mohan Adapa 4cfc2fb4f2
tests: functional: Make install script work for Bullseye
- Pip option --break-system-packages is available only from Bookworm.

- Remove --user to that the script works can be used broadly.

Tests:

- On a fresh stable container, running functional tests works. Without the
patch, it fails.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-04-05 08:50:08 -04:00

40 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
echo "Installing requirements"
sudo apt-get install -yq --no-install-recommends \
python3-pytest python3-pytest-django python3-pytest-xdist \
python3-pip python3-wheel firefox-esr git smbclient
# Use compatible versions of Splinter and Selenium
PIP_VERSION=$(dpkg-query -W -f '${Version}' python3-pip)
PIP_OPTIONS=
dpkg --compare-versions 23 \<= $PIP_VERSION && PIP_OPTIONS=--break-system-packages
pip3 install $PIP_OPTIONS selenium==4.2.0 splinter==0.17.0 pytest-splinter pytest-reporter-html1
echo "Installing geckodriver"
(
DL_DIR=/tmp/gecko
GECKO_VERSION=$(curl --silent "https://api.github.com/repos/mozilla/geckodriver/releases/latest" | grep -Po '"tag_name":\s*"\K.*?(?=")')
FILENAME="geckodriver-${GECKO_VERSION}-linux64.tar.gz"
GECKO_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKO_VERSION/$FILENAME"
test -e /usr/local/bin/geckodriver && \
test "$GECKO_VERSION" = "v$(geckodriver --version | head -1 | awk '{ print $2 }')" && \
echo "geckodriver already installed" && \
exit 0
mkdir -p $DL_DIR
cd $DL_DIR
if ! [[ -e $FILENAME ]] ; then
wget --no-clobber \
--continue \
--no-verbose \
"$GECKO_URL"
fi
tar xf $FILENAME
sudo mv geckodriver /usr/local/bin/geckodriver
echo "Done"
)