ddev / ddev-selenium-standalone-chrome

A DDEV service for running standalone Chrome
Apache License 2.0
34 stars 20 forks source link

Connection fails if tests are not allowed to complete #28

Open andy-blum opened 1 year ago

andy-blum commented 1 year ago

I've been struggling to get Drupal Nightwatch tests running at all, but this appears to be a bug worth sharing:

If I start running tests, and ^C before they finish, the web container will never connect to the selenium-chrome container again until I ddev restart.

Copy/Pasted output for search-ability:

andy@drupal-tests-web:/var/www/html/core$ yarn test:nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js 
yarn run v1.22.19
$ node -r dotenv-safe/config ./node_modules/.bin/nightwatch --config ./tests/Drupal/Nightwatch/nightwatch.conf.js tests/Drupal/Nightwatch/Tests/exampleTest.js

[Tests/Example Test] Test Suite
──────────────────────────────────────────────────────────────
ℹ Connected to selenium-chrome on port 4444 (585ms).
  Using: chrome (101.0.4951.41) on LINUX.

  ℹ Loaded url http://web in 181ms

  Running Test page:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ℹ Loaded url http://web/test-page in 263ms
  ✔ Element <body> was visible after 53 milliseconds.
  ✔ Testing if element <body> contains text 'Test page text' (59ms)

  ✨ PASSED. 2 assertions. (443ms)

  Running Page objects test page:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ℹ Loaded url http://web/test-page in 142ms
  ✔ Element <body> was visible after 34 milliseconds.
  ✔ Testing if element <Element [name=@body]> contains text 'Test page text' (28ms)
  ✔ Ensuring no deprecation errors have been triggered (11ms)

  ✨ PASSED. 3 assertions. (292ms)
^C

andy@drupal-tests-web:/var/www/html/core$ yarn test:nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js 
yarn run v1.22.19
$ node -r dotenv-safe/config ./node_modules/.bin/nightwatch --config ./tests/Drupal/Nightwatch/nightwatch.conf.js tests/Drupal/Nightwatch/Tests/exampleTest.js

[Tests/Example Test] Test Suite
──────────────────────────────────────────────────────────────
⠹ Connecting to selenium-chrome on port 4444...
  Error
      POST http://selenium-chrome:4444 /wd/hub/session - ECONNRESET
Error: socket hang up
    at Socket.socketCloseListener (node:_http_client:467:25)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
⠧ Connecting to selenium-chrome on port 4444...
^C

andy@drupal-tests-web:/var/www/html/core$

I'll also leave a screenshot version in case people prefer reading with the color-coded outputs:

Screenshot 2023-04-13 at 1 37 49 PM
andy-blum commented 1 year ago

ddev debug test output here

star-szr commented 11 months ago

I'm seeing the same issue with other types of tests too (not just Nightwatch), and if you connect via noVNC you'll likely see the browser still sitting there waiting (or you may just see the desktop wallpaper if the browser crashed).

My knowledge and experience is not strong in this area but would adding a health check help? If I can find some time, I will look into that.

weitzman commented 11 months ago

If anyone finds out whats happenning here, I'm all ears.