laravel / dusk

Laravel Dusk provides simple end-to-end testing and browser automation.
https://laravel.com/docs/dusk
MIT License
1.88k stars 322 forks source link

Dusk timed out in gitlab-ci #331

Closed ajcastro closed 7 years ago

ajcastro commented 7 years ago

I've been searching for this and also tried solutions like from https://github.com/laravel/dusk/issues/50#issuecomment-275155974. But didnt work..

I just need some little help from you guys. Please help.

I am using the default DuskTestCase.php.

Related Issue: #10

This is the dusk job configuration in my gitlab-ci.yml

dusk:
  image: ubuntu:xenial

  before_script:
  - apt-get update -yqq
  - apt-get -y install curl
  - apt-get -y install php
  - apt-get -y install wget

  # ----------------------------------------------------------------------------
  # Upgrade to Node 7
  - curl -sL https://deb.nodesource.com/setup_7.x | bash -

  # Install dependencies
  - apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq

  # Install php extensions
  # - docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache bcmath
  - apt-get install -y php7.0-gd php7.0-mysql php7.0-dom php7.0-cli php7.0-json php7.0-common php7.0-mbstring php7.0-opcache php7.0-readline php7.0-bcmath php7.0-curl php7.0-zip

  # # Install xdebug
  # - pecl install xdebug
  # # Enable Xdebug
  # - docker-php-ext-enable xdebug

  # Install Composer and project dependencies.
  - curl -sS https://getcomposer.org/installer | php
  - php composer.phar install 

  # Install Node dependencies.
  # comment this out if you don't have a node dependency
  - npm install

  # Copy over testing configuration.
  # Don't forget to set the database config in .env.testing correctly
  # DB_HOST=mysql
  # DB_DATABASE=project_name
  # DB_USERNAME=root
  # DB_PASSWORD=secret
  - cp .env._testing .env

  # Run npm build
  # comment this out if you don't have a frontend build
  # you can change this to to your frontend building script like
  # npm run build
  - npm run dev

  # Generate an application key. Re-cache.
  - php artisan key:generate
  - php artisan config:cache

  # Run database migrations.
  - php artisan migrate

  # Run database seed
  - php artisan db:seed
  # ----------------------------------------------------------------------------

  # ----------------------------------------------------------------------------
  # From https://github.com/laravel/dusk/issues/50#issuecomment-275669582
  - apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4

  # Install google-chrome browser
  - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
  - sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
  - apt-get update
  - apt-get -y install google-chrome-stable

  - apt-get -y install xvfb gtk2-engines-pixbuf
  - apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
  - apt-get -y install imagemagick x11-apps

  - chmod a+x ./vendor/laravel/dusk/bin/*

  # - Xvfb -ac :0 -screen 0 1280x1024x16 &
  - export DISPLAY=:99.0
  - Xvfb :0 -screen 0 1280x960x24 &
  # - ./vendor/laravel/dusk/bin/chromedriver-linux &
  - php artisan serve > /dev/null 2>&1 &
  - cat /etc/hosts
  - sleep 5

  # ----------------------------------------------------------------------------

  script:
  # run dusk tests
  - php artisan dusk

And this is the result:

$ php artisan dusk
Warning: TTY mode requires /dev/tty to be read/writable.
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 2.5 minutes, Memory: 10.00MB

There was 1 error:

1) Tests\Browser\LoginTest::testLogin
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}

Operation timed out after 30000 milliseconds with 0 bytes received

/builds/ajcastro29/daragahomedepot/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286
/builds/ajcastro29/daragahomedepot/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126
/builds/ajcastro29/daragahomedepot/tests/DuskTestCase.php:32
/builds/ajcastro29/daragahomedepot/vendor/laravel/dusk/src/TestCase.php:209
/builds/ajcastro29/daragahomedepot/vendor/laravel/framework/src/Illuminate/Support/helpers.php:706
/builds/ajcastro29/daragahomedepot/vendor/laravel/dusk/src/TestCase.php:210
/builds/ajcastro29/daragahomedepot/vendor/laravel/dusk/src/TestCase.php:116
/builds/ajcastro29/daragahomedepot/vendor/laravel/dusk/src/TestCase.php:88
/builds/ajcastro29/daragahomedepot/tests/Browser/LoginTest.php:24

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Running after script...
$ cat storage/logs/laravel.log
cat: storage/logs/laravel.log: No such file or directory
ERROR: Job failed: exit code 1
deleugpn commented 7 years ago

your problem is probably here:

  # - Xvfb -ac :0 -screen 0 1280x1024x16 &
  - export DISPLAY=:99.0
  - Xvfb :0 -screen 0 1280x960x24 &

You're starting a screen on display 0, but you're setting the display to 99.0. Use export DISPLAY=:0 instead.

lsfiege commented 7 years ago

Try with this docker image

ajcastro commented 7 years ago

this is already resolved btw.