зеркало из https://github.com/github/vitess-gh.git
Add Makefile rule to run tests inside Docker.
This will let contributors test changes without having to do bootstrap at all. It also makes it easy to test against multiple flavors without having to swap out installed packages. You can even run tests against multiple flavors simultaneously without interfering, if you have enough RAM.
This commit is contained in:
Родитель
89cb8a5a01
Коммит
3a8ec3799a
8
Makefile
8
Makefile
|
@ -4,7 +4,7 @@
|
|||
|
||||
MAKEFLAGS = -s
|
||||
|
||||
.PHONY: all build test clean unit_test unit_test_cover unit_test_race queryservice_test integration_test bson proto site_test site_integration_test docker_bootstrap
|
||||
.PHONY: all build test clean unit_test unit_test_cover unit_test_race queryservice_test integration_test bson proto site_test site_integration_test docker_bootstrap docker_test
|
||||
|
||||
all: build test
|
||||
|
||||
|
@ -185,3 +185,9 @@ proto:
|
|||
# Example: $ make docker_bootstrap flavor=mariadb
|
||||
docker_bootstrap:
|
||||
docker/bootstrap/build.sh $(flavor)
|
||||
|
||||
# This rule loads the working copy of the code into a bootstrap image,
|
||||
# and then runs the tests inside Docker.
|
||||
# Example: $ make docker_test flavor=mariadb
|
||||
docker_test:
|
||||
docker/test/run.sh $(flavor)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
flavor=$1
|
||||
|
||||
if [[ -z "$flavor" ]]; then
|
||||
echo "Flavor must be specified as first argument."
|
||||
exit 1
|
||||
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
|
||||
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="$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`
|
||||
testid=`basename $hostdir`
|
||||
|
||||
echo "Mounting host dir $hostdir as VTDATAROOT"
|
||||
args="$args -v $hostdir:/vt/vtdataroot --name=$testid"
|
||||
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'
|
||||
|
||||
# Clean up host dir mounted VTDATAROOT
|
||||
if [[ -n "$hostdir" ]]; then
|
||||
rm -rf $hostdir
|
||||
fi
|
Загрузка…
Ссылка в новой задаче