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

Docker-compose in Docker for e2e testing #125

Open
mmckeon16 opened this issue Jan 8, 2021 · 3 comments
Open

Docker-compose in Docker for e2e testing #125

mmckeon16 opened this issue Jan 8, 2021 · 3 comments

Comments

@mmckeon16
Copy link

I am using this library to run browser tests in a dockerized environment. This works well, but I have another scenario when the browser tests themselves need to run in a dockerized environment during an end to end test. This was working when my team was using spawn from react-dev-utils/crossSpawn to run docker-compose, but we are trying to switch to this library so we do not have to manage it.
When any docker-compose command is called from the dockerized environment with this library, the process fails with:

err:  Error: spawn docker-compose ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn docker-compose',
  path: 'docker-compose',

no matter which command is run.

I have made a repo here that exemplifies this problem, with and without the working version using crossSpawn from react-dev-utils.

Not sure if I am missing some config, or if it is another issue, but I would appreciate any and all help resolving this.

@AlexZeitler
Copy link
Contributor

@mmckeon16 Thanks for providing the repro.

I've changed https://github.com/mmckeon16/docker-compose-in-docker/blob/master/tasks/e2e.test.sh#L14 to look like this:

node ./scripts/browser-tests.js --working

I've run yarn in the root directory of the repro and I've run yarn inside the e2e-example directory.

Then I've run yarn docker:e2e-test.

This is the output I got:

yarn run v1.22.4
warning package.json: No license field
$ docker-compose down -v && docker-compose run e2e
Stopping docker-compose-in-docker_selenium-chrome_1      ... done
Stopping docker-compose-in-docker_localserver.info.com_1 ... done
Removing docker-compose-in-docker_e2e_run_69a78ed54e03   ... done
Removing docker-compose-in-docker_selenium-chrome_1      ... done
Removing docker-compose-in-docker_localserver.info.com_1 ... done
Removing network docker-compose-in-docker_default
Removing volume docker-compose-in-docker_overlay-node_modules
Creating network "docker-compose-in-docker_default" with the default driver
Creating volume "docker-compose-in-docker_overlay-node_modules" with default driver
Creating docker-compose-in-docker_selenium-chrome_1      ... done
Creating docker-compose-in-docker_localserver.info.com_1 ... done
Creating docker-compose-in-docker_e2e_run                ... done
using node version
v12.20.1
yarn run v1.22.5
warning ../package.json: No license field
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  41.21 KB  build/static/js/2.7b391e01.chunk.js
  1.4 KB    build/static/js/3.9abfea1d.chunk.js
  1.17 KB   build/static/js/runtime-main.d5ad7ea2.js
  596 B     build/static/js/main.1463f971.chunk.js
  531 B     build/static/css/main.8c8b27cf.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

Done in 26.39s.
build run
starting environment
in working version
Waiting for environment...
Running tests...
now running the following config: npx,wdio,test/browser/config/docker.conf.js
err:  Error: spawn docker-compose ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn docker-compose',
  path: 'docker-compose',
  spawnargs: [
    '-p',
    'e2e-example',
    '-f',
    '/usr/src/app/e2e-example/scripts/docker/base.yml',
    'exec',
    '-T',
    'project',
    'npx',
    'wdio',
    'test/browser/config/docker.conf.js'
  ]
}
error code:  undefined
✨  Done in 30.74s.

If I don't enable the --working flag, I get this output:

yarn run v1.22.4
warning package.json: No license field
$ docker-compose down -v && docker-compose run e2e
Stopping docker-compose-in-docker_selenium-chrome_1      ... done
Stopping docker-compose-in-docker_localserver.info.com_1 ... done
Removing docker-compose-in-docker_e2e_run_8349bf4d1e85   ... done
Removing docker-compose-in-docker_selenium-chrome_1      ... done
Removing docker-compose-in-docker_localserver.info.com_1 ... done
Removing network docker-compose-in-docker_default
Removing volume docker-compose-in-docker_overlay-node_modules
Creating network "docker-compose-in-docker_default" with the default driver
Creating volume "docker-compose-in-docker_overlay-node_modules" with default driver
Creating docker-compose-in-docker_selenium-chrome_1      ... done
Creating docker-compose-in-docker_localserver.info.com_1 ... done
Creating docker-compose-in-docker_e2e_run                ... done
using node version
v12.20.1
yarn run v1.22.5
warning ../package.json: No license field
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  41.21 KB  build/static/js/2.7b391e01.chunk.js
  1.4 KB    build/static/js/3.9abfea1d.chunk.js
  1.17 KB   build/static/js/runtime-main.d5ad7ea2.js
  596 B     build/static/js/main.1463f971.chunk.js
  531 B     build/static/css/main.8c8b27cf.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

Done in 28.29s.
build run
starting environment
err:  Error: spawn docker-compose ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn docker-compose',
  path: 'docker-compose',
  spawnargs: [
    '-p',
    'e2e-example',
    '-f',
    '/usr/src/app/e2e-example/scripts/docker/base.yml',
    'up',
    '--build',
    '-d',
    'project'
  ]
}
error code:  undefined
✨  Done in 32.68s.

I guess the spawn error when enabling --working is expected?

@mmckeon16
Copy link
Author

Yes, sorry if that was unclear. I only replaced the "start environment" part of the test with crossSpawn when there's the --working tag. With the --working tag, the test gets further along until the browser should be executed, and isn't really "working" completely either, it's just working when starting the environemnt

@AlexZeitler
Copy link
Contributor

@mmckeon16 Thanks for the clarification. Right now, tbh I don't have an idea what may cause this problem.

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

No branches or pull requests

2 participants