You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/t/selenium/testrunner

86 lines
2.7 KiB

#!/bin/bash
if ! [ -f /.dockerenv ] && ! grep -q 'devices:/docker' /proc/1/cgroup ; then
echo "Not running inside docker, exiting to avoid data damage." >&2
exit 1
fi
set -e
set -u
PASSWORD="selenium"
if [ -z "${1:-}" ] ; then
echo "Usage: $0 <testsystem> [<output_directory>] [junit] [test_plan]" >&2
echo
echo "Usage examples:
$0 192.168.88.162
$0 192.168.88.162 /results/ junit controller_billing.t"
exit 1
fi
SERVER="${1}"
OUTPUT_DIRECTORY="${2:-/code/}"
OUTPUT_TYPE=${3:-}
shift; shift; shift # remove first three argv to use ${@} below.
if [ -z "${1:-}" ] || [ "${1:-}" == '*.t' ]; then
declare -a TEST_PLAN="t/selenium/runner.t"
elif [ "${1:-}" == 'experimental' ] || [ "${1:-}" == 'exp' ]; then
declare -a TEST_PLAN="exp"
else
declare -a TEST_PLAN=( "${@/#/t/selenium/}" )
fi
export TESTFILES=${TEST_PLAN[*]}
# workaround for new Selenium::Remote::Driver (see Dockerfile)
export PERL5LIB=/home/selenium/Selenium-Remote-Driver/lib/
# vnc
echo "Setting VNC password"
printf '%s\n%s\n\n' "${PASSWORD}" "${PASSWORD}" | vncpasswd >/dev/null
PASSWORD_ENCODED=$(hexdump -v -e '"\\""x" 1/1 "%02X"' < "${HOME}/.vnc/passwd")
xvnc_process=$(pgrep -f 'Xtigervnc :99' || true)
if [ -n "${xvnc_process:-}" ] ; then
echo "Warning: existing VNC server found, not restarting Xtigervnc process (PID: $xvnc_process)."
else
echo "Starting VNCserver on display :99"
vncserver -localhost no -geometry 1280x1024 :99
fi
echo "Firefox version:"
firefox --version
# ensure we don't leave any process behind causing problems with re-execution
pkill -f 'geckodriver' || true
DISPLAY=:99 ~/geckodriver -p 4444 &
DISPLAY=:99 ~/geckodriver -p 5555 &
DISPLAY=:99 ~/geckodriver -p 6666 &
DISPLAY=:99 ~/geckodriver -p 7777 &
echo "################################################################################"
echo "Finished main setup, now running tests ..."
echo "Selenium server log file available at /home/selenium/selenium.log"
echo "Watch at test runs by connecting via VNC (password: '${PASSWORD}'):"
echo "echo -e '$PASSWORD_ENCODED' >/tmp/vncpasswd ; vncviewer geometry=1280x1024x16 passwd=/tmp/vncpasswd localhost:5999"
RC=0
export CATALYST_SERVER="https://${SERVER}:1443"
if [ "${OUTPUT_TYPE:-}" = "junit" ] ; then
export JENKINS=1
perl t/selenium/runner.t | \
tee -a "${OUTPUT_DIRECTORY}/selenium.xml"
RC="${PIPESTATUS[0]}"
else
perl t/selenium/runner.t || RC=$?
fi
echo "Finished test execution, test execution returned with exit code ${RC}."
if [ -f "${OUTPUT_DIRECTORY}/selenium.xml" ] ; then
echo "Test results available at '${OUTPUT_DIRECTORY}/selenium.xml'"
fi
echo "################################################################################"
exit "${RC}"