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

65 lines
2.3 KiB

#!/bin/bash
if ! [ -f /.dockerinit ]; 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]" >&2
echo
echo "Usage examples:
$0 192.168.88.162
$0 192.168.88.162 /results/ junit"
exit 1
fi
SERVER="${1}"
OUTPUT_DIRECTORY="${2:-/code/}"
# 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 'Xvnc4 :99' || true)
if [ -n "${xvnc_process:-}" ] ; then
echo "Warning: existing VNC server found, not restarting Xvnc4 process (PID: $xvnc_process)."
else
echo "Starting VNCserver on display :99"
vncserver -geometry 1280x1024 :99
fi
# selenium
pkill -f '/usr/bin/java -jar /home/selenium/selenium-server-standalone.jar' || true
# NOTE: this could silently fail because selenium-server-standalone.jar is missing a daemonize option
DISPLAY=:99 /usr/bin/java -jar /home/selenium/selenium-server-standalone.jar -trustAllSSLCertificates -log /home/selenium/selenium.log &
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
if [ -n "${3:-}" ] && [ "${3:-}" = "junit" ] ; then
CATALYST_SERVER=https://${SERVER}:1443/ prove --formatter TAP::Formatter::JUnit -l -It/lib t/selenium/*.t | \
tee -a "${OUTPUT_DIRECTORY}/selenium.xml" || RC=$?
else
CATALYST_SERVER="https://${SERVER}:1443" prove -v --color -l -It/lib t/selenium/*.t | \
tee -a "${OUTPUT_DIRECTORY}/selenium.pretty" || RC=$?
fi
echo "Finished test execution, test execution returned with exit code ${RC}."
for file in "${OUTPUT_DIRECTORY}/selenium.pretty" "${OUTPUT_DIRECTORY}/selenium.xml" ; do
if [ -f "$file" ] ; then
echo "Test results available at ${file}"
fi
done
echo "################################################################################"