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

Testing in docker #118

Merged
merged 11 commits into from Feb 8, 2017
Merged

Testing in docker #118

merged 11 commits into from Feb 8, 2017

Conversation

mayhem
Copy link
Member

@mayhem mayhem commented Feb 8, 2017

This branch fixes and cleans up the unit test setup. We now have a test.sh script that will start the needed containers and run tests in the most expedient way possible. Also, testing happens in isolated containers that do not interfere with production containers/volumes.

mayhem and others added 11 commits February 2, 2017 00:25
…t.py file

that gives a test env for the test containers.
It's a good idea to have it for the workers that are going to connect
to an external service so that they can wait for those external
containers to come up before running
Add options to start the test database containers and leave them
running so that running tests during development will be faster
Running the script if no containers exist will cause them to be
started and set up before running the tests.
Copy link
Collaborator

@alastair alastair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shiny 🎆

@mayhem mayhem merged commit 5da77b9 into master Feb 8, 2017
Copy link
Contributor

@gentlecat gentlecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is docker/docker-compose.prod.yml file even needed anymore? We don't start services with compose in production.

# docker ps -a --no-trunc | grep $COMPOSE_PROJECT_NAME \
# | awk '{print $1}' | xargs -r --no-run-if-empty docker stop
# docker ps -a --no-trunc | grep $COMPOSE_PROJECT_NAME \
# | awk '{print $1}' | xargs -r --no-run-if-empty docker rm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this stuff need to be here (commented out)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I don't think so



if [[ ! -d "docker" ]]; then
echo "This script must be run from the top level directory of the listenbrainz-server source."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do something like this to make it easier to use: metabrainz/sir#11 (comment) (cd "$(dirname "${BASH_SOURCE[0]}")/../").



function bring_up_db {
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME up -d db influx redis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this separation necessary when the dependencies are defined in the compose file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, perhaps not needed. I originally had it because I did

docker-compose up <databases>
docker-compose run listenbrainz dockerize ... <setup db>
docker-compose up -d
docker-compose logs -f listenbrainz

then I realised that we could skip the up -d and logs and just run py.test straight from docker-compose run.
In this case, if we run docker-compose run listenbrainz dockerize ... <setup db> then it should load the database containers first, right?

@alastair
Copy link
Collaborator

alastair commented Feb 8, 2017

Yes, I'd be really happy to remove docker-compose.prod.yml. The idea would be that we have docker-compose.yml for development and .test. for unit tests, right??

Do you think we also need a different Dockerfile and Dockerfile.prod? Looking at the case for LB, I think that they do 99% the same thing?

@gentlecat
Copy link
Contributor

You'll probably need a separate Dockerfile if you want to deploy on the new infrastructure.

@gentlecat
Copy link
Contributor

As a side note: if you want me to review something next time, I'd appreciate to be given more than half an hour.

@mayhem mayhem deleted the testing-in-docker branch February 27, 2017 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants