cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

Cypress will fail when run in a Docker container within CircleCI 1.0 with the --net=host option #673

Closed carlos-granados closed 7 years ago

carlos-granados commented 7 years ago

Is this a Feature or Bug?

Bug

Current behavior:

cypress run and cypress verify will hang at "Verifying Cypress can run /node_modules/cypress/dist/Cypress"

Desired behavior:

cypress run and cypress verify work normally

How to reproduce:

Run a CircleCI 1.0 test run with this circle.yml config file:

machine:
  pre:
    - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
  services:
    - docker
  node:
    version: v6.1.0

Enable SSH for the build and SSH into it once it finishes setting things up

Run

docker run -it --net=host --entrypoint bash cypress/base

to create a docker container using the official cypress base image and bash into it. Then run

npm install cypress --save-dev
$(npm bin)/cypress verify

Cypress will stop at "Verifying Cypress can run /node_modules/cypress/dist/Cypress" and will not go any further. This is the output I see if I run it with DEBUG=cypress:*

  cypress:cli cli starts with arguments ["/usr/local/bin/node","/node_modules/.bin/cypress","verify"] +0ms
  cypress:cli verifying Cypress app +206ms
  cypress:cli path to info.json file /node_modules/cypress/dist/info.json +3ms
  cypress:cli { version: '0.20.1' } +5ms
  cypress:cli installed version is 0.20.1 comparing to 0.20.1 +4ms
  cypress:cli checking if executable exists /node_modules/cypress/dist/Cypress/Cypress +0ms
  cypress:cli path to info.json file /node_modules/cypress/dist/info.json +2ms
  cypress:cli has verified version undefined +1ms
  cypress:cli run verification check? true +0ms
  cypress:cli running binary verification check 0.20.1 +0ms
It looks like this is your first time using Cypress: 0.20.1

  cypress:cli writing verified version string "null" +6ms
  cypress:cli path to info.json file /node_modules/cypress/dist/info.json +1ms
  cypress:cli path to info.json file /node_modules/cypress/dist/info.json +1ms
  cypress:cli running smoke test +4ms
  cypress:cli using Cypress executable /node_modules/cypress/dist/Cypress/Cypress +0ms
  cypress:cli needs XVFB? true +0ms
  cypress:cli Starting XVFB +0ms
 ⠹  Verifying Cypress can run /node_modules/cypress/dist/Cypress

Note: this will work fine if I remove --net=host when launching the container. It also works fine if I run this container locally (not within CircleCI)

brian-mann commented 7 years ago

I know this sidesteps the issue here - but we run everything in Circle 2.0 with docker. Circle 1.0 just works as is (without using Docker). They already have all the dependencies installed to run Cypress.

Can you switch to either:

carlos-granados commented 7 years ago

We are trying to move to Circle 2.0 but it is taking longer than expected as we have a quite complicated set up with several containers tied together by docker-compose. I will try to run it without using docker in 1.0

carlos-granados commented 7 years ago

When trying to run the tests in CircleCI 1.0 without using docker, Cypress will crash just after running the tests and uploading the video, with this message:

EEXIST: file already exists, mkdir '/tmp/circle-artifacts.jxoLodA/cypress'
Error: EEXIST: file already exists, mkdir '/tmp/circle-artifacts.jxoLodA/cypress'
    at Error (native)

The weird thing is that if I SSH into the container and run Cypress then it works fine

brian-mann commented 7 years ago

At the end of the run Cypress will copy circle artifacts. This is undocumented behavior and will be removed likely in the next major release. You can turn off artifact copying with COPY_CIRCLE_ARTIFACTS=false

carlos-granados commented 7 years ago

I got this working in CircleCI by not using Docker as you suggested. Would you like me to close this issue or do you want to investigate this any further?

brian-mann commented 7 years ago

Yes, going to close the issue.

I'm not sure what if anything we could do on our end to fix this. The docker containers work, but its possible the environment they're being launched in (Circle 1.0) have constrained resources which make it crash.