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

Use headless Chrome for browser tests #447

Merged
merged 10 commits into from
Apr 10, 2018
Merged

Conversation

vbrown608
Copy link
Collaborator

@vbrown608 vbrown608 commented Apr 9, 2018

Loading the react and react-ujs packages requires loading ES6 syntax, which isn't supported by our current webdriver (capybara-webpack) or the one we're using on the Action Center (poltergeist). This PR switches SEC to use headless Chrome, which would allow us to write JS tests for the admin interface (ex #198) and add React to the user-facing site without breaking the existing JS tests.

This is working smoothly except within Docker, where there are two problems

  1. The version of chromium-chromedriver packaged for Alpine is buggy - we need a newer version. It's probably possible to do a manual install instead of using the package.
  2. Chrome/Chromium needs to make syscalls that are not allowed by the default Docker seccomp config. Jesse Frazelle has a blog about it here and links to a seccomp profile that can be used with Chrome/Chromium here. Seems like a lot of people are using it to run headless Chrome in Docker.

Options I see are

  1. Update our current Dockerfile to manually install the chromedriver and update docker-compose.yml.example to suggest the Chrome seccomp outside production.
  2. Try to use someone else's headless Chrome container and let selenium connect to Chrome over a port. That would keep some messiness out of the SEC application container.
  3. Not support this in Docker, since I don't think any of us is doing development in Docker anymore.

@wioux
Copy link
Member

wioux commented Apr 9, 2018

I like option (2) and I think it'd keep techops happy as well. Ben and I discussed a related issue to this the other day, which was rendering PDFs from a headless chrome process running in a separate container. He was concerned about xvfb being included in the app container so I think if we add chromium too there'll be the same concern and we'll eventually need to pull it out.

The tests for supporters.eff.org work this way and we have a Dockerfile for chrome headless in kittens at tests/Dockerfile.google-chrome.

For problem (1) -- I'm not sure whether you tried it but when I was working on the PDF issue I used the chromedriver-helper gem to install chromedriver and that seemed to work well.

Runs chrome with the --no-sandbox flag in order to pass tests in Travis, as
mentioned in
travis-ci/travis-ci#8836 (comment)

The additional changes to spec/rails_helper.rb in this commit are just to
reproduce the behavior of the predefined :selenium_chrome_headless driver.
@vbrown608
Copy link
Collaborator Author

vbrown608 commented Apr 10, 2018

The chromdriver-helper gem is nice. I switched it in for tests run on the host and on Travis, thanks! It doesn't work within the Alpine container for the reason described here: flavorjones/chromedriver-helper#48 (comment)

I'd like to revisit Docker support as a separate ticket.

@vbrown608 vbrown608 changed the title WIP use headless Chrome for browser tests Use headless Chrome for browser tests Apr 10, 2018
@wioux wioux merged commit 514baad into master Apr 10, 2018
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.

2 participants