diff options
author | William Desportes <williamdes@wdes.fr> | 2020-05-25 00:13:09 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2020-06-10 02:27:22 +0300 |
commit | 4de5bcb2a7d65ee9e12d14b50b4750dbec40634f (patch) | |
tree | a9854a73f215ad18ca6109b636464009eca9b8d8 | |
parent | 28dc4088130cf10d021eefd163ad534ef756fe88 (diff) |
Support selenium-standalone mode and use docker
Signed-off-by: William Desportes <williamdes@wdes.fr>
-rw-r--r-- | .travis.yml | 20 | ||||
-rwxr-xr-x | test/install-browserstack | 22 | ||||
-rwxr-xr-x | test/start-local-server | 21 | ||||
-rwxr-xr-x | test/stop-local-server | 26 |
4 files changed, 59 insertions, 30 deletions
diff --git a/.travis.yml b/.travis.yml index c88779a1fb..a3ad9c1ec8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,6 @@ cache: yarn: true directories: - $HOME/.composer/cache/ - - $HOME/browserstack - node_modules jobs: @@ -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')" @@ -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: diff --git a/test/install-browserstack b/test/install-browserstack deleted file mode 100755 index 2348b26e2c..0000000000 --- a/test/install-browserstack +++ /dev/null @@ -1,22 +0,0 @@ -#!/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 - exit 0 -fi - -mkdir -p ~/browserstack -cd ~/browserstack -if [ ! -f BrowserStackLocal ] ; then - wget https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip - unzip BrowserStackLocal-linux-x64.zip -fi - diff --git a/test/start-local-server b/test/start-local-server index 31482a885d..6a09c29d3a 100755 --- a/test/start-local-server +++ b/test/start-local-server @@ -10,6 +10,7 @@ set -e set -x if [ "$CI_MODE" != "selenium" ] ; then + echo "Not in CI_MODE=selenium" exit 0 fi @@ -20,7 +21,7 @@ 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 @@ -28,6 +29,24 @@ $HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm --fpm-config $DIR/php-fpm.conf 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 diff --git a/test/stop-local-server b/test/stop-local-server new file mode 100755 index 0000000000..f187848f97 --- /dev/null +++ b/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 |