chilio / laravel-dusk-ci

Docker Test suite for Laravel Dusk in gitlab CI
MIT License
159 stars 51 forks source link

[SEVERE]: bind() failed: Cannot assign requested address (99) #75

Closed lewislarsen closed 8 months ago

lewislarsen commented 11 months ago

I have run into a slight snag when using the latest image with a Gitlab CI pipeline, it can reach the starting ChromeDriver on port 9515, but unfortunately, a binding issue presents itself afterwards.

ChromeDriver binary successfully installed for version 112.0.5615.49.
$ configure-laravel

   INFO  Application key set successfully.  

   INFO  The [public/storage] link has been connected to [storage/app/public].  

  Dropping all tables ............................................. 213ms DONE

   INFO  Preparing database.  

  Creating migration table ......................................... 38ms DONE

   INFO  Running migrations.  

-- SNIP -- 

   INFO  Seeding database.  

System Chrome version: 112
System Chromedriver version: 112.0
Laravel Chromedriver version: 112.0
 Laravel Chromedriver check PASSED OK.
You can use both Chromedriver shipped with Laravel (112.0) or system Chromeriver (112.0)
System Chromedriver is NOT automatically started in this case. So, before running php artisan DUSK, you have 2 options:
1. If you want to run tests with Laravel Chromedriver and you have DuskTestCase.php configured with 'static::startChromeDriver();' enabled, then you don't need to change anything.
2. If you want to run tests with System Chromedriver, remember to issue command 'chromedriver &' in your .gitlab-ci-yml before starting Dusk tests.
$ start-nginx-ci-project
 * Starting nginx nginx
   ...done.
$ chromedriver &
$ php artisan pest:dusk --without-tty
Starting ChromeDriver 112.0.5615.49 (bd2a7bcb881c11e8cfe3078709382934e3916914-refs/branch-heads/5615@{#936}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1696844306.357][SEVERE]: bind() failed: Cannot assign requested address (99)
ChromeDriver was started successfully.

I don't want to burden this issue with logs but here's one of the Dusk test failures as it may come in handy.

   FAILED  Tests\Browser\Tablatures\IndexFilterTest >…  UnknownErrorException   
  unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

  at vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:146
    142▕                     throw new UnexpectedAlertOpenException($message, $results);
    143▕                 case 'unknown command':
    144▕                     throw new UnknownCommandException($message, $results);
    145▕                 case 'unknown error':
  ➜ 146▕                     throw new UnknownErrorException($message, $results);
    147▕                 case 'unknown method':
    148▕                     throw new UnknownMethodException($message, $results);
    149▕                 case 'unsupported operation':
    150▕                     throw new UnsupportedOperationException($message, $results);

      +3 vendor frames 
  4   tests/DuskTestCase.php:40
      +1 vendor frames 
  6   tests/Browser/Tablatures/IndexFilterTest.php:11

This is the job from my gitlab-ci.yml file.

end_to_end_tests:
#  extends: .standard-rules
  stage: testing
  image: chilio/laravel-dusk-ci:latest
  script:
    - php artisan dusk:chrome-driver --detect --verbose
    - configure-laravel
    - start-nginx-ci-project
    - chromedriver &
    - php artisan pest:dusk --without-tty
  artifacts:
    paths:
      - ./storage/logs # for debugging
      - ./tests/Browser/screenshots
      - ./tests/Browser/console
    expire_in: 7 days
    when: always

The only adjustment I have made is adding no--sandbox to the driver in DuskTestCase.php. The only outlier is that I use Postgres (the tables migrate successfully) but I couldn't see why that would break dusk testing.

If you happen to know what the culprit could be, I'd appreciate it, if you need any additional information please let me know, I didn't want this to be a wall of logs. (It is being ran locally with gitlab-ci-local)

I have attached my full gitlab ci file as it may reveal the issue with added information. (Had to change the extension!)

gitlab-ci.txt

chilio commented 11 months ago

Hi, unfortunately I don't have time to investigate further, I can only confirm and double checked that tests are passing with phpunit and dusk without problems. It might be your running machine configuration or resources, as well as some specific things connected with your project.

lewislarsen commented 11 months ago

Hi, unfortunately I don't have time to investigate further, I can only confirm and double checked that tests are passing with phpunit and dusk without problems. It might be your running machine configuration or resources, as well as some specific things connected with your project.

No worries, I'll do my best to investigate further. :)