Skip to content

Commit

Permalink
Merge pull request #316 from paramsingh/jenkins-fix
Browse files Browse the repository at this point in the history
Explicitly specify the name of the container running tests in Jenkins
  • Loading branch information
paramsingh committed Jan 17, 2019
2 parents 000e3b5 + 0f2a628 commit a602d31
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit a602d31

Please sign in to comment.