Skip to content

Commit

Permalink
Support selenium-standalone mode and use docker
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Jun 9, 2020
1 parent 28dc408 commit 4de5bcb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 30 deletions.
20 changes: 13 additions & 7 deletions .travis.yml
Expand Up @@ -30,7 +30,6 @@ cache:
yarn: true
directories:
- $HOME/.composer/cache/
- $HOME/browserstack
- node_modules

jobs:
Expand Down Expand Up @@ -201,9 +200,15 @@ jobs:
- TESTSUITE_URL=http://127.0.0.1:8000
- TESTSUITE_SERVER="127.0.0.1"
- TESTSUITE_DATABASE="selenium"
- TESTSUITE_SELENIUM_HOST="127.0.0.1"
- TESTSUITE_SELENIUM_PORT="4444"
- SKIP_STANDALONE=1
before_install:
- docker run -d --rm --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59
- phpenv config-rm xdebug.ini
- cp test/config.e2e.inc.php config.inc.php
before_script:
- export TESTSUITE_PASSWORD=`openssl rand -base64 30`
- export TESTSUITE_BROWSERSTACK_KEY=`echo cHlDcHJTNmZwZjVlaUR2RmV6VkU= | base64 --decode`
- mysql -uroot -e "CREATE DATABASE IF NOT EXISTS test"
- mysql -uroot < sql/create_tables.sql
- mysql -uroot -e "SET PASSWORD = PASSWORD('$TESTSUITE_PASSWORD')"
Expand All @@ -213,11 +218,12 @@ jobs:
- if [ -f php.log ] ; then cat php.log ; fi
- if [ -f nginx-error.log ] ; then cat nginx-error.log ; fi
- if [ -f config.inc.php ] ; then rm -rf config.inc.php; fi
- ~/browserstack/BrowserStackLocal --daemon stop
before_install:
- phpenv config-rm xdebug.ini
- ./test/install-browserstack
- cp test/config.e2e.inc.php config.inc.php
- ./test/stop-local-server
- docker logs selenium
- docker stop selenium
services:
- docker
- mysql
addons:
apt:
packages:
Expand Down
22 changes: 0 additions & 22 deletions test/install-browserstack

This file was deleted.

21 changes: 20 additions & 1 deletion test/start-local-server
Expand Up @@ -10,6 +10,7 @@ set -e
set -x

if [ "$CI_MODE" != "selenium" ] ; then
echo "Not in CI_MODE=selenium"
exit 0
fi

Expand All @@ -20,14 +21,32 @@ PHP_VERSION=$(phpenv version-name)

# Create configuration with correct paths
cp test/nginx.conf test/php-fpm.conf test/php.ini $DIR/
sed -i -e "s@%DIR%@$DIR@" -e "s@%ROOT%@$CURRENT@" $DIR/*
sed -i -e "s,%DIR%,$DIR," -e "s,%ROOT%,$CURRENT," $DIR/*
mkdir $DIR/sessions

# Start servers
$HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm --fpm-config $DIR/php-fpm.conf -c $DIR/php.ini
nginx -c $DIR/nginx.conf

if [ ! -z "$TESTSUITE_BROWSERSTACK_KEY" ] ; then
echo "Using: BrowserStack"
# Install if necessary
if [ ! -f ~/browserstack/BrowserStackLocal ] ; then
mkdir -p ~/browserstack
cd ~/browserstack
wget https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip
unzip BrowserStackLocal-linux-x64.zip
fi
# Start BrowserStack Local forwarder
~/browserstack/BrowserStackLocal --force-local --localIdentifier "travis-$TRAVIS_JOB_NUMBER" --onlyAutomate --key "$TESTSUITE_BROWSERSTACK_KEY" --daemon start
elif [ -z "$SKIP_STANDALONE" ] ; then
echo "Using: selenium-standalone"
if [ ! -f selenium-standalone ]; then
yarn global add selenium-standalone
selenium-standalone install
fi
selenium-standalone start -- -debug > ~/selenium-standalone.logs~ 2>&1 &
echo $! > ~/selenium-standalone.pid~
else
echo "Using: nothing."
fi
26 changes: 26 additions & 0 deletions test/stop-local-server
@@ -0,0 +1,26 @@
#!/bin/sh

# Do not run as CGI
if [ -n "$GATEWAY_INTERFACE" ] ; then
echo 'Can not invoke as CGI!'
exit 1
fi

set -e
set -x

if [ "$CI_MODE" != "selenium" ] ; then
echo "Not in CI_MODE=selenium"
exit 0
fi

if [ ! -z "$TESTSUITE_BROWSERSTACK_KEY" ] ; then
# Stop BrowserStack Local forwarder
~/browserstack/BrowserStackLocal --daemon stop
fi

if [ -f ~/selenium-standalone.pid~ ] ; then
# Stop selenium-standalone server
kill $(cat ~/selenium-standalone.pid~)
rm ~/selenium-standalone.pid~
fi

0 comments on commit 4de5bcb

Please sign in to comment.