Chromium/Chrome does not work in an OpenVZ container #938

Closed
gildegoma opened this Issue Feb 16, 2013 · 71 comments

Comments

Projects
None yet
Member

gildegoma commented Feb 16, 2013

Problem initially reported in https://groups.google.com/forum/m/?fromgroups#!topic/travis-ci/YG9j5wN4YeE

See attempts to install chrome browser and test driver on the fly here: https://travis-ci.org/freedomsponsors/www.freedomsponsors.org/builds

As pointed out below, this a well-known integration problem: Chrome cannot be executed in a OpenVZ container/guest, because of suid binaries. Details there:

//cc @tonylampada

@gildegoma Thanks for opening this.
I may have made a new discovery today.
I tried just running chromium-browser and got this error:

Failed to move to new PID namespace: Operation not permitted

Googling for it, I found this chromium issue, marked as won't fix --> http://code.google.com/p/chromium/issues/detail?id=31077

Apparently, the partition where /opt lives should be mounted without an option called nosuid

Hope this helps

I'm placing a 20 bucks bounty for this issue on FreedomSponsors.
http://www.freedomsponsors.org/core/offer/203/chromium-browser-is-preinstalled-on-32bit-worker-vm-but-not-on-64bit-bluebox-workers?alert=SPONSOR

If there's anyone out there who's suffering from this as well, please feel free to chip in :-)

Owner

rkh commented Feb 21, 2013

ping @joshk

Member

gildegoma commented Mar 10, 2013

All travis boxes are now 64-bit and chromium-browser package should be preinstalled on all linux boxes.

Member

gildegoma commented Mar 10, 2013

I verified: this problem is still present (issue renamed) and sounds very hard to fix.
as expected, both chrome flavours ('chromium-broswer' and 'google-chrome') are impacted.

Thanks for verifying. Looking forward to see my tests running again :-)

Member

gildegoma commented Mar 11, 2013

According to chromium bug reports above, Chrome does not support OpenVZ integration. @joshk could you double check with bluebox support, if no 🌟 magical workaround exists (very little hope, but who knows...)

Owner

joshk commented Mar 11, 2013

I will check with BlueBox about this.

Member

gildegoma commented Mar 15, 2013

At the moment, the best workaround consists in running the client tests from SauceLabs. See:

(or use other Selenium Drivers, like WebDriver or Firefox)

mithro commented Apr 13, 2013

From looking at the bug linked above I found;

This just started happening to my OpenVZ containers, too:
linux-image-openvz-amd64 2.6.32+28 from Debian testing
chromium-browser 6.0.472.36~r55963-0ubuntu1~ucd1~hardy (from beta PPA: http://ppa.launchpad.net/chromium-daily/beta/ubuntu)

I have upgraded the kernel from 2.6.24.28.30 (Ubuntu Hardy) a few days ago, and chromium-browser from 5.0.375.125~r53311-0ubuntu2~ucd2~hardy.

Passing "--no-sandbox" works around this, but it adds a warning during startup because of the unsupported nature of this option, which I'd like to avoid (I'm using Chromium in OpenVZ for creating browser screenshots automatically).

See also https://bugs.launchpad.net/chromium-browser/+bug/577919

Working if --no-sandbox might allow chrome to run?

mithro commented Apr 13, 2013

Yeap, that seems to work for me!

    driver_arguments = {}
    driver_arguments['chrome_options'] = webdriver.ChromeOptions()

....

    # Travis-CI uses OpenVZ containers which are incompatible with the sandbox
    # technology.
    # See https://code.google.com/p/chromium/issues/detail?id=31077 for more
    # information.
    if 'TRAVIS' in os.environ:
        driver_arguments['chrome_options'].add_argument('--no-sandbox')

...

    webdriver.Chrome(**driver_arguments)

https://travis-ci.org/mithro/web-animations-js/jobs/6310912

mithro commented Apr 14, 2013

Oh, you also need to fix the permissions of /dev/shm

# Make sure /dev/shm has correct permissions.
ls -l /dev/shm
sudo chmod 1777 /dev/shm
ls -l /dev/shm

@mithro, I tried using this workaround, but still no luck.
I'm getting this error:

WebDriverException: Message: u'session not created exception: unknown error: unable to discover open pages'

Any idea what I might be doing wrong?
https://travis-ci.org/freedomsponsors/www.freedomsponsors.org/builds/6809583

mithro commented May 2, 2013

