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

Explicitly specify the name of the container running tests in Jenkins #316

Merged
merged 5 commits into from Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions docker/jenkins-test.sh
Expand Up @@ -2,14 +2,14 @@

# Modify these two as needed:
COMPOSE_FILE_LOC="docker/docker-compose.jenkins.yml"
TEST_CONTAINER_NAME="acousticbrainz"
TEST_SERVICE_NAME="acousticbrainz"

COMPOSE_PROJECT_NAME_ORIGINAL="jenkinsbuild_${BUILD_TAG}"

# Project name is sanitized by Compose, so we need to do the same thing.
# See https://github.com/docker/compose/issues/2119.
COMPOSE_PROJECT_NAME=$(echo $COMPOSE_PROJECT_NAME_ORIGINAL | awk '{print tolower($0)}' | sed 's/[^a-z0-9]*//g')
TEST_CONTAINER_REF="${COMPOSE_PROJECT_NAME}_${TEST_CONTAINER_NAME}_run_1"
TEST_CONTAINER_REF="${COMPOSE_PROJECT_NAME}_${TEST_SERVICE_NAME}_run_1"

# Record installed version of Docker and Compose with each build
echo "Docker environment:"
Expand Down Expand Up @@ -46,14 +46,17 @@ function run_tests {

# create database and user once
echo "creating user and database"
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME run --rm $TEST_CONTAINER_NAME \
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME run --rm $TEST_SERVICE_NAME \
dockerize \
-wait tcp://db:5432 -timeout 60s bash -c \
"cd /code && cp config.py.example config.py && ls -lR && python manage.py init_db"

# run tests
echo "running tests"
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME run $TEST_CONTAINER_NAME \
# NOTE: we specify container name here so that we have a consistent name, allowing
# us to copy over the test results later in the script. The container name contains
# a reference to the jenkins tag, so it won't conflict with other test runs.
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME run --name $TEST_CONTAINER_REF $TEST_SERVICE_NAME \
dockerize \
-wait tcp://db:5432 -timeout 60s \
-wait tcp://redis:6379 -timeout 60s \
Expand Down