Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHPUnit invalid cookie domain and failing Nightwatch test #76

Merged
merged 6 commits into from
May 26, 2023
Merged

Fix PHPUnit invalid cookie domain and failing Nightwatch test #76

merged 6 commits into from
May 26, 2023

Conversation

gitressa
Copy link
Contributor

@gitressa gitressa commented Nov 6, 2022

Fixes: #70. Issue with failing test and WebDriver\Exception\InvalidCookieDomain: invalid cookie domain message error message. This update looks like it makes both PHPUnit and Nightwatch work.

New configuration kindly shared by @neclimdul in lando/lando#3411 (comment).

  • To Do: Test with D9 branch, and if it works apply there as well. Does it need a separate MR?

After the update

PHPUnit Olivero test

$ lando phpunit --group olivero
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing 
.........SS                                                       11 / 11 (100%)

Time: 04:28.872, Memory: 337.00 MB

OK, but incomplete, skipped, or risky tests!
Tests: 11, Assertions: 45, Skipped: 2.

HTML output was generated
https://drupal-contributions.lndo.site/sites/simpletest/browser_output/Drupal_FunctionalTests_Theme_OliveroTest-1-85693154.html
https://drupal-contributions.lndo.site/sites/simpletest/browser_output/Drupal_FunctionalTests_Theme_OliveroTest-2-82886258.html
[...]

PHPUnit Password Hashing test

$ lando phpunit web/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\Core\Password\PasswordHashingTest
.........                                                           9 / 9 (100%)

Time: 00:00.024, Memory: 10.00 MB

OK (9 tests, 19 assertions)

Nightwatch example test

$ cd web/core/
$ lando 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 chrome on port 9515 (138ms).
  Using: chrome (106.0.5249.103) on LINUX.

  ℹ Loaded url http://appserver in 82ms

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

  ✨ PASSED. 2 assertions. (310ms)

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

  ✨ PASSED. 3 assertions. (167ms)

  ✨ PASSED. 5 total assertions (3.142s)
 Wrote HTML report file to: /app/web/core/reports/nightwatch/nightwatch-html-report/index.html

Done in 10.14s.

Nightwatch Olivero test

$ cd web/core/
$ lando nightwatch --tag olivero

  ℹ Loaded url http://drupal-contributions.lndo.site/user/reset/1/1682500376/WmeOV8GaBUGJa70coru0vEtQD9oyeZ60Lapajlh8A4c/login
 in 761ms

  [...]

  ✔ Testing if element <#block-olivero-main-menu> is visible (30ms)
  ✔ Testing if attribute 'aria-checked' of element <button.sticky-header-toggle> equals 'true' (21ms)

  ✨ PASSED. 9 assertions. (2.465s)

  ✨ PASSED. 180 total assertions (3m 10s)
 Wrote HTML report file to: /app/web/core/reports/nightwatch/nightwatch-html-report/index.html

Done in 199.20s.

@gitressa
Copy link
Contributor Author

gitressa commented Nov 7, 2022

I had updated DRUPAL_TEST_BASE_URL: 'http://appserver' to DRUPAL_TEST_BASE_URL: 'https://drupal-contributions.lndo.site/' because it looked more correct, but it doesn't work. So I have reverted that in the MR :-)

.lando.yml Outdated
@@ -21,7 +21,7 @@ services:
SIMPLETEST_DB: "sqlite://localhost/tmp/db.sqlite"
BROWSERTEST_OUTPUT_DIRECTORY: '/app/web/sites/simpletest/browser_output'
BROWSERTEST_OUTPUT_BASE_URL: 'https://drupal-contributions.lndo.site'
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chrome:9515"]'
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chromedriver:9515"]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't DRUPAL_TEST_WEBDRIVER_HOSTNAME be changed too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the change from http://chrome:9515 to http://chromedriver:9515 you mean? It might not be correct ... I just assumed that since the tests worked, this was the right set up.

But what would you suggest to update it to? Do you ask because you tried the patch and it didn't work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong.
With the given configuration, the DRUPAL_TEST_WEBDRIVER_HOSTNAME value is the right one because the chrome driver container is reachable using the chrome hostname. This value is used for nightwatch tests which seem to ignore cookie domain issues.

The real problem is that the WebDriverTestBase tests are still not working because they cannot find the chromedriver service at the http://chromedriver:9515 URL. That's why they appear as skipped in the PHPUnit report.

So, if we use http://chromedriver:9515 the test is skipped because it cannot reach the driver and if we use http://chrome:9515 which is the appropriate URL with the current lando configuration, the test fails because of the cookie domain error...

When trying to understand what's happening inside the chromedriver service, I can see the following trace (in /tmp/chromedriver.log):

[1668781158.148][INFO]: [fe198b47912849d98bcf4c66f13b4b93] RESPONSE GetUrl "https://drupal-contributions.lndo.site/"
[1668781158.148][INFO]: [fe198b47912849d98bcf4c66f13b4b93] COMMAND AddCookie {
   "cookie": {
      "domain": "drupal-contributions.lndo.site",
      "expires": 1668861158,
      "name": "SIMPLETEST_USER_AGENT",
      "secure": false,
      "value": "simpletest20588224%3A1668781158%3A63779466232a65.73180091%3ABGYNVRC51qyN8Ch_xyVlXDJwHb1XmKrfcCbgQWiUsa4"
   }
}

That helped me to understand that we are requesting https but the cookie is set with "secure": false so that means that somehow Drupal doesn't understand he is serving secure content.

If we replace SIMPLETEST_BASE_URL by an http URL, the tests are working again!... but most of them are failing T_T

I had to dig a lot more to understand why the chromedriver was crashing despite the --no-sandbox option you added. As usual, the answer came from stackoverflow and was talking about the /dev/shm partition size. The easiest way to fix it seem to be mounting it as a volume linked to the host machine partition.

In the end I finally found a way to run the tests with the following changes only:

  1. changing both SIMPLETEST_BASE_URL and BROWSERTEST_OUTPUT_BASE_URL to http
        SIMPLETEST_BASE_URL: "http://drupal-contributions.lndo.site/"
...
        BROWSERTEST_OUTPUT_BASE_URL: 'http://drupal-contributions.lndo.site'
  1. adding a volume on the chrome service:
  chrome:
    type: compose
    app_mount: false
    services:
      image: drupalci/webdriver-chromedriver:production
      volumes:
        - /dev/shm:/dev/shm
      command: chromedriver --log-path=/tmp/chromedriver.log --allowed-origins=* --verbose --whitelisted-ips=

Now, all tests are working \o/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the chromedriver hosts are because that's what I named my service but drupal-contributions uses chrome for the service so they should be converted.

As far as the sandbox stuff, that's interesting. I wonder if its environment specific because I was getting similar errors with --no-sandbox being needed but not solving the whole shared memory thing but the SO search ended with me adding the seccomp:unconfined line which fixed it on my machine. I guess you may need one of the other depending on system configuration but I can't see a problem with adding both. Well, other then the fact both are turning off container protections but I think that's going to be the price of doing business with chrome.

Copy link
Contributor Author

@gitressa gitressa Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great detective work @DuaelFr, and thanks for chiming in @neclimdul.

It would be great if you two could work out the best solution, and eventually share the optimal .lando.yml here, so that I can update the MR with that set up.

@mparker17
Copy link

mparker17 commented Jan 2, 2023

For what it's worth, I had to work through this problem to get a FunctionalJavascript test working this week - this thread was really helpful - and ultimately came up with the following changes that I had to make...

An explanation of the changes:

  1. Running PHPUnit would often generate a /.phpunit.result.cache which I ignored. We may want to copy this to other branches as well.
  2. I had to set composer_version: '2.3.6' because Drupal 10.0.0 requires at least Composer 2.3.6, but Lando's current drupal10 recipe includes an older 2.2 version
  3. I had to change SIMPLETEST_BASE_URL and BROWSERTEST_OUTPUT_BASE_URL to plain HTTP to avoid certificate errors
  4. I changed the MINK_DRIVER_ARGS_WEBDRIVER environment variable and chrome service as described by @DuaelFr and @neclimdul above.

The following patch is based on commit 701faff i.e.: the HEAD of the 10.x branch at time-of-writing.

diff --git a/.gitignore b/.gitignore
index fe2a948..12fac38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ node_modules
 *.sql
 *.sql.gz
 *.gz
+/.phpunit.result.cache
diff --git a/.lando.yml b/.lando.yml
index 004f09b..b43e149 100644
--- a/.lando.yml
+++ b/.lando.yml
@@ -5,6 +5,7 @@ config:
 
 services:
   appserver:
+    composer_version: '2.3.6'
     build_as_root:
       # Note that you will want to use the script for the major version of node you want to install
       # See: https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
@@ -17,11 +18,11 @@ services:
       - yarn install --non-interactive --cwd /app/web/core
     overrides:
       environment:
-        SIMPLETEST_BASE_URL: "https://drupal-contributions.lndo.site/"
+        SIMPLETEST_BASE_URL: "http://drupal-contributions.lndo.site/"
         SIMPLETEST_DB: "sqlite://localhost/tmp/db.sqlite"
         BROWSERTEST_OUTPUT_DIRECTORY: '/app/web/sites/simpletest/browser_output'
-        BROWSERTEST_OUTPUT_BASE_URL: 'https://drupal-contributions.lndo.site'
-        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chrome:9515"]'
+        BROWSERTEST_OUTPUT_BASE_URL: 'http://drupal-contributions.lndo.site'
+        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515"]'
         # Nightwatch
         DRUPAL_TEST_BASE_URL: 'http://appserver'
         DRUPAL_TEST_DB_URL: 'mysql://drupal10:drupal10@database:3306/drupal10'
@@ -33,10 +34,18 @@ services:
         DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES: node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest
   chrome:
     type: compose
+    scanner: false
     app_mount: false
     services:
-      image: drupalci/webdriver-chromedriver:production
-      command: chromedriver --log-path=/tmp/chromedriver.log --allowed-origins=* --verbose --whitelisted-ips=
+      image: drupalci/chromedriver:production
+      expose:
+        - "9515"
+        - "4444"
+      volumes:
+        - /dev/shm:/dev/shm
+      security_opt:
+        - seccomp:unconfined
+      command: ["chromedriver",  "--log-path=/tmp/chromedriver.log", "--verbose", "--allowed-ips=", "--allowed-origins=*", "--whitelisted-ips="]
 
 tooling:
   drush:

@theMusician
Copy link
Contributor

It seems this gets it closer on the M1 based Mac but still doesn't work for M1 Apple devices. Exciting to see it inch closer. Glad it is working on other devices.

Here is the output:

lando 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
──────────────────────────────────────────────────────────────
⚠ Failed to connect to Selenium Server on chrome with port 9515.

───────────────────────────────────────────────────────────────────────────────────────────────────

  ️TEST FAILURE (4.076s):
   - 1 error during execution;
   - 0 tests failed;
   - 0/NA tests passed
   - 2 skipped

   ✖ 1) Tests/exampleTest

  - OTHER ERRORS:

  1)  An error occurred while creating a new Selenium Server session: [WebDriverError] 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=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Linux 5.10.47-linuxkit x86_64)
    SKIPPED:
    - Test page
    - Page objects test page

 Wrote HTML report file to: /app/web/core/reports/nightwatch/nightwatch-html-report/index.html

error Command failed with exit code 5.

The HTML file it wrote has the following in the raw log:


  Request POST http://chrome:9515/session  
{
     desiredCapabilities: {
       browserName: 'chrome',
       acceptSslCerts: true,
       'goog:chromeOptions': {
         w3c: false,
         args: [ '--disable-gpu', '--headless', '--no-sandbox' ]
       },
       name: 'Tests/Example Test'
     },
     capabilities: {
       alwaysMatch: {
         browserName: 'chrome',
         'goog:chromeOptions': {
           w3c: false,
           args: [ '--disable-gpu', '--headless', '--no-sandbox' ]
         }
       }
     }
  }
  Response 200 POST http://chrome:9515/session (2277ms)
{
     sessionId: '772234545b07bdd2e1c3ce45af5aca1c',
     status: 13,
     value: {
       message: 'unknown error: Chrome failed to start: crashed.\n' +
         "  (unknown error: DevToolsActivePort file doesn't exist)\n" +
         '  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n' +
         '  (Driver info: chromedriver=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Linux 5.10.47-linuxkit x86_64)'
     }
  }

@gitressa
Copy link
Contributor Author

gitressa commented Feb 13, 2023

Thanks @neclimdul, @DuaelFr and @mparker17, your suggested solution works well, and I have updated the MR.

Some Nightwatch tests were working well, such as tests/Drupal/Nightwatch/Tests/exampleTest.js, but running lando nightwatch --tag olivero would yield several errors, which are fixed with this patch.

@mparker17: Possibly use composer_version: 2-latest in stead? (#78).

@gitressa gitressa changed the title Fix PHPUnit invalid cookie domain Fix PHPUnit invalid cookie domain and failling Nightwatch test Feb 13, 2023
@gitressa gitressa changed the title Fix PHPUnit invalid cookie domain and failling Nightwatch test Fix PHPUnit invalid cookie domain and failing Nightwatch test Feb 13, 2023
@xurizaemon
Copy link
Contributor

xurizaemon commented Feb 28, 2023

Hey @gitressa, thanks for this PR, some feedback on it.

Is /dev/shm Linux specific? Does that exist for Windows or Mac users? We should ensure this gets tested by someone not using Linux IMO. I'm concerned that volume mounting shared memory into the container is risky. Chrome has a --disable-dev-shm-usage flag which should work equally well to avoid shared memory exhaustion, I suggest adding that to chrome.services.command array. Likewise I'd like to know what the security_opt: seccomp:unconfined change is actually doing before we accept it.

Nitpick: I don't think b9a8b06 belongs in this PR.

@xurizaemon
Copy link
Contributor

xurizaemon commented Feb 28, 2023

I tested with this set of changes using --disable-dev-shm-usage proposed above, and that nightwatch test passed for me. This does not require the security or shared memory changes from this PR currently. @gitressa would you consider testing this approach please, and update your PR if that works too? It feels safer ...

The composer self-update and drupal10 changes don't live in this PR though - that's in #78 / #75.

I'm not sure if Github lets me propose changes to your PR so I'm just pasting the diff here to show :)

diff --git a/.lando.yml b/.lando.yml
index 473b225..e5b0c42 100644
--- a/.lando.yml
+++ b/.lando.yml
@@ -1,5 +1,5 @@
 name: drupal-contributions
-recipe: drupal9
+recipe: drupal10
 config:
   webroot: web
 
@@ -12,18 +12,19 @@ services:
       - apt-get install -y nodejs
       - npm install --global yarn
     run:
+      - composer self-update
       - cd /app/web && composer require drush/drush && composer install
       - mkdir -p private/browsertest_output
       - yarn install --non-interactive --cwd /app/web/core
     overrides:
       environment:
-        SIMPLETEST_BASE_URL: "https://drupal-contributions.lndo.site/"
+        SIMPLETEST_BASE_URL: "http://drupal-contributions.lndo.site/"
         SIMPLETEST_DB: "sqlite://localhost/tmp/db.sqlite"
         BROWSERTEST_OUTPUT_DIRECTORY: '/app/web/sites/simpletest/browser_output'
-        BROWSERTEST_OUTPUT_BASE_URL: 'https://drupal-contributions.lndo.site'
-        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chrome:9515"]'
+        BROWSERTEST_OUTPUT_BASE_URL: 'http://drupal-contributions.lndo.site'
+        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515"]'
         # Nightwatch
-        DRUPAL_TEST_BASE_URL: 'http://appserver'
+        DRUPAL_TEST_BASE_URL: 'http://drupal-contributions.lndo.site'
         DRUPAL_TEST_DB_URL: 'mysql://drupal9:drupal9@database:3306/drupal9'
         DRUPAL_TEST_WEBDRIVER_HOSTNAME: chrome
         DRUPAL_TEST_WEBDRIVER_PORT: 9515
@@ -35,14 +36,17 @@ services:
     type: compose
     app_mount: false
     services:
-      image: drupalci/webdriver-chromedriver:production
-      command: chromedriver --log-path=/tmp/chromedriver.log --allowed-origins=* --verbose --whitelisted-ips=
+      image: drupalci/chromedriver:production
+      expose:
+        - "9515"
+        - "4444"
+      command: ["chromedriver",  "--allowed-ips=", "--allowed-origins=*", "--whitelisted-ips=", "--disable-dev-shm-usage"]
 
 tooling:
   drush:
     service: appserver
     cmd:
-      web/vendor/drush/drush/drush --root=/app/web --uri=https://drupal-contributions.lndo.site
+      web/vendor/drush/drush/drush --root=/app/web --uri=http://drupal-contributions.lndo.site
   si:
     service: appserver
     description: Install Drupal
$ lando 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 chrome on port 9515 (159ms).
  Using: chrome (106.0.5249.103) on LINUX.

  ℹ Loaded url http://drupal-contributions.lndo.site in 1275ms

  Running Test page:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ℹ Loaded url http://drupal-contributions.lndo.site/test-page in 254ms
  ✔ Element <body> was visible after 31 milliseconds.
  ✔ Testing if element <body> contains text 'Test page text' (26ms)

  ✨ PASSED. 2 assertions. (368ms)

  Running Page objects test page:
───────────────────────────────────────────────────────────────────────────────────────────────────
  ℹ Loaded url http://drupal-contributions.lndo.site/test-page in 43ms
  ✔ Element <body> was visible after 26 milliseconds.
  ✔ Testing if element <Element [name=@body]> contains text 'Test page text' (23ms)
  ✔ Ensuring no deprecation errors have been triggered (7ms)

  ✨ PASSED. 3 assertions. (165ms)

  ✨ PASSED. 5 total assertions (4.598s)
 Wrote HTML report file to: /app/web/core/reports/nightwatch/nightwatch-html-report/index.html

Done in 12.22s.

I tried removing the https => http change but that didn't fly for me.

@gitressa
Copy link
Contributor Author

Thanks xurizaemon. I am merely copy-pasting suggestions at this point, so about /dev/shm I think @neclimdul, @DuaelFr or @mparker17, should feel free to weigh in, and I'll update the MR.

About b9a8b06: Yes, I have removed it.

I see you use composer self-update. Is it better than composer_version: 2-latest?

I'll try your suggestion later, and see if it works in Linux.

@xurizaemon
Copy link
Contributor

I see you use composer self-update. Is it better than composer_version: 2-latest?

That was just me being lazy! I think your proposed fix in #78 is better.

I'll try your suggestion later, and see if it works in Linux.

FWIW I'm testing in Linux.

@gitressa
Copy link
Contributor Author

Ah, thanks for clearing that up :)

I tried the changes, and these tests work (Ubuntu 20.04):

  • lando phpunit web/core/tests/Drupal/Tests/Core/Password/PasswordHashingTest.php
  • lando nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js

The Olivero test works with the current patch, but fails with your updates:

  • lando nightwatch --tag olivero

Maybe you can check if the Olivero test works for you?

@agarzola
Copy link

Like @theMusician, I have struggled to get tests running on an M1 chip-powered mac. I found a solution, but I don’t know what the correct way to implement it is.

Searching for chromedriver docker apple m1 and found this Reddit comment. Based on that comment, here is a patch that allows me to run tests:

diff --git a/.lando.yml b/.lando.yml
index 004f09b..265f40b 100644
--- a/.lando.yml
+++ b/.lando.yml
@@ -35,8 +35,17 @@ services:
     type: compose
     app_mount: false
     services:
-      image: drupalci/webdriver-chromedriver:production
-      command: chromedriver --log-path=/tmp/chromedriver.log --allowed-origins=* --verbose --whitelisted-ips=
+      image: seleniarm/standalone-chromium:102.0.5005.61
+      environment:
+        START_XVFB: 'false'
+        SE_NODE_MAX_SESSIONS: 5
+        JAVA_OPTS: "-XX:ActiveProcessorCount=5"
+        SE_NODE_OVERRIDE_MAX_SESSIONS: 5
+      expose:
+        - 9515
+        - 4444
+      command: ["chromedriver",  "--allowed-ips=", "--allowed-origins=*", "--whitelisted-ips=", "--disable-dev-shm-usage"]
+
 
 tooling:
   drush:

