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

test: switch from PhantomJS to HeadlessChrome #4262

Merged
merged 3 commits into from Oct 3, 2019

Conversation

@bajtos
Copy link
Member

bajtos commented Sep 30, 2019

Rework browser tests to run in Headless Chrome instead of PhantomJS, because the latter is no longer maintained.

This allows us to remove transpilation to ES5 via babelify, which significantly improves speed of our tests.

Fixes #4252

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
@bajtos bajtos added the ci label Sep 30, 2019
@bajtos bajtos requested review from hacksparrow and strongloop/loopback-3x-maintainers Sep 30, 2019
@bajtos bajtos self-assigned this Sep 30, 2019
@bajtos

This comment has been minimized.

Copy link
Member Author

bajtos commented Sep 30, 2019

@tomleah it makes me wonder if we can enable browser tests on ppc64 and s390x platform, now that we are using Headless Chrome instead of PhantomJS. What do you think? (These two platforms were disabled by your commit 0dac936.)

@bajtos bajtos force-pushed the fix/ci branch from d16698b to 97cfd3c Sep 30, 2019
@bajtos

This comment has been minimized.

Copy link
Member Author

bajtos commented Sep 30, 2019

The build is failing on cis-jenkins because we don't have Chrome installed in the docker image used to run them. I opened a PR to add Chrome, now I am waiting for @rmg to help me get that change landed and published to production.

@bajtos bajtos force-pushed the fix/ci branch 2 times, most recently from 39ab65a to 9dd2257 Sep 30, 2019
@hacksparrow

This comment has been minimized.

Copy link
Member

hacksparrow commented Sep 30, 2019

Much better choice. What about the CI failures?

config.set({
customLaunchers: {
ChromeDocker: {
base: 'ChromeHeadless',

This comment has been minimized.

Copy link
@rmg

rmg Sep 30, 2019

Member

If you change this to ChromiumHeadless it might "just work" since Chromium is installed.

This comment has been minimized.

Copy link
@bajtos

bajtos Oct 1, 2019

Author Member

In c772233, I added a check to see if chromium or chromium-browser is in PATH and then use ChromiumHeadless instead of ChromeHeadless. Unfortunately, it seems the check did not pass, because the build is still using Chrome (not Chromium):

https://cis-jenkins.swg-devops.com/job/nb/job/loopback%7Emaster/label=x64%20&&%20linux%20&&%20nvm,nodeVersion=10/300/console

This comment has been minimized.

Copy link
@bajtos

bajtos Oct 1, 2019

Author Member

Below is the Dockerfile I am using to test my setup, it's based on our build images.

###
### Copied from Jenkins base Dockerfile
###

FROM ubuntu:xenial

# Declared first so that during build, nothing ever gets accidentally persisted
VOLUME /tmp

# Simple wrapper for apt-get install that does an update before install and
# cleanup after install to ensure that the resulting layer doesn't contain
# anything extra
COPY docker-friendly-apt-install.sh /bin/docker-friendly-apt-install

# Ensure that package don't give us any trouble when we install them
RUN echo 'DPkg::options { "--force-confdef"; "--force-confnew"; }' \
    > /etc/apt/apt.conf.d/60local

# Use bash by default instead of dash
RUN echo "dash dash/sh boolean false" | debconf-set-selections \
 && DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

# Set our locale to use UTF-8 by default
RUN docker-friendly-apt-install locales \
 && locale-gen en_US.UTF-8 \
 && update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

# ssh and some additional packages that are sufficiently common/popular that
# they are probably wanted/needed in all images.
RUN docker-friendly-apt-install \
      ca-certificates \
      apt-transport-https \
      wget \
      curl \
      git \
      openssh-server \
      zip \
      unzip \
      bzip2 \
      xz-utils \
      bash \
      rsync \
      jq

###
### Install Chromium - see xvfb/Dockerfile
###

# For running protractor/selenium based tests
# libgconf-2-4 is a dependency of the selenium chromedriver
RUN docker-friendly-apt-install xvfb chromium-chromedriver libgconf-2-4

###
### Setup Node environment
###

# Install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

RUN source ~/.nvm/nvm.sh && nvm install 12

###
### Run our tests
###

ENV CI=true
ENV JENKINS_HOME=/tmp

COPY "." "."

CMD ["/bin/bash", "-c", "source ~/.nvm/nvm.sh && nvm run 12 ./node_modules/.bin/grunt karma:unit-once"]

I am running the following command to build & run the tests:

docker build -t loopback-core-tests . && docker run -it loopback-core-tests

When I run this on my machine, Chromium is correctly picked and all tests pass.

@rmg could you please help me to investigate why my tests are failing on cis-jenkins?

@tomleah

This comment has been minimized.

Copy link
Contributor

tomleah commented Sep 30, 2019

@tomleah it makes me wonder if we can enable browser tests on ppc64 and s390x platform, now that we are using Headless Chrome instead of PhantomJS. What do you think? (These two platforms were disabled by your commit 0dac936.)

As long as Headless Chrome works on those platforms I don't see why not @bajtos. I no longer have access to ppc64 or s390x machines so I'm unable to check this however

@bajtos bajtos force-pushed the fix/ci branch 3 times, most recently from c772233 to a182075 Oct 1, 2019
Rework browser tests to run in Headless Chrome instead of PhantomJS,
because the latter is no longer maintained.

This allows us to remove transpilation to ES5 via babelify, which
significantly improves speed of our tests.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
@bajtos bajtos force-pushed the fix/ci branch from a182075 to 1cd3ae0 Oct 1, 2019
bajtos added 2 commits Sep 30, 2019
See the discussion in
docker/for-linux#496

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
@bajtos bajtos force-pushed the fix/ci branch from 1cd3ae0 to 387835f Oct 1, 2019
@rmg

This comment has been minimized.

Copy link
Member

rmg commented Oct 2, 2019

@slnode test please

@rmg

This comment has been minimized.

Copy link
Member

rmg commented Oct 2, 2019

I made an adjustment to the Jenkins config - it was previously using a minimal image that lacked chromium-browser instead of a more standard image that has it.

@bajtos

This comment has been minimized.

Copy link
Member Author

bajtos commented Oct 3, 2019

I made an adjustment to the Jenkins config - it was previously using a minimal image that lacked chromium-browser instead of a more standard image that has it.

Thank you a lot, @rmg! 🙇

@bajtos bajtos requested a review from emonddr Oct 3, 2019
@emonddr
emonddr approved these changes Oct 3, 2019
@bajtos bajtos merged commit af9f776 into master Oct 3, 2019
50 of 56 checks passed
50 of 56 checks passed
[cis-jenkins] PR Builder Build finished.
Details
[cis-jenkins] downstream: loopback-boot@master Failed! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-openapi@master Failed! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-swagger@master Failed! (387835f)
Details
[cis-jenkins] downstream: loopback-context@master Failed! (387835f)
Details
[cis-jenkins] downstream: velox-service-broker@master Failed! (387835f)
Details
Commit Linter commits are all properly formatted
Details
PR Linter PR is up to date
Details
[cis-jenkins] downstream: angular-live-set@master Success! (387835f)
Details
[cis-jenkins] downstream: apiconnect-workspace@master Success! (387835f)
Details
[cis-jenkins] downstream: grunt-loopback-sdk-angular@master Success! (387835f)
Details
[cis-jenkins] downstream: gulp-loopback-sdk-angular@master Success! (387835f)
Details
[cis-jenkins] downstream: lb-con-test-app@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-api-definition@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-explorer@2.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-explorer@4.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-explorer@5.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-explorer@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-oauth2@2.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-oauth2@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-passport@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-push@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-component-storage@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-grpc@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-jsonrpc@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-remote@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-connector-soap@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-example-bluemix@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-getting-started-intermediate@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-getting-started@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-sandbox@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-sdk-angular-cli@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-sdk-angular@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-soap@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-swagger@3.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-swagger@4.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-swagger@master Success! (387835f)
Details
[cis-jenkins] downstream: loopback-workspace@4.x Success! (387835f)
Details
[cis-jenkins] downstream: loopback-workspace@master Success! (387835f)
Details
[cis-jenkins] downstream: microgateway-datastore@master Success! (387835f)
Details
[cis-jenkins] downstream: microgateway@1.7.x Success! (387835f)
Details
[cis-jenkins] downstream: microgateway@master Success! (387835f)
Details
[cis-jenkins] downstream: strong-arc-filesystem@master Success! (387835f)
Details
[cis-jenkins] downstream: strong-arc-project-list@master Success! (387835f)
Details
[cis-jenkins] x64 && linux && nvm,10 Success! (387835f)
Details
[cis-jenkins] x64 && linux && nvm,12 Success! (387835f)
Details
[cis-jenkins] x64 && linux && nvm,8 Success! (387835f)
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 90.308%
Details
loopback Success! (387835f)
Details
loopback/node=4.x,os=windows Success! (387835f)
Details
loopback/node=6.x,os=windows Success! (387835f)
Details
pr-builder
Details
security/snyk - package.json (StrongLoop) No new issues
Details
@bajtos bajtos deleted the fix/ci branch Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.