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

fixes #21592 - uses headless chrome instead of phantomjs #4987

Closed
wants to merge 1 commit into from

Conversation

ohadlevy
Copy link
Member

@ohadlevy ohadlevy commented Nov 7, 2017

it seems that we can also cut down the default waiting time
which hopefully will speed up our tests.

@theforeman-bot
Copy link
Member

Issues: #21592

waldenraines
waldenraines previously approved these changes Nov 7, 2017
Copy link

@waldenraines waldenraines left a comment

Choose a reason for hiding this comment

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

Nice change, approved pending green tests.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017

@mmoll @ekohl any idea why the test fail? I'm installing chromedriver via npm (search from chromedriver in http://ci.theforeman.org/job/test_develop_pr_core/14979/database=postgresql,ruby=2.2,slave=fast/consoleFull) and I'm using the relative path at https://github.com/theforeman/foreman/pull/4987/files#diff-7a6aaeae51145fd37e71db58212fd18bR15) which of course works locally. how can I debug / troubleshoot this?

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

According to https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver it expects chrome to be in /usr/bin/google-chrome. You're just installing the driver and I think we need to look at a package installation of chrome. A quick search for RPMs doesn't show me any for centos7 so I'll need to dive into it. Since it's selenium it should also support firefox which may work better on centos7 slaves. Need to dive into it a bit to figure out our options.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017 via email

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

But the entire chrome browser isn't on NPM, only the chrome driver for selenium. One reason I can think of why chrome isn't packaged for EL7 is that it uses some kernel features for sandboxing that the EL7 kernel doesn't support, but this is speculation from my side. It may be that the Fedora packages do work. One path we can choose is to get Fedora slaves for the UI tests but I'd prefer to try a more generic solution first with Firefox.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017 via email

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

That would be my suggestion to start with. I have experience with using Firefox + Selenium on CentOS7 and generally that works well. If the setup code is generic enough we can support chrome via an env var for users who prefer that on their desktops.

Note that Firefox and xvfb are already installed on our slaves but the job config may need to be modified. Looks like the 1.11-stable job uses it.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017 via email

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

That makes total sense, but I haven't thought about it. We have a few priorities to balance no. I think that Rails 5.1 SCL + Updated Ruby is also a high priority blocker for developers but the fixing the Dynflow service for the 1.16 release is my top priority. Perhaps this is small enough to do it before the Rails 5.1 effort but I'll get back to you on that.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017

another option is to run it on travis - as its already configured to support chrome.
the main problem is that currently travis works on one language at a time (e.g. ruby or node) and not both.

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

Travis has matrix builds. See https://github.com/theforeman/puppet-foreman/blob/master/.travis.yml for how we use separate RVMs. Pretty sure you can choose a different language in the include.

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017 via email

@ekohl
Copy link
Member

ekohl commented Nov 8, 2017

It appears you're right: travis-ci/travis-ci#4090

@ehelms
Copy link
Member

ehelms commented Nov 8, 2017

The Travis configuration is already running node based tests. Where does the Ruby part come into play?

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017

@ehelms chrome integration tests run against the rails server.... you need to be able to execute rake jenkins:integration

@ehelms
Copy link
Member

ehelms commented Nov 8, 2017

One broader issue I will point out is that our current standard devel environment via Forklift is based on using CentOS 7 given that is the production RPM distro we support. This change would imply that developers could no longer run these tests within the local environment.

Has anyone tried installing the 'Fedora' only Chrome on EL7? From what I read, when they dropped it they dropped it intending to drop for EL6 but dropped it for all. Should be a fairly easy test on a Forklift environment to configure:

[google-chrome]
name=google-chrome - \$basearch
baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

Install chrome and try this PR out. If that works, then we can add this to our slaves no?

@ehelms
Copy link
Member

ehelms commented Nov 8, 2017

@ohadlevy ahh so these are for the older JS tests not the new ones coming with the React changes? Or even those requires a running Rails server?

@ohadlevy
Copy link
Member Author

ohadlevy commented Nov 8, 2017

ahh so these are for the older JS tests not the new ones coming with the React changes? Or even those requires a running Rails server?

this PR aim is to replace phantomjs with headless chrome- the motivation is to:

  1. reduce integeration test time
  2. use a more modern infrastructure - phantomjs seems like a less of an ideal tool today, we need polyfills etc as its emulated fairly older browsers.
    (I must admit I don't know if we have an official minimum browser defined anywhere).

regarding the tests itself:

  1. phatomjs and chrome are both doing full end to end tests using an automated browser - you require a
    full rails server.
  2. webpack based code tests (using jest) do not require a browser - they run purely in travis today using jsdom.

@ehelms
Copy link
Member

ehelms commented Nov 9, 2017

So testing this out, I was able to install Chrome on EL7 without issues (running the tests now) using that repository. From what I read, they "pulled" Chrome from EL6 due to incompatibility and in the process pulled it from all all EL despite it still working just fine.

Assuming tests pass, I'd opt for adding this repository to our slaves and allowing the use of Chrome here.

@ekohl
Copy link
Member

ekohl commented Nov 9, 2017

@ehelms I think that's fine.

@ohadlevy
Copy link
Member Author

@ehelms whats the next step ?

dLobatog added a commit to dLobatog/foreman-infra that referenced this pull request Nov 13, 2017
In order to use chrome headless with Selenium, and get rid of phantomjs.
For the moment, both can be installed to test theforeman/foreman#4987
When that PR is merged and we no longer need phantomjs and firefox, 
we can remove them on another PR.
dLobatog added a commit to dLobatog/foreman-infra that referenced this pull request Nov 13, 2017
In order to use chrome headless with Selenium, and get rid of phantomjs.
For the moment, both can be installed to test theforeman/foreman#4987
When that PR is merged and we no longer need phantomjs and firefox,
we can remove them on another PR.
Copy link
Member

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

@ohadlevy @ehelms @ekohl I think a good strategy to move forward is:

  • Installing chrome alongside firefox/phantomjs in our slaves
  • Making sure tests pass on Jenkins in this PR
  • Remove phantomjs/firefox

I've submitted theforeman/foreman-infra#381, as soon as that is merged please trigger the tests here again to see if they pass. I'd be thrilled to see a default_max_wait_time=5 working 😄

dLobatog added a commit to dLobatog/foreman-infra that referenced this pull request Nov 14, 2017
In order to use chrome headless with Selenium, and get rid of phantomjs.
For the moment, both can be installed to test theforeman/foreman#4987
When that PR is merged and we no longer need phantomjs and firefox,
we can remove them on another PR.
dLobatog added a commit to dLobatog/foreman-infra that referenced this pull request Nov 14, 2017
In order to use chrome headless with Selenium, and get rid of phantomjs.
For the moment, both can be installed to test theforeman/foreman#4987
When that PR is merged and we no longer need phantomjs and firefox,
we can remove them on another PR.
@mmoll
Copy link
Contributor

mmoll commented Jan 5, 2018

@ohadlevy a lot of tests fail and I have the feeling a lot of tests are run with this new configuration the first time after a long while... how can that be?

@dLobatog
Copy link
Member

[test foreman]

Copy link
Member

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

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

@ohadlevy I think this needs rebasing so tests pass, could you try that? Thanks!

@mmoll
Copy link
Contributor

mmoll commented Feb 17, 2018

rebased, no change.

@ohadlevy
Copy link
Member Author

@dLobatog @mmoll - can we upgrade the chrome version?

@mmoll
Copy link
Contributor

mmoll commented Mar 12, 2018

Currently not, as it was agreed to use the chromium version coming in EPEL.

@@ -213,6 +212,7 @@ def database_cleaner_strategy

def login_admin
SSO.register_method(TestSSO)
visit '/'
Copy link
Contributor

Choose a reason for hiding this comment

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

while this fixes some tests, some are also failing because of this (e.g. TEST=test/integration/fact_value_test.rb)

@mmoll
Copy link
Contributor

mmoll commented May 4, 2018

I think the changes itself are OK, somebody:tm: would need to have a look into the problem with the cookies vs. visting a page first and then fix a few remaining problems.

it seems that we can also cut down the default waiting time
which hopefully will speed up our tests.
@ohadlevy
Copy link
Member Author

ohadlevy commented Jul 4, 2018

closing in favor of #5770

@ohadlevy ohadlevy closed this Jul 4, 2018
@ohadlevy ohadlevy deleted the headless-chrome branch October 21, 2018 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants