ddev-contrib icon indicating copy to clipboard operation
ddev-contrib copied to clipboard

drupalci-chromedriver recipe does not work on arm64 (Mac M1/Apple Siliicon)

Open smustgrave opened this issue 2 years ago • 14 comments

Following the setup on https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/drupalci-chromedriver I get the following error

  1. Drupal\Tests\system\FunctionalJavascript\System\DateFormatTest::testDateFormatXss The test wasn't able to connect to your webdriver instance. For more information read core/tests/README.md.

The original message while starting Mink: Could not open connection: 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.) (Driver info: chromedriver=98.0.4758.102 (273bf7ac8c909cde36982d27f66f3c70846a3718-refs/branch-heads/4758@{#1151}),platform=Linux 5.10.47-linuxkit x86_64)

/var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:55 /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:381 /var/www/html/web/core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php:29 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:703

Don't know how to proceed any help would be appreciated (@mglaman or @heddn tagging you as the authors on that page)

I'm on a macbook with the M1 chip if that matters.

smustgrave avatar Jun 01 '22 01:06 smustgrave

M1 matters a lot, as the recipe you're using doesn't have amd64 images. (chromedriver doesn't have amd64, only chromium). See https://github.com/drud/ddev/issues/3578 for a path.

rfay avatar Jun 01 '22 03:06 rfay

So I added

`webimage_extra_packages:

  • chromium
  • chromium-driver` to my config.yml file

phpunit.xml

<php> <!-- Set error reporting to E_ALL. --> <ini name="error_reporting" value="32767"/> <!-- Do not limit the amount of memory tests take to run. --> <ini name="memory_limit" value="-1"/> <!-- Example SIMPLETEST_BASE_URL value: http://localhost --> <env name="SIMPLETEST_BASE_URL" value="http://drupal9-ddev.ddev.site"/> <!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix --> <env name="SIMPLETEST_DB" value="sqlite://localhost//tmp/drupal9-ddev.test.sqlite"/> <!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output --> <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="./docroot/sites/simpletest/browser_output"/> <!-- To have browsertest output use an alternative base URL. For example if SIMPLETEST_BASE_URL is an internal DDEV URL, you can set this to the external DDev URL so you can follow the links directly. --> <env name="BROWSERTEST_OUTPUT_BASE_URL" value="http://drupal9-ddev.ddev.site"/> <!-- To disable deprecation testing completely uncomment the next line. --> <!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> --> <!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' --> <env name="MINK_DRIVER_CLASS" value=""/> <!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' --> <env name="MINK_DRIVER_ARGS" value=""/> <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> <env name="MINK_DRIVER_ARGS_WEBDRIVER" value="['chrome', {'browserName':'chrome','chromeOptions':{'args':['--disable-gpu','--disable-dev-shm-usage','--headless','--no-sandbox','--window-size=1920,1080']}}, 'http://localhost:9515']"/> <!-- Drupal Test Traits --> <env name="DTT_BASE_URL" value="http://drupal9-ddev.ddev.site"/> <env name="DTT_API_URL" value="http://localhost:9222"/> <env name="DTT_MINK_DRIVER_ARGS" value="['chrome', {'browserName':'chrome','chromeOptions':{'args':['--disable-gpu','--disable-dev-shm-usage','--headless','--no-sandbox','--window-size=1920,1080']}}, 'http://localhost:9515']"/> <!-- @todo This should not be necessary, but Drupal Test Traits currently throw a lot of deprecation warnings which make test jobs fail in CI. --> <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> </php>

Installed the following "require-dev": { "drupal/core-dev": "^9.5", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", "weitzman/drupal-test-traits": "^1.5" },

When I try and run

ddev exec phpunit --verbose -c ./phpunit-phpstorm.xml web/core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php

I get

  1. Drupal\Tests\system\FunctionalJavascript\System\DateFormatTest::testDateFormatXss The test wasn't able to connect to your webdriver instance. For more information read core/tests/README.md.

The original message while starting Mink: Could not open connection: Curl error thrown for http POST to http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"browserName":"firefox","name":"Behat Test"}}

Failed to connect to localhost port 4444: Connection refused

/var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:55 /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:381 /var/www/html/web/core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php:29 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

Not even using my config it seems

smustgrave avatar Jun 01 '22 14:06 smustgrave

Your webdriver has crashed because it's amd64 and can't run on arm64. "The test wasn't able to connect to your webdriver instance". You can see the crash with ddev logs chromedriver

rfay avatar Jun 01 '22 14:06 rfay

Any suggestions or am I just out of luck right now until wider support for the new M1 happens?

smustgrave avatar Jun 01 '22 14:06 smustgrave

Please do go look at https://github.com/drud/ddev/issues/3578

rfay avatar Jun 01 '22 15:06 rfay

I use linux/amd64, so I won't be much help here.

heddn avatar Jun 01 '22 15:06 heddn

@heddn no worries thank you though!

@rfay tried following the steps from https://github.com/drud/ddev/issues/3578#issuecomment-1039898468 but no luck. If you have a consolidated list of tricks it would be appreciated.

Trying to be a good Drupal contributor and right functional javascript files but can't seem to get a chromedriver working

smustgrave avatar Jun 01 '22 15:06 smustgrave

I've spent a lot of time with this, and built a new multiplatform chromium image for use (https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/headless-chrome) but the Drupal community here hasn't stepped up to adjust to use it. The most knowledgable person I know is @stborchert in https://github.com/drud/ddev/issues/3578#issuecomment-1039898468 - please follow up there. He has also promised to write up the whole recipe.

rfay avatar Jun 01 '22 15:06 rfay

Please follow up in that issue, not here. Thanks.

rfay avatar Jun 01 '22 17:06 rfay

@rfay I FINALLY got it working. I would like to document how for future users. Where would it best go?
Edit the config file Custom command Phpunit.xml example

smustgrave avatar Jun 29 '22 01:06 smustgrave

How about a ddev-get add-on (see https://github.com/drud/ddev-addon-template)? That would be awesome! Otherwise, a PR here in ddev-contrib. I'd love you to do it as an add-on, where it can be properly maintained over the long term.

rfay avatar Jun 29 '22 01:06 rfay

Cool I'll take a look. Hopefully eventually drupalci chromeDriver catches up

Since this doesn't have its own docker-compose file would that work as an add on?

smustgrave avatar Jun 29 '22 02:06 smustgrave

Let's find out who maintains that and see if we can figure out how to influence it.

rfay avatar Jun 29 '22 02:06 rfay

Except... it can't use Chrome at this time, as there are no chrome arm64 packages, only Chromium.

rfay avatar Jun 29 '22 02:06 rfay