Fix failing parallel running browser tests with Gitlab & Robotframework

erstellt von Steffen Lindner zuletzt geändert: 2017-01-25T16:41:19+01:00
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 that waits if a Robot process is running:


while :

RESULT=`pgrep -f robot`

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

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

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

# stage: build
# Stage: build
- /usr/bin/virtualenv .
- ./
# 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/ || exit 1
expire_in: 1 week
- parts/test/

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

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

parts +=

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

 Hope this helps someone!

Kommentare unterstützt durch Disqus