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

Ease execution of tests using Docker => simpler setup instructions in readme #60

Closed
adrienjoly opened this issue Jul 13, 2017 · 6 comments

Comments

@adrienjoly
Copy link
Member

adrienjoly commented Jul 13, 2017

When running:

$ docker-compose up
$ docker-compose exec web npm test

Unit tests are running fine, but getting error mongo: not found when test-reset npm script tries to re-init the testing database.

@adrienjoly adrienjoly created this issue from a note in Development (🏃‍ In progress) Jul 13, 2017
@adrienjoly adrienjoly self-assigned this Jul 13, 2017
@adrienjoly adrienjoly added the bug label Jul 13, 2017
@adrienjoly
Copy link
Member Author

Hypothesis:

This is caused by the fact that mongodb is reachable only by the mongo service, not the web service on which the npm test command is executed.

@adrienjoly
Copy link
Member Author

=> Trying to add the following lines in Dockerfile:

RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN sudo apt-get install -y mongodb-org-shell
RUN sudo apt-get install -y mongodb-org-tools

(as recommended there: http://corpus.hubwiz.com/2/node.js/27050643.html)

@adrienjoly
Copy link
Member Author

...then:

$ docker-compose build

(as recommended there: docker/compose#1487 (comment))

=> getting sudo: not found

=> trying without sudo

@adrienjoly
Copy link
Member Author

getting Unable to locate package mongodb-org-shell

=> replacing new lines in Dockerfile by:

RUN apt-get update
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN apt-get install -y mongodb

(as recommended there: https://stackoverflow.com/a/28966356/592254 and https://hub.docker.com/r/richardxxx0x/docker-leanote/builds/bh3enhrdrfscxzrgxxybqol/)

=> now getting couldn't connect to server 127.0.0.1:27017:

> mongo openwhyd_test --eval "db.dropDatabase();" && mongo openwhyd_test ../whydDB/initdb.js && mongo openwhyd_test ../whydDB/initdb_team.js

MongoDB shell version: 2.4.10
connecting to: openwhyd_test
Thu Jul 13 09:04:10.052 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed

=> Considering another alternative: run mongodb init scripts from the app server instead.

@adrienjoly
Copy link
Member Author

adrienjoly commented Jul 13, 2017

(WIP) currently experimenting with:

  • running db init scripts from web server (app.js) --> 4e7674c
  • clearing the database and starting/stoping web server from the acceptance test script

current problem: it seems complicated to mix webdriver-based code (synchronous) and callback-based code with console.logs. => my tests start running before I'm done with my before() checks and db inits...

EDIT: it would probably make more sense to execute just unit tests in the container, while providing an easy way to run acceptance/end-to-end tests from outside the container (but connecting to the app server running inside the container)

@adrienjoly adrienjoly moved this from 🏃‍ In progress to 📓 Backlog / Next in Development Jul 15, 2017
@adrienjoly adrienjoly moved this from 📓 Backlog / Next to 📥 Inbox / ideas in Development Jul 20, 2017
@adrienjoly adrienjoly changed the title BUG: acceptance tests don't run in docker because of "mongo: not found" error Ease execution of tests using Docker => simpler setup instructions in readme Jul 27, 2017
@adrienjoly
Copy link
Member Author

Different approach was chosen: run tests outside of Docker container,
but enable DB to be also updated from the outside, in order for test scripts to reset the database (#81)

@adrienjoly adrienjoly moved this from 📥 Inbox / ideas to ✔️ Done / pending QA in Development Aug 12, 2017
@adrienjoly adrienjoly moved this from ✔️ Done / pending QA to 🌲 In production in Development Aug 13, 2017
@adrienjoly adrienjoly added this to 🎉 Done! in Openwhyd's Roadmap Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development
  
🌲 In production
Openwhyd's Roadmap
  
🎉 Done!
Development

No branches or pull requests

1 participant