2012-11-01 02:29:41 +04:00
# Copyright 2012, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
MAKEFLAGS = -s
2015-05-07 00:43:41 +03:00
# Disabled parallel processing of target prerequisites to avoid that integration tests are racing each other (e.g. for ports) and may fail.
# Since we are not using this Makefile for compilation, limiting parallelism will not increase build time.
.NOTPARALLEL :
2015-08-23 05:21:26 +03:00
.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 docker_unit_test java_test php_test
2014-05-17 01:45:16 +04:00
all : build test
2012-11-01 02:29:41 +04:00
2015-07-23 10:13:29 +03:00
# Set a custom value for -p, the number of packages to be built/tested in parallel.
# This is currently only used by our Travis CI test configuration.
# (Also keep in mind that this value is independent of GOMAXPROCS.)
i f d e f V T _ G O _ P A R A L L E L
VT_GO_PARALLEL := "-p" $( VT_GO_PARALLEL)
e n d i f
2015-07-23 10:07:47 +03:00
# Link against the MySQL library in $VT_MYSQL_ROOT if it's specified.
i f d e f V T _ M Y S Q L _ R O O T
# Clutter the env var only if it's a non-standard path.
ifneq ( $( VT_MYSQL_ROOT) ,/usr)
CGO_LDFLAGS += -L$( VT_MYSQL_ROOT) /lib
endif
e n d i f
2012-11-01 02:29:41 +04:00
build :
2015-08-21 19:51:08 +03:00
echo $$ ( date) : Building source tree
2015-07-31 23:40:44 +03:00
godep go install $( VT_GO_PARALLEL) -ldflags " $( tools/build_version_flags.sh) " ./go/...
2013-12-25 02:28:19 +04:00
2014-09-11 01:56:25 +04:00
# Set VT_TEST_FLAGS to pass flags to python tests.
# For example, verbose output: export VT_TEST_FLAGS=-v
2015-08-23 05:21:26 +03:00
test : unit_test queryservice_test integration_test java_test
2014-09-11 01:56:25 +04:00
site_test : unit_test site_integration_test
2014-05-17 01:45:16 +04:00
2013-12-25 02:28:19 +04:00
clean :
go clean -i ./go/...
2015-07-29 00:10:59 +03:00
rm -rf third_party/acolyte
2012-11-01 02:29:41 +04:00
2015-07-31 23:40:44 +03:00
# This will remove object files for all Go projects in the same GOPATH.
# This is necessary, for example, to make sure dependencies are rebuilt
# when switching between different versions of Go.
clean_pkg :
rm -rf ../../../../pkg Godeps/_workspace/pkg
2012-11-01 02:29:41 +04:00
unit_test :
2015-07-23 10:13:29 +03:00
godep go test $( VT_GO_PARALLEL) ./go/...
2012-11-01 02:29:41 +04:00
2014-05-01 00:43:22 +04:00
# Run the code coverage tools, compute aggregate.
# If you want to improve in a directory, run:
# go test -coverprofile=coverage.out && go tool cover -html=coverage.out
2014-05-01 00:13:59 +04:00
unit_test_cover :
2015-07-23 10:13:29 +03:00
godep go test $( VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py
2014-05-01 00:13:59 +04:00
2013-10-29 15:40:01 +04:00
unit_test_race :
2015-07-23 10:13:29 +03:00
godep go test $( VT_GO_PARALLEL) -race ./go/...
2013-10-29 15:40:01 +04:00
2014-12-15 21:39:20 +03:00
# Run coverage and upload to coveralls.io.
# Requires the secret COVERALLS_TOKEN env variable to be set.
2014-10-01 05:59:51 +04:00
unit_test_goveralls :
2015-08-13 02:32:37 +03:00
go list -f '{{if len .TestGoFiles}}godep go test $(VT_GO_PARALLEL) -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}{{end}}' ./go/... | xargs -i sh -c { } | tee unit_test_goveralls.txt
2014-10-01 05:59:51 +04:00
gover ./go/
2015-08-12 02:58:24 +03:00
# -shallow ensures that goveralls does not return with a failure \
# if Coveralls returns a 500 http error or higher (e.g. when the site is in read-only mode). \
goveralls -shallow -coverprofile= gover.coverprofile -service= travis-ci
2015-08-13 02:32:37 +03:00
echo
echo "Top 10 of Go packages with worst coverage:"
sort -n -k 5 unit_test_goveralls.txt | head -n10
[ -f unit_test_goveralls.txt ] && rm unit_test_goveralls.txt
2013-10-29 15:40:01 +04:00
2015-07-23 09:55:43 +03:00
ENABLE_MEMCACHED := $( shell test -x /usr/bin/memcached && echo "-m" )
queryservice_test_files = \
" queryservice_test.py $( ENABLE_MEMCACHED) -e vtocc " \
" queryservice_test.py $( ENABLE_MEMCACHED) -e vttablet "
2015-08-21 19:51:08 +03:00
queryservice_test : build
2015-07-23 09:55:43 +03:00
$( call run_integration_tests, $( queryservice_test_files) )
2012-11-01 02:29:41 +04:00
2014-09-11 01:56:25 +04:00
# These tests should be run by users to check that Vitess works in their environment.
site_integration_test_files = \
keyrange_test.py \
keyspace_test.py \
mysqlctl.py \
secure.py \
tabletmanager.py \
update_stream.py \
vtdb_test.py \
2015-08-17 18:34:18 +03:00
vtgatev2_test.py
2014-09-11 01:56:25 +04:00
# These tests should be run by developers after making code changes.
2014-12-15 21:39:20 +03:00
# Integration tests are grouped into 3 suites.
# - small: under 30 secs
# - medium: 30 secs - 1 min
# - large: over 1 min
2015-08-20 22:48:17 +03:00
small_integration_test_files = \
tablet_test.py \
sql_builder_test.py \
vertical_split.py \
schema.py \
keyspace_test.py \
keyrange_test.py \
mysqlctl.py \
python_client_test.py \
sharded.py \
secure.py \
binlog.py \
backup.py \
update_stream.py \
custom_sharding.py \
initial_sharding_bytes.py \
initial_sharding.py
medium_integration_test_files = \
tabletmanager.py \
reparent.py \
vtdb_test.py \
client_test.py \
vtgate_utils_test.py \
rowcache_invalidator.py \
worker.py \
automation_horizontal_resharding.py
large_integration_test_files = \
vtgatev2_test.py
2012-12-28 02:25:51 +04:00
2014-12-15 21:39:20 +03:00
# The following tests are considered too flaky to be included
2014-12-13 05:12:58 +03:00
# in the continous integration test suites
2015-08-20 22:48:17 +03:00
ci_skip_integration_test_files = \
resharding_bytes.py \
resharding.py
2014-12-13 05:12:58 +03:00
2015-07-23 10:32:03 +03:00
# Run the following tests after making worker changes.
2015-01-13 07:08:44 +03:00
worker_integration_test_files = \
binlog.py \
resharding.py \
resharding_bytes.py \
vertical_split.py \
initial_sharding.py \
2015-04-01 20:53:03 +03:00
initial_sharding_bytes.py \
worker.py
2015-01-13 07:08:44 +03:00
2014-04-14 05:38:00 +04:00
.ONESHELL :
SHELL = /bin/bash
2014-10-01 05:59:51 +04:00
# function to execute a list of integration test files
# exits on first failure
d e f i n e r u n _ i n t e g r a t i o n _ t e s t s
2014-04-14 05:38:00 +04:00
cd test ; \
2014-10-01 05:59:51 +04:00
for t in $1 ; do \
2015-08-21 19:51:08 +03:00
echo $$ ( date) : Running test/$$ t --skip-build ; \
output = $$ ( time timeout 5m ./$$ t $$ VT_TEST_FLAGS --skip-build 2>& 1) ; \
2015-08-19 00:39:03 +03:00
if [ [ $$ ? != 0 ] ] ; then \
2014-04-28 10:28:55 +04:00
echo " $$ output " >& 2 ; \
2014-04-14 05:38:00 +04:00
exit 1 ; \
fi ; \
echo ; \
done
2014-10-01 05:59:51 +04:00
e n d e f
2015-08-21 19:51:08 +03:00
small_integration_test : build
2015-08-20 22:48:17 +03:00
$( call run_integration_tests, $( small_integration_test_files) )
2014-10-01 05:59:51 +04:00
2015-08-21 19:51:08 +03:00
medium_integration_test : build
2015-08-20 22:48:17 +03:00
$( call run_integration_tests, $( medium_integration_test_files) )
2014-10-01 05:59:51 +04:00
2015-08-21 19:51:08 +03:00
large_integration_test : build
2015-08-20 22:48:17 +03:00
$( call run_integration_tests, $( large_integration_test_files) )
2014-10-01 05:59:51 +04:00
2015-08-21 19:51:08 +03:00
ci_skip_integration_test : build
2015-08-20 22:48:17 +03:00
$( call run_integration_tests, $( ci_skip_integration_test_files) )
2014-12-13 05:12:58 +03:00
2015-08-21 19:51:08 +03:00
worker_test : build
2015-01-29 02:44:42 +03:00
godep go test ./go/vt/worker/
2015-01-13 07:08:44 +03:00
$( call run_integration_tests, $( worker_integration_test_files) )
2014-12-13 05:36:46 +03:00
integration_test : small_integration_test medium_integration_test large_integration_test ci_skip_integration_test
2014-03-22 02:55:49 +04:00
2015-08-21 19:51:08 +03:00
site_integration_test : build
2014-10-01 05:59:51 +04:00
$( call run_integration_tests, $( site_integration_test_files) )
2014-09-11 01:56:25 +04:00
2015-08-23 05:21:26 +03:00
java_test :
godep go install ./go/cmd/vtgateclienttest
2015-07-29 00:10:59 +03:00
mvn -f java/pom.xml clean verify
2014-10-01 05:59:51 +04:00
2015-08-23 05:21:26 +03:00
php_test :
godep go install ./go/cmd/vtgateclienttest
2015-08-23 11:28:44 +03:00
php $$ PHP_FLAGS $$ ( which phpunit) php/tests
2015-08-23 05:21:26 +03:00
2014-12-06 09:12:47 +03:00
v3_test :
cd test && ./vtgatev3_test.py
2014-04-04 01:51:04 +04:00
2014-03-22 02:55:49 +04:00
bson :
2014-12-24 13:10:49 +03:00
go generate ./go/...
2015-02-28 07:40:55 +03:00
2015-07-17 00:07:11 +03:00
# This rule rebuilds all the go files from the proto definitions for gRPC.
2015-07-16 01:21:48 +03:00
# 1. list all proto files.
# 2. remove 'proto/' prefix and '.proto' suffix.
2015-07-17 00:07:11 +03:00
# 3. (go) run protoc for each proto and put in go/vt/proto/${proto_file_name}/
# 4. (python) run protoc for each proto and put in py/vtproto/
2015-02-28 07:40:55 +03:00
proto :
2015-07-16 01:21:48 +03:00
find proto -name '*.proto' -print | sed 's/^proto\///' | sed 's/\.proto//' | xargs -I{ } $$ VTROOT/dist/protobuf/bin/protoc -Iproto proto/{ } .proto --go_out= plugins = grpc:go/vt/proto/{ }
2015-06-09 20:58:01 +03:00
find go/vt/proto -name "*.pb.go" | xargs sed --in-place -r -e 's,import ([a-z0-9_]+) ".",import \1 "github.com/youtube/vitess/go/vt/proto/\1",g'
2015-07-17 00:07:11 +03:00
find proto -name '*.proto' -print | sed 's/^proto\///' | sed 's/\.proto//' | xargs -I{ } $$ VTROOT/dist/protobuf/bin/protoc -Iproto proto/{ } .proto --python_out= py/vtproto --grpc_out= py/vtproto --plugin= protoc-gen-grpc= $$ VTROOT/dist/grpc/bin/grpc_python_plugin
2015-04-21 01:09:26 +03:00
2015-06-27 03:12:04 +03:00
# This rule builds the bootstrap images for all flavors.
2015-04-21 01:09:26 +03:00
docker_bootstrap :
2015-06-27 03:12:04 +03:00
docker/bootstrap/build.sh common
docker/bootstrap/build.sh mariadb
docker/bootstrap/build.sh mysql56
2015-04-21 02:03:01 +03:00
# 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 :
2015-06-27 03:12:04 +03:00
go run test.go -flavor $( flavor)
2015-04-22 06:12:20 +03:00
docker_unit_test :
2015-06-27 03:12:04 +03:00
go run test.go -flavor $( flavor) unit