Not sure, but we are using a different chrome driver / chrome version I
think...

export CHROME=google-chrome-${VERSION}_current_amd64.deb
 wget https://dl.google.com/linux/direct/$CHROME

(Version is stable/beta/unstable)

                chromedriver_url = "
https://chromedriver.googlecode.com/files/chromedriver2_linux64_0.6.zip"
            else:
Owner

joshk commented May 2, 2013

Is there anything we (Travis) can do to fix this issue? (apart from moving off OpenVZ)

On 2/05/2013, at 7:43 AM, Tim Ansell notifications@github.com wrote:

Not sure, but we are using a different chrome driver / chrome version I
think...

export CHROME=google-chrome-${VERSION}_current_amd64.deb
wget https://dl.google.com/linux/direct/$CHROME

(Version is stable/beta/unstable)

chromedriver_url = "
https://chromedriver.googlecode.com/files/chromedriver2_linux64_0.6.zip"
else:

On 2 May 2013 15:35, tonylampada notifications@github.com wrote:

@mithro https://github.com/mithro, I tried using this workaround, but
still no luck.
I'm getting this error:

WebDriverException: Message: u'session not created exception: unknown error: unable to discover open pages'

Any idea what I might be doing wrong?

https://travis-ci.org/freedomsponsors/www.freedomsponsors.org/builds/6809583


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-17321268
.


Reply to this email directly or view it on GitHub.

mithro commented May 6, 2013

Sadly, I can't see anyway that Travis can fix this problem at the moment.

It looks like they are trying to fix this limitation in the kernel which
would then mean just a kernel upgrade.

On 2 May 2013 21:30, Josh Kalderimis notifications@github.com wrote:

Is there anything we (Travis) can do to fix this issue? (apart from moving
off OpenVZ)

On 2/05/2013, at 7:43 AM, Tim Ansell notifications@github.com wrote:

Not sure, but we are using a different chrome driver / chrome version I
think...

export CHROME=google-chrome-${VERSION}_current_amd64.deb
wget https://dl.google.com/linux/direct/$CHROME

(Version is stable/beta/unstable)

chromedriver_url = "
https://chromedriver.googlecode.com/files/chromedriver2_linux64_0.6.zip"

else:

On 2 May 2013 15:35, tonylampada notifications@github.com wrote:

@mithro https://github.com/mithro, I tried using this workaround,
but
still no luck.
I'm getting this error:

WebDriverException: Message: u'session not created exception: unknown
error: unable to discover open pages'

Any idea what I might be doing wrong?

https://travis-ci.org/freedomsponsors/www.freedomsponsors.org/builds/6809583


Reply to this email directly or view it on GitHub<
https://github.com/travis-ci/travis-ci/issues/938#issuecomment-17321268>
.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-17332752
.

niklas added a commit to niklas/cataract that referenced this issue Jun 2, 2013

Wasn't getting anywhere with the --no-sandbox and misc hacks on linux. Sorted by simply switching to OSX VMs.

mithro commented Jun 26, 2013

--no-sandbox definitely works because we are using it daily :)

Tim

On 26 June 2013 00:20, Luis Abreu notifications@github.com wrote:

Wasn't getting anywhere with the --no-sandbox and misc hacks on linux.
Sorted by simply switching to OSX VMs.


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-19979133
.

Humm, alright, guess I need to try again :) ( wonder if being on Pro makes any diff )

@jakoch jakoch referenced this issue in giorgiosironi/phpunit-selenium Jul 24, 2013

Open

Selenium2TestCase "chrome not reachable" #259

0 of 2 tasks complete

mithro commented Dec 5, 2013

If you are using the latest Chrome unstable you will now get a "Failed to move to new PID namespace: Operation not permitted" error even when running with --no-sandbox (none of the --no-sandbox related flags seem to work any more).

I have created a custom version of the sandbox which doesn't fail with this error. You can install it the following way;

        # If we don't have PID namespace support, download a custom
        # chrome-sandbox which works even without it.
        if [ -f /opt/google/chrome/chrome-sandbox ]; then
            export CHROME_SANDBOX=/opt/google/chrome/chrome-sandbox
        else
            export CHROME_SANDBOX=$(ls /opt/google/chrome*/chrome-sandbox)
        fi

        sudo rm -f $CHROME_SANDBOX
        sudo wget https://googledrive.com/host/0B5VlNZ_Rvdw6NTJoZDBSVy1ZdkE -O $CHROME_SANDBOX
        sudo chown root:root $CHROME_SANDBOX; sudo chmod 4755 $CHROME_SANDBOX
        sudo md5sum $CHROME_SANDBOX