Here’s a diff of my .lando.yml file compared to the current 10.x branch (701faff):

diff --git a/.lando.yml b/.lando.yml
index 004f09b..313cb21 100644
--- a/.lando.yml
+++ b/.lando.yml
@@ -5,6 +5,7 @@ config:
 
 services:
   appserver:
+    composer_version: 2-latest
     build_as_root:
       # Note that you will want to use the script for the major version of node you want to install
       # See: https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
@@ -17,11 +18,11 @@ services:
       - yarn install --non-interactive --cwd /app/web/core
     overrides:
       environment:
-        SIMPLETEST_BASE_URL: "https://drupal-contributions.lndo.site/"
+        SIMPLETEST_BASE_URL: "http://drupal-contributions.lndo.site/"
         SIMPLETEST_DB: "sqlite://localhost/tmp/db.sqlite"
         BROWSERTEST_OUTPUT_DIRECTORY: '/app/web/sites/simpletest/browser_output'
-        BROWSERTEST_OUTPUT_BASE_URL: 'https://drupal-contributions.lndo.site'
-        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chrome:9515"]'
+        BROWSERTEST_OUTPUT_BASE_URL: 'http://drupal-contributions.lndo.site'
+        MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515"]'
         # Nightwatch
         DRUPAL_TEST_BASE_URL: 'http://appserver'
         DRUPAL_TEST_DB_URL: 'mysql://drupal10:drupal10@database:3306/drupal10'
@@ -35,14 +36,23 @@ services:
     type: compose
     app_mount: false
     services:
-      image: drupalci/webdriver-chromedriver:production
-      command: chromedriver --log-path=/tmp/chromedriver.log --allowed-origins=* --verbose --whitelisted-ips=
+      image: seleniarm/standalone-chromium:102.0.5005.61
+      environment:
+        START_XVFB: 'false'
+        SE_NODE_MAX_SESSIONS: 5
+        JAVA_OPTS: "-XX:ActiveProcessorCount=5"
+        SE_NODE_OVERRIDE_MAX_SESSIONS: 5
+      expose:
+        - 9515
+        - 4444
+      command: ["chromedriver",  "--allowed-ips=", "--allowed-origins=*", "--whitelisted-ips=", "--disable-dev-shm-usage"]
+
 
 tooling:
   drush:
     service: appserver
     cmd:
-      web/vendor/drush/drush/drush --root=/app/web --uri=https://drupal-contributions.lndo.site
+      web/vendor/drush/drush/drush --root=/app/web --uri=http://drupal-contributions.lndo.site
   si:
     service: appserver
     description: Install Drupal

I hope this helps anyone trying to run tests against the 10.x branch via Lando on an M1-powered mac.

@WWU-MaxBronsema
Copy link

Thank you for posting @agarzola. I'll give this a try with the latest Lando release in the near future. Very exciting to hear you got it running. An image that works with this Apple Silicon seems to be the missing piece. Thank you to you and Reddit!

@theMusician
Copy link
Contributor

@agarzola - your changes worked for me on an M1 as well. Nightwatch, PHP unit, hooray!

Tests also seem to run faster than ever.

I am still using v3.6.4 of Lando.

@mortona42
Copy link

I had to change DRUPAL_TEST_BASE_URL to http://drupal-contributions.lndo.site, and set composer_version: 2-latest.

- Updates `DRUPAL_TEST_BASE_URL` to http://drupal-contributions.lndo.site.
- Adds `composer_version: 2-latest` to get the latest Composer version for Drupal 10 support.
@gitressa
Copy link
Contributor Author

Thanks @mortona42 I have updated the merge request, and both PHPUnit and NightWatch tests work well.

There's already #78 (fixes #69), but having a single patch here, which makes tests work in Drupal 10 is easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants