Closed chrisroane closed 2 years ago
Hey @chrisroane!
Wowzers! Those are some heavy duty files!
I've definitely gotten Pantheon/Behat to work in a much simpler setup, but I usually add in Chromedriver or PhantomJS in an extra container to make this work.
This exact thing is going to be our next major focus after we firm up this next release. Aaron Wolfe at Capellic and I have been discussing Behat JS tests a lot lately using Lando and Pantheon and we finally got a dialed setup that uses Chromedriver to handle the control of the browser (so it can access JS and handle sessions). I'd suggest hopping into the #lando channel in our slack instance (https://launchpass.com/kalabox) and pinging @Aaron
to discuss. I have a good example for Laravel Dusk which I'll share to give you an idea, but Behat's config is obviously a little different:
https://gist.github.com/dustinleblanc/c49b020419e70f70b40353b3d05a9735
@dustinleblanc Thanks for your response.
After many hours in trying to get something to work, I finally came up with a solution that seems to work well. This is what I did:
imports:
- behat.yml
default:
suites:
default:
contexts:
- MedstatFeatureContext
- MedstatDrupalContext
- MedstatRestfulContext:
base_url: 'https://192.168.1.17:32811'
files_path: '%paths.base%/tests/assets'
api_role: 'api write client'
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Drupal\MinkExtension:
base_url: 'https://192.168.1.17:32811'
selenium2:
wd_host: 'http://192.168.1.17:4444/wd/hub'
capabilities:
browser: 'chrome'
browserVersion: '65.0.3325.146'
extra_capabilities:
selenium-version: '3.10.0'
screenResolution: '1920x1600'
tz: 'America/New_York'
recordVideo: 'true'
Drupal\DrupalExtension:
drupal:
drupal_root: '/app/build'
drush:
root: '/app/build'
Bex\Behat\ScreenshotExtension:
image_drivers:
local:
screenshot_directory: /app/tests/behat_screenshots
The only minor annoyance with this is that when I reboot the lando box the ports change + if I change local networks my host computer ip address changes. I tried many different combinations with urls and the only thing I could get work was using the host ip directly.
If you have any ideas in what I could use in my local.behat.yml file to make this work without having to use the host ip + lando port, that would be appreciated.
I'm sure there is a more integrated way I could get this setup using docker compose, and I may play with that again at some point, but this is what we got working for the time being and it seems to work well enough for now. Your laraval example provides some good insight in what I can try next. :)
Hey @chrisroane
Wow yeah that still looks more complex than I'd want to deal with.
I think the reason you need to use the randomly changing port business is precisely that you aren't using an integrated docker-compose.yml
file.
Doing it the way I did adds the chromedriver container to the network of your app, giving both chromedriver and php access to the same internal network being set up by docker compose.
I think if you just refactor that to use the container within a docker-compose file, that gets included in the .lando.yml, you will have all the internal networking magic needed to just use the service hostnames.
@chrisroane Here are my files. Maybe they will help. behat.yml
#
# behat.yml file for testing on Pantheon.
#
default:
suites:
default:
paths:
- %paths.base%/features
contexts:
- FeatureContext
- ClientHelperContext
- ClientContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
files_path: "%paths.base%/features/fixtures/"
base_url: http://nginx
browser_name: chrome
sessions:
default:
goutte:
guzzle_parameters:
verify: false
javascript:
selenium2:
wd_host: http://chromedriver:4444/wd/hub
Bex\Behat\ScreenshotExtension:
image_drivers:
local:
screenshot_directory: /app/tmp
clear_screenshot_directory: false
screenshot_taking_mode: failed_scenarios
Drupal\DrupalExtension:
drupal:
drupal_root: '/app/web'
blackbox: ~
region_map:
system: '.region-system'
horizontaltabs: '.horizontal-tabs'
activetab: '.horizontal-tabs-pane:not(.horizontal-tab-hidden)'
header: '.top-nav'
footertop: '.footer-top'
footerbottom: '.footer-bottom'
api_driver: 'drupal'
lando.yml
name: client
recipe: pantheon
compose:
- docker-compose.yml
config:
framework: drupal8
env: dev
site: client
id: 3913120e-xxxxx-46ce-a987-xxxxx
web: web
xdebug: false
events:
post-db-import:
- appserver: cd $LANDO_MOUNT && composer install
services:
appserver:
extras:
- "apt-get update"
- "apt-get install -y apt-utils"
- "curl -sL https://deb.nodesource.com/setup_6.x | bash"
- "apt-get install -y nodejs"
- "npm install --global gulp-cli"
build:
- "cd $LANDO_MOUNT && cd web/themes/custom/client/patternlab && composer install"
- "cd $LANDO_MOUNT && cd web/themes/custom/client && npm install"
- "cd $LANDO_MOUNT && cd web/themes/custom/client && gulp build"
- "cd $LANDO_MOUNT && cd web/themes/custom/client && gulp translate"
overrides:
services:
environment:
BEHAT_PARAMS: >-
{"extensions" : {"Behat\\MinkExtension" : {"base_url" :
"http://nginx/", "files_path" : "/app/web/tests/features/fixtures/"}, "Drupal\\DrupalExtension" : {"drush" : {
"root": "/app/web" }}}}
CI_ENV: ci-${CIRCLE_BUILD_NUM}
PANTHEON_SITE: ${TERMINUS_SITE}
CIRCLE_BRANCH: ${CIRCLE_BRANCH}
CIRCLE_USERNAME: ${CIRCLE_USERNAME}
GIT_EMAIL: ${GIT_EMAIL}
tooling:
phplint:
service: appserver
cmd: /app/vendor/bin/phplint
phpcs:
service: appserver
cmd: /app/vendor/bin/phpcs
phpunit:
service: appserver
cmd: /app/vendor/bin/phpunit
behat:
service: appserver
cmd: /app/vendor/bin/behat
docker-compose.yml
version: '3'
services:
chromedriver:
image: robcherry/docker-chromedriver:latest
volumes:
- ${LANDO_APP_ROOT}/:/app/
expose:
- "4444"
environment:
CHROMEDRIVER_WHITELISTED_IPS: ""
CHROMEDRIVER_URL_BASE: "/wd/hub"
security_opt:
- seccomp:unconfined
Thanks everyone! I'll give this a shot this week. This is all great. This clears up some things in using docker compose that I couldn't figure out from the docs. But I'm a docker noob and might be missing some basic info. :)
Awesome @chrisroane! Join us in the slack instance, its a great place to fire off some questions and share ideas as you go.
I'm getting a similar error when trying to run Behat to reach the url of one of my multisites. I'm hosted on Acquia not Pantheon. My local does not use nginx so I'm not sure what my base_url
should be.
Given I am on "/" # Drupal\DrupalExtension\Context\MinkContext::visit()
GuzzleHttp\Exception\ConnectException: cURL error 7: Failed to connect to naswa.lndo.site port 443: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in /app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185
@brooke-heaton with no nginx the appserver is typically your serving container, so http://appserver
is a good assumption. Since you have Multi-site, that's probably going to screw with things in a big way.
I'm getting this curl error when I try to run a simple test: https://www.dropbox.com/s/v19nda8c6vsrijw/Screenshot%202018-03-04%2016.44.06.png?dl=0
I searched the issue queue and the web with no luck. I was able to get a simple behat test running in lando using the vanilla drupal7 recipe, but I can't get it to work on this client site.
Here is the command I am using to run this test:
.lando.yml
behat.yml
Any tips you can give me in helping me get this to work? This is my first time using lando on a client project and I love everything about this project! Thanks for the help.