jsdevel commented Dec 21, 2013

I'm now getting this:

Error: Error creating class
org.openqa.selenium.WebDriverException: chrome not reachable
  (Driver info: chromedriver=2.8.240825,platform=Linux 2.6.32-042stab079.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.25 seconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'testing-worker-linux-2-2-5645-linux-8-15825418', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-042stab079.5', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:182)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:150)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:118)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

Here's my .travis.yml

language: node_js
node_js:
  - "0.10"
before_install:
  - "Xvfb :99 > /dev/null &"
install: "npm install"
cache:
  directories:
    - node_modules

mithro commented Dec 22, 2013

Even with my custom sandbox binary installed?

jsdevel added a commit to jsdevel/webdriver-sync that referenced this issue Dec 22, 2013

jsdevel commented Dec 22, 2013

@mithro I wasn't able to install your sandbox binary. Checkout the output here: https://travis-ci.org/jsdevel/webdriver-sync/builds/15840074

I added your script as a fixChrome bash script in my project root and added a before_install line to run it.

jsdevel commented Dec 22, 2013

@mithro I think I've found a smoking gun. My VM doesn't have google chrome, it has chromium! Adding ' - "find / -maxdepth 5"' to my before_install yielded the following:

....
/usr/bin/mysqld_safe
/usr/bin/ppmtowinicon
/usr/bin/chromium-browser
/usr/bin/unzipsfx
/usr/bin/troff
....

No sign of google-chrome anywhere. This is a problem for ChromeDriver, as it expects to find the binary at /usr/bin/google-chrome (see https://code.google.com/p/selenium/wiki/ChromeDriver#Overriding_the_Chrome_binary_location)

I'm going to investigate creating a symlink that points to chromium, and / or removing chromium and installing google-chrome before_install.

jsdevel commented Dec 23, 2013

@mithro I was finally able to get chrome to load, but it sure isn't elegant. Using your and others suggestions in this thread, my .travis.yml file now looks like this:

language: node_js
node_js:
  - "0.10"
before_install:
  - "sudo apt-get remove chromium-browser"
  - "echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections"
  - "sudo apt-get install ttf-mscorefonts-installer"
  - "sudo apt-get install x-ttcidfont-conf"
  - "sudo mkfontdir"
  - "sudo apt-get install defoma libgl1-mesa-dri xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic"
  - "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
  - "sudo mkdir -p /usr/share/desktop-directories"
  - "sudo dpkg -i google-chrome-stable_current_amd64.deb"
  - "sudo apt-get install -f"
  - "sudo dpkg -i google-chrome-stable_current_amd64.deb"
  - "export CHROME_SANDBOX=/opt/google/chrome/chrome-sandbox"
  - "sudo rm -f $CHROME_SANDBOX"
  - "sudo wget https://googledrive.com/host/0B5VlNZ_Rvdw6NTJoZDBSVy1ZdkE -O $CHROME_SANDBOX"
  - "sudo chown root:root $CHROME_SANDBOX; sudo chmod 4755 $CHROME_SANDBOX"
  - "sudo md5sum $CHROME_SANDBOX"
  - "export DISPLAY=:99.0"
  - "Xvfb :99.0 -extension RANDR > /dev/null &"
  - "sudo chmod 1777 /dev/shm"
install: "npm install"
cache:
  directories:
    - node_modules

I'm still getting strange error output in my builds, namely:

[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!

However, this is more related to fonts than anything.

Is there a way to get stuff like this baked into the VMs?

Owner

roidrage commented Dec 23, 2013

Which of the steps would you like to see baked into the VMs?

jsdevel commented Dec 23, 2013

@roidrage I'd personally like to see all of them baked in. It would really help me out, as I'm actively working on webdriver-sync. For me, any user that wishes to test chrome using that module will have to add everything from my .travis.yml above to their project's yml.

I wish I could get that last warning about TrueType to go away, but that can wait.

jsdevel commented Dec 23, 2013

@roidrage These two lines can probably be ignored from my previous statement:

  - "export DISPLAY=:99.0"
  - "Xvfb :99.0 -extension RANDR > /dev/null &"

I think it's acceptable for users to configure that on their own, but I leave it to you.

Owner

roidrage commented Dec 23, 2013

I think one thing that's worth for us to look into is to use a proper Chrome instead of Chromium and utilize the sandbox script.

Unfortunately a change like this isn't that easy to implement, as it's certain to break tests for a lot of people in the process.

jsdevel commented Dec 23, 2013

@roidrage Who's using chromium ? :P (only half joking)

I guess I can attempt setting the binary location to use chromium. Worth a shot.

Maybe a flag could be supported, like:

language: node_js
node_js:
  - "0.10"
use_chrome: true
before_install:
  - "export DISPLAY=:99.0"
  - "Xvfb :99.0 -extension RANDR > /dev/null &"
install: "npm install"
cache:
  directories:
    - node_modules

With use_chrome: true I'd expect that my VM would be provisioned with chrome. Not sure how .travis.yml fits into the lifeline of Travis CI though. In this way you would't break backwards compat.

mithro commented Dec 30, 2013

My set up script for Chrome (and Firefox) on Travis can be found at
https://github.com/web-animations/web-animations-js/blob/master/.travis-setup.sh.
We ended up moving to a proper shell script because setup was getting
complicated. We test against chrome stable, beta and unstable and
equivalent for Firefox.

On the Chrome case I should create a PPA with a divert and the custom
sandbox rather then this hack. Then you just install the package.

It would be really nice if their was a browser section part of travis.yml
that let you do this selection. I haven't had a chance to look at the
Travis code to see if it would be possible.
On 24 Dec 2013 05:28, "Joseph Spencer" notifications@github.com wrote:

@roidrage https://github.com/roidrage Who's using chromium ? :P (only
half joking)

I guess I can attempt setting the binary location to use chromium. Worth a
shot.

Maybe a flag could be supported, like:

language: node_jsnode_js:

  • "0.10"use_chromium: falsebefore_install:
  • "export DISPLAY=:99.0"
  • "Xvfb :99.0 -extension RANDR > /dev/null &"install: "npm install"cache:
    directories:
- node_modules


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-31137129
.

jsdevel commented Dec 31, 2013

@mithro Thank you for sharing. It would be really nice to make setup like this transparent to users.

@jarib jarib referenced this issue in watir/watir Jan 31, 2014

Closed

Fix Chrome on Travis #240

sanemat added a commit to handcooler/hand_cooler that referenced this issue Feb 8, 2014

Add brower setting
Chromium/Chrome does not work in an OpenVZ container · Issue #938 ·
travis-ci/travis-ci travis-ci/travis-ci#938

@timthelion timthelion referenced this issue in subuser-security/subuser Feb 11, 2014

Closed

Chromium doesn't work #1

philnate pushed a commit to philnate/textManager that referenced this issue Feb 19, 2014

Owner

roidrage commented May 2, 2014

Is this still an active issue?

Owner

roidrage commented May 9, 2014

Hey, we haven't heard back from you, so I'm closing this.

If you have any more issues, you can either give us an update here or file a new one.

@roidrage roidrage closed this May 9, 2014

jsdevel commented May 9, 2014

@roidrage sorry! I have no idea why I missed this. Too many notifications in github at times : P

I haven't tried not doing what I'm doing here. With the latest changes, should the steps in my yml be obsolete? Thanks!

Owner

roidrage commented May 9, 2014

Unfortunately I'm fairly certain it isn't at this point. Chrome is a strange beast. What we could do is distill the steps into an addon that people can opt into.

jsdevel commented May 9, 2014

@roidrage that would be cool. Anything that would make it easier would be appreciated. Is that something I can do?

Owner

roidrage commented May 9, 2014

Thinking about it some more, it's actually fairly straight-forward. Distilling this into a runnable shell script as a Gist would do the trick.

Member

gildegoma commented May 9, 2014

It could also make sense to remove Chromium from the Travis VM image.

Owner

roidrage commented May 9, 2014

At this point it's hard to guess how many people rely on it to be installed, but a GitHub search could help :)

jsdevel commented May 28, 2014

@roidrage for some reason, chromedriver is now unable to luanch on travis builds given my install steps that were working on Apr 25th. Here's the latest from the webdriver-sync build. I'll try and see if it was something that changed on chrome's end. I even tried reverting my changes back to selenium-standalone-server-2.40 and chromedriver-2.8 but no dice :(

mithro commented May 29, 2014

The Chrome version did change recently (they do a release every 6 weeks).

You might need to update your changes so they match what we were doing for
the newer binaries (I seem to remember the sandbox binary changed location).

Otherwise we might need to rebuild the "broken sandbox" binary.

I won't get a chance to look at this further till next week at the earliest.
On 28 May 2014 14:21, "Joseph Spencer" notifications@github.com wrote:

@roidrage https://github.com/roidrage for some reason, chromedriver is
now unable to luanch on travis builds given my installhttps://github.com/jsdevel/webdriver-sync/blob/master/.travis.yml#L4steps that were working on Apr 25th. Here's the latest from the
webdriver-sync https://travis-ci.org/jsdevel/webdriver-sync#L1024build. I'll try and see if it was something that changed on chrome's end. I
even tried reverting my changes back to selenium-standalone-server-2.40and
chromedriver-2.8 but no dice :(


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-44364306
.

jsdevel commented May 29, 2014

Thanks for the response @mithro !!!!

Is this all related to sandboxing?

mithro commented May 29, 2014

The issue with Chrome that I fixed was caused by the sandbox; The Chrome sandbox uses a method which is incompatible with OpenVZ containers (as OpenVZ containers use the same technology to actually sandbox the containers and the technology doesn't support nesting).

I'm assuming that you are hitting the issue again but have not looked at your output to confirm.

From the web-animation-js .travis-setup.sh -- https://github.com/web-animations/web-animations-js/blob/master/.travis-setup.sh

    echo "Getting $VERSION of $BROWSER"
    export CHROME=google-chrome-${VERSION}_current_amd64.deb
    wget https://dl.google.com/linux/direct/$CHROME
    sudo dpkg --install $CHROME || sudo apt-get -f install
    which google-chrome
    ls -l `which google-chrome`

    if [ -f /opt/google/chrome/chrome-sandbox ]; then
        export CHROME_SANDBOX=/opt/google/chrome/chrome-sandbox
    else
        export CHROME_SANDBOX=$(ls /opt/google/chrome*/chrome-sandbox)
    fi

    # Download a custom chrome-sandbox which works inside OpenVC containers (used on travis).
    sudo rm -f $CHROME_SANDBOX
    sudo wget https://googledrive.com/host/0B5VlNZ_Rvdw6NTJoZDBSVy1ZdkE -O $CHROME_SANDBOX
    sudo chown root:root $CHROME_SANDBOX; sudo chmod 4755 $CHROME_SANDBOX
    sudo md5sum $CHROME_SANDBOX

    google-chrome --version
    ;;

jsdevel commented May 29, 2014

@mithro is that currently working for you?

jsdevel commented May 29, 2014

@mithro I have checked the output, but all I get is "opening chrome crashed." I haven't tried with a verbose flag or anything like that.

mithro commented May 29, 2014

Seems too https://travis-ci.org/web-animations/web-animations-js

On 29 May 2014 16:44, Joseph Spencer notifications@github.com wrote:

@mithro https://github.com/mithro I have checked the output, but all I
get is "opening chrome crashed." I haven't tried with a verbose flag or
anything like that.


Reply to this email directly or view it on GitHubhttps://github.com/travis-ci/travis-ci/issues/938#issuecomment-44499366
.

jsdevel commented May 29, 2014

@mithro have you uploaded that to gist? I'd like to reference it directly. Seems very reusable and superman like in it's ability to solve this issue.

mithro commented May 29, 2014

I keep meaning too but have never gotten around to it. I'd also like to take the sandbox binary and put it inside a deb package with proper diverts so the setup becomes;

  • Install chrome.deb
  • Install chrome-on-travis-ci.deb

Happy to review / comment on a gist if you have the time to create one and test it.

jsdevel commented May 29, 2014

@mithro currently I'm doing this in my .travis.yml:

language: node_js
node_js:
  - "0.10"
before_install:
  - "wget https://raw.githubusercontent.com/web-animations/web-animations-js/master/.travis-setup.sh"
  - "chmod 777 ./.travis-setup.sh"
  - "sudo ./.travis-setup.sh"
  - "export DISPLAY=:99.0"
  - "Xvfb :99.0 -extension RANDR > /dev/null &"
  - "WEBDRIVER_SYNC_ENABLE_SELENIUM_STDOUT=true"
  - "WEBDRIVER_SYNC_ENABLE_SELENIUM_STDERR=true"
install: "npm install"
cache:
  directories:
    - node_modules

My builds are failing though with this:
ln: failed to create symbolic link/lib/*/site-packages/PIL.pth': No such file or directory`

mithro commented May 29, 2014

The part that copies PIL.pth into the virtualenv of .travis-setup.sh isn't needed by you (you get a virtualenv when you set "language: python"). You should skip lines 16 to 22 in your node set up.

You will also need to set the BROWSER environment (I believe ARGS is optional), here is an example that we use;

env:

  matrix:
    - BROWSER=Chrome-stable ARGS='-x -b Chrome -u'
    - BROWSER=Chrome-beta ARGS='-x -b Chrome -u'
    - BROWSER=Chrome-unstable ARGS='-x -b Chrome -u'
    - BROWSER=Chrome-unstable ARGS='-x -b Chrome -u --flag=--enable-experimental-web-platform-features'
    - BROWSER=Firefox-stable ARGS='-x -b Firefox -u'
    - BROWSER=Firefox-beta ARGS='-x -b Firefox -u'
    - BROWSER=Firefox-aurora ARGS='-x -b Firefox -u'
    - BROWSER=Remote ARGS='--verbose -b Remote --sauce --remote-caps=INTERNETEXPLORER --remote-caps=version=10 --remote-caps=platform="Windows 8"'
    - BROWSER=Remote ARGS='--verbose -b Remote --sauce --remote-caps=SAFARI --remote-caps=version=6 --remote-caps=platform="OS X 10.8"'
    - BROWSER=Remote ARGS='--verbose -b Remote --sauce --remote-caps=IPHONE --remote-caps=version=6 --remote-caps=platform="OS X 10.8"'
    - BROWSER=Remote ARGS='--verbose -b Remote --sauce --remote-caps=ANDROID --remote-caps=version=4.0 --remote-caps=platform=Linux'

jsdevel commented May 29, 2014

Thanks @mithro. I'm a bit confused by "You should skip lines 16 to 22 in your node set up." Can you provide me a link?

What does matrix do? Does that spawn new builds for each item?

jsdevel commented May 30, 2014

@mithro sorry for my confusion. I see now that you meant 16 to 22 in your setup script.

I had no idea about matrix! That's really cool.

So this appears to be a chromedriver issue: https://code.google.com/p/chromedriver/issues/detail?id=799

I found out it was the way I was invoking Xvfb. Sometimes it pays to read the docs.

balthazar added a commit to balthazar/ng-markdown that referenced this issue Jun 29, 2014

chore(travis): Chrome not working with Travis
travis-ci/travis-ci#938

Switching to Firefox for running the tests on Travis

visusnet added a commit to codecentric/zucchini that referenced this issue Jul 22, 2014

jugglinmike added a commit to bocoup/todomvc-vanillajs that referenced this issue Aug 20, 2014

Add TravisCI configuration file
The Chrome installation script comes from the discussion on the TravisCI
issue tracker, "Chromium/Chrome does not work in an OpenVZ container"
(gh-938):

travis-ci/travis-ci#938

jeromew commented Sep 15, 2014

As a cross-post after a discussion with @mithro here is a link to a chromium issue that I opened regarding the chrome sandbox on an openvz machine: https://code.google.com/p/chromium/issues/detail?id=412698

The sandbox can be bypassed by recompiling the "chrome_sandbox" target of the chromium project after commenting the 2 lines

//if (!MoveToNewNamespaces())
//  return 1;

in src/sandbox/linux/suid/sandbox.c in the chromium source code.

use with care: this removes the annoying UI message that you get with the --no-sandbox or the --disable-setuid-sandbox flag, but this UI message is annoying for a reason. Your chrome instance will not be correctly sandboxed by using this trick so you should not browser the open web with it for security reasons.

mithro referenced this issue in enkidulan/hangout_api Sep 18, 2014

jugglinmike added a commit to bocoup/todomvc-vanillajs that referenced this issue Oct 2, 2014

Add TravisCI configuration file
The Chrome installation script comes from the discussion on the TravisCI
issue tracker, "Chromium/Chrome does not work in an OpenVZ container"
(gh-938):

travis-ci/travis-ci#938

jugglinmike added a commit to bocoup/todomvc-vanillajs that referenced this issue Oct 2, 2014

Add TravisCI configuration file
The Chrome installation script comes from the discussion on the TravisCI
issue tracker, "Chromium/Chrome does not work in an OpenVZ container"
(gh-938):

travis-ci/travis-ci#938

jugglinmike added a commit to bocoup/todomvc-vanillajs that referenced this issue Oct 5, 2014

Add TravisCI configuration file
The Chrome installation script comes from the discussion on the TravisCI
issue tracker, "Chromium/Chrome does not work in an OpenVZ container"
(gh-938):

travis-ci/travis-ci#938

I see this has been marked as "awaiting-followup" and somebody impacted (trying to run tests using karma in chrome on travis), karma just times out looking for a chrome instance (example). It all works locally, just not on travisCI.

@LoveIsGrief LoveIsGrief referenced this issue in LoveIsGrief/videojs-soundcloud Nov 8, 2014

Merged

Continuous integration with travis CI #9

Owner

joshk commented Mar 9, 2015

Hi @lookfirst

Could you open a new issue and we can dive into this problem once more with fresh eyes.

Were you having issues on .org or .com?

Thanks,

Josh

Sorry for the previous (now deleted) comment...

After an insane amount of hours wasted today... I finally got this working with Angular Protractor. As everyone has suggested, the no-sandbox argument is the key. It was difficult to figure out how to pass that into Protractor since there isn't any examples that I could find (note the protractor.conf.js near the bottom). 😢

Hopefully the bits and pieces of my config below will help someone.

Example project: https://github.com/lookfirst/systemjs-seed
First all green build: https://travis-ci.org/lookfirst/systemjs-seed/builds/53593085

./.travis.chrome.sh

#!/bin/bash

# Holy shit batman!
# https://github.com/travis-ci/travis-ci/issues/938
# https://github.com/travis-ci/travis-ci/issues/2555

sudo apt-get install -y python-software-properties
sudo apt-add-repository "deb http://dl.google.com/linux/chrome/deb/ stable main"
sudo sed -i s/deb-src.*google.*//g /etc/apt/sources.list
wget -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-get update -qq
sudo apt-get install -y google-chrome-stable

sudo chmod 1777 /dev/shm

.travis.yml

language: node_js
node_js:
- '0.12'
- '0.11'
- '0.10'
branches:
  only:
  - master
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- ./.travis.chrome.sh
- npm install jspm
- jspm config endpoints.github.auth $GH_TOKEN
install:
- npm install
script:
- gulp run &
- npm run-script protractor-setup
- sleep 10
- npm run-script protractor-run

package.json:

  "scripts": {
    "protractor-setup": "./node_modules/.bin/webdriver-manager update --standalone",
    "protractor-run": "gulp es6-e2e && ./node_modules/.bin/protractor protractor.conf.js"
  }

protractor.conf.js

exports.config = {
    // The advantage of directly connecting to browser drivers is that your test scripts may start up and run faster.
    directConnect: true,

    // https://github.com/angular/protractor/blob/master/docs/jasmine-upgrade.md
    framework: 'jasmine2',

    // The address of a running selenium server.
    seleniumAddress: 'http://localhost:4444/wd/hub',

    // A base URL for your application under test. Calls to protractor.get()
    // with relative paths will be prepended with this.
    baseUrl: 'http://localhost:9000',

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
            'args': ['no-sandbox']
        }
    },

    // Spec patterns are relative to the configuration file location passed
    // to proractor (in this example conf.js).
    // They may include glob patterns.
    specs: ['test-e2e-compile/**/*.e2e.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        isVerbose: true,
        showTiming: true,
        includeStackTrace: true,
        showColors: true // Use colors in the command line report.
    }
};

So, now my request is for the admins of Travis to install Chrome in the default image so that I don't have to run that .travis.chrome.sh script. =) It would also be helpful if xvfb was started and the DISPLAY environment variable was already set. That would make things a lot more plug and play.

Owner

joshk commented Mar 9, 2015

Hi @lookfirst

Can you please open a separate issue for this.

DISPLAY is already exported on the VM image. Also, I believe Chrome is also installed.

Can you try adding sudo: true to your .travis.yml and seeing if the protractor-setup script is still needed?

Thanks

@joshk

I'd like to understand your suggestions before I make fixes and break things. 😉 So I have a couple questions:

  1. Do I still need to start xvfb?
  2. What is DISPLAY exported as?
  3. What effect does sudo: true have? I don't see it anywhere in your docs.
  4. Why would sudo: true negate the need to run protractor-setup?

thanks.

Owner

joshk commented Mar 9, 2015

You will still need to start xvfb as we do not start this by default.
I believe :99.0 is the exported DISPLAY value, you can check this by adding env in a before_install step
Sorry, I meant to say sudo: false. This will send the job to our new build environment which is based on LXC and runs on EC2. Our current legacy setup uses OpenVZ, which is part of the problem with Chrome.

Ok, without installing chrome, no-sandbox and DISPLAY commented out, chrome still crashes on the new arch:

https://travis-ci.org/lookfirst/systemjs-seed/jobs/53600350

uncommented no-sandbox and i get this:

https://travis-ci.org/lookfirst/systemjs-seed/jobs/53600788

and uncommenting DISPLAY, i get this:

https://travis-ci.org/lookfirst/systemjs-seed/jobs/53601000

Note that I added env before I set DISPLAY by hand:

https://travis-ci.org/lookfirst/systemjs-seed/jobs/53601000#L99

So, I guess we are back to square one, but with a faster server now. 👍

So now that I can't sudo, how do I install stuff with apt?

@joshk Any more thoughts?

Owner

joshk commented Mar 10, 2015

Not sure right now sorry, Can you please open a new ticket with the information you posted above summerizing the issue and I can escalated this within the team.

Thanks :)

Due to the recent change over to docker by default and the fact that it has an ancient version of chrome, this is what I'm using now...

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- curl -Lo chrome.zip https://download-chromium.appspot.com/dl/Linux_x64 && unzip chrome.zip
@ghost

ghost commented May 24, 2015

Thanks @lookfirst -- google-chrome (launched via python/selenium/chromedriver) is working for me with your bash script, sudo: required, and the --no-sandbox flag activated.

@andy11 I found that installing chrome via apt takes an inordinate amount of time because of all the dependencies. The comment above where I just download the .zip file and use that binary works much better.

JohannesHoppe added a commit to angular-buch/code that referenced this issue Jul 23, 2015

nope. chrome on travis, not a good idea: travis-ci/travis-ci#938
Revert "lets try again ChromeDriver"

This reverts commit 07557b7.

lkwg82 added a commit to lkwg82/de.lgohlke.selenium-pageobjects that referenced this issue Sep 21, 2015

@lbustelo lbustelo referenced this issue in jupyter-widgets/declarativewidgets Oct 2, 2015

Merged

Skip remote tests if SAUCE* environment variables not defined. #20

VandeurenGlenn added a commit to VandeurenGlenn/web-import that referenced this issue Oct 4, 2015

dtracers commented Apr 5, 2016

I am installing chrome driver via grunt and as of this build it had errors with the chrome driver:

https://travis-ci.org/dtracers/coursesketch/builds/120990028
I have not tried any of the scripts yet but I did not know if anything has changed in the past year that is worth noting.

kvz added a commit to transloadit/uppy that referenced this issue Apr 6, 2016

This is going to be hard
It seems we are currently trying to run Chrome on Travis. Which is a
bit hard (travis-ci/travis-ci#938). Firefox
is recommended:
https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to
-Run-Tests-That-Require-a-GUI

But it's still only Firefox.

We can keep the chrome work for local tests, but I think Travis should
ping Sauce Labs:
https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-Sauce-L
abs

So they can spin up 180 real browsers and test on those.

fulls1z3 commented Dec 9, 2016

Hope it helps:

sudo: required
dist: trusty
addons:
  apt:
    sources:
      - google-chrome
    packages:
      - google-chrome-stable

language: node_js
node_js:
  - "6"
cache:
  directories: node_modules
branches:
  only: master

before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
  - npm i -g npm@^3
  - sleep 3

This appears to no longer be an issue for the "Trusty Tahr" (e.g. 14.04) release of Ubuntu and onward. If you are able to upgrade to that release in your .travis.yml file, then you should be able to run Google Chrome without disabling the sandbox.

(I just spoke with some folks on the Chromium team in the #chromium IRC channel on Freenode. Chrome only uses a "setuid sandbox" as a fallback when the kernel does not support more advanced features. It seems likely that Ubuntu 14.04 has the namespace features that allow it to use other technologies--ones that are compatible with the environment provided by TravisCI.)

Indemnity83 added a commit to solderio/solder that referenced this issue Feb 27, 2017

Upgrade test environment to Ubuntu 14.04
Attempting to get browser tests to work on Travis-CI; based on the feedback in travis-ci/travis-ci#938

lutostag added a commit to lutostag/webextension-formsave that referenced this issue Apr 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment