Fix failing parallel running browser tests with Gitlab & Robotframework

erstellt von Steffen Lindner zuletzt geändert: 2017-01-25T17:41:19+02:00
Comments
One of our project is organized in sprints where all developer work on the same code at the same time. We use one Gitlab CI server with a simple shell executer and had random failing builds with Robotframwork & Firefox.

Our Gitlab CI Runner can run three shell executer at the same time. Sometimes two Robotframework (Selenium) tests run in parallel and one of them fails with this error:

error: [Errno 98] Address already in use

That means Firefox is already in use (by the other build) and the CI job failed and blocked our process. Gitlabs automerge -feature does not happen and the code-reviewer needs to manually start the job again since it is marked as a fail.

We solved the problem with a little shell script isfirefoxinuse.sh that waits if a Robot process is running:

#!/bin/sh

while :
do

RESULT=`pgrep -f robot`

if [ "${RESULT:-null}" = null ]; then
echo "Robot not running, starting "
./bin/test --all -t robot || exit 1
break
else
echo "running"
fi
sleep 20
done

Our .gitlab-ci.yml file looks like this:

before_script:
- export PATH=$PATH:bin/
- export DISPLAY=:99

build_project:
# stage: build
script:
# Stage: build
- /usr/bin/virtualenv .
- ./bootstrap_ci.sh
# Stage test
- ./bin/code-analysis
- ./bin/i18nize_all && ./bin/podiff_all
- ./bin/coverage erase
- ./bin/coverage run -p --source=src bin/test || exit 1
- ./bin/coverage combine
- ./bin/coverage html
- ./bin/coverage report
# Stage robot
- ./bin/isfirefoxinuse.sh || exit 1
artifacts:
expire_in: 1 week
paths:
- parts/test/

The call to start the robot tests (./bin/test --all -t robot) is wrapped into the ./bin/isfirefoxinuse.sh script.

If you are a buildout user, this might be useful to get the script integrated:

parts +=
isfirefoxinuse
...

recipe = collective.recipe.cmd
on_install = true
on_update = true
cmds = cp ${buildout:directory}/templates/isfirefoxinuse.in ${buildout:bin-directory}/isfirefoxinuse.sh

 Hope this helps someone!

Kommentare unterstützt durch Disqus