diff --git a/Makefile b/Makefile index 98664faadeb..7e10943950c 100644 --- a/Makefile +++ b/Makefile @@ -190,4 +190,4 @@ docker_bootstrap: # and then runs the tests inside Docker. # Example: $ make docker_test flavor=mariadb docker_test: - docker/test/run.sh $(flavor) + docker/test/run.sh $(flavor) 'make test' diff --git a/docker/bootstrap/Dockerfile.common b/docker/bootstrap/Dockerfile.common index 91f06146bb7..60c5683dd02 100644 --- a/docker/bootstrap/Dockerfile.common +++ b/docker/bootstrap/Dockerfile.common @@ -32,9 +32,6 @@ RUN cd /tmp && \ pip install -r src/python/requirements.txt && \ pip install src/python/src -# Create mount point for actual data (e.g. MySQL data dir) -VOLUME /vt/vtdataroot - # Set up Vitess environment (equivalent to '. dev.env') ENV VTTOP /vt/src/github.com/youtube/vitess ENV VTROOT /vt @@ -57,7 +54,10 @@ COPY . /vt/src/github.com/youtube/vitess # Create vitess user RUN groupadd -r vitess && useradd -r -g vitess vitess && \ - chown -R vitess:vitess /vt + mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt + +# Create mount point for actual data (e.g. MySQL data dir) +VOLUME /vt/vtdataroot # If the user doesn't specify a command, load a shell. CMD ["/bin/bash"] diff --git a/docker/test/run.sh b/docker/test/run.sh index c69be8a13c5..e37ed05db60 100755 --- a/docker/test/run.sh +++ b/docker/test/run.sh @@ -1,12 +1,17 @@ #!/bin/bash flavor=$1 +cmd=$2 if [[ -z "$flavor" ]]; then echo "Flavor must be specified as first argument." exit 1 fi +if [[ -z "$cmd" ]]; then + cmd=bash +fi + if [[ ! -f bootstrap.sh ]]; then echo "This script should be run from the root of the Vitess source tree - e.g. ~/src/github.com/youtube/vitess" exit 1 @@ -15,22 +20,26 @@ fi # To avoid AUFS permission issues, files must allow access by "other" chmod -R o=g * -args="-ti --rm -v /dev/log:/dev/log" +args="-ti --rm -e USER=vitess -v /dev/log:/dev/log" args="$args -v $PWD:/tmp/src" # Mount in host VTDATAROOT if one exists, since it might be a RAM disk or SSD. if [[ -n "$VTDATAROOT" ]]; then - hostdir=`mktemp -d --tmpdir=$VTDATAROOT test.XXX` + hostdir=`mktemp -d --tmpdir=$VTDATAROOT test-XXX` testid=`basename $hostdir` + chmod 777 $hostdir + echo "Mounting host dir $hostdir as VTDATAROOT" - args="$args -v $hostdir:/vt/vtdataroot --name=$testid" + args="$args -v $hostdir:/vt/vtdataroot --name=$testid -h $testid" +else + args="$args -h test" fi # Run tests echo "Running tests in vitess/bootstrap:$flavor image..." docker run $args vitess/bootstrap:$flavor \ - bash -c 'rm -rf * && cp -R /tmp/src/* . && rm -rf Godeps/_workspace/pkg && make test' + bash -c "rm -rf * && cp -R /tmp/src/* . && rm -rf Godeps/_workspace/pkg && $cmd" # Clean up host dir mounted VTDATAROOT if [[ -n "$hostdir" ]]; then