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-05-06 21:40:48 +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_vtgate_client_test
|
2014-05-17 01:45:16 +04:00
|
|
|
|
|
|
|
all: build test
|
2012-11-01 02:29:41 +04:00
|
|
|
|
2014-12-10 10:19:35 +03:00
|
|
|
# Values to be burned into the binary at build-time.
|
|
|
|
LDFLAGS = "\
|
|
|
|
-X github.com/youtube/vitess/go/vt/servenv.buildHost '$$(hostname)'\
|
|
|
|
-X github.com/youtube/vitess/go/vt/servenv.buildUser '$$(whoami)'\
|
|
|
|
-X github.com/youtube/vitess/go/vt/servenv.buildGitRev '$$(git rev-parse HEAD)'\
|
2015-01-22 00:10:23 +03:00
|
|
|
-X github.com/youtube/vitess/go/vt/servenv.buildTime '$$(LC_ALL=C date)'\
|
2014-12-10 10:19:35 +03:00
|
|
|
"
|
|
|
|
|
2012-11-01 02:29:41 +04:00
|
|
|
build:
|
2015-01-29 02:44:42 +03:00
|
|
|
godep go install -ldflags ${LDFLAGS} ./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-05-06 21:40:48 +03:00
|
|
|
test: unit_test queryservice_test integration_test java_vtgate_client_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/...
|
2014-06-18 22:33:29 +04:00
|
|
|
rm -rf java/vtocc-client/target java/vtocc-jdbc-driver/target third_party/acolyte
|
2012-11-01 02:29:41 +04:00
|
|
|
|
|
|
|
unit_test:
|
2015-01-29 02:44:42 +03:00
|
|
|
godep go test ./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-01-29 02:44:42 +03:00
|
|
|
godep go test -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-01-29 02:44:42 +03:00
|
|
|
godep go test -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-01-29 02:44:42 +03:00
|
|
|
go list -f '{{if len .TestGoFiles}}godep go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}{{end}}' ./go/... | xargs -i sh -c {}
|
2014-10-01 05:59:51 +04:00
|
|
|
gover ./go/
|
2015-01-02 20:07:51 +03:00
|
|
|
# Travis doesn't set the token for forked pull requests, so skip
|
|
|
|
# upload if COVERALLS_TOKEN is unset.
|
2015-01-02 19:30:30 +03:00
|
|
|
if ! [ -z "$$COVERALLS_TOKEN" ]; then \
|
|
|
|
goveralls -coverprofile=gover.coverprofile -repotoken $$COVERALLS_TOKEN; \
|
|
|
|
fi
|
2013-10-29 15:40:01 +04:00
|
|
|
|
2012-11-29 04:41:43 +04:00
|
|
|
queryservice_test:
|
2014-09-04 01:00:41 +04:00
|
|
|
echo $$(date): Running test/queryservice_test.py...
|
2012-11-02 20:49:07 +04:00
|
|
|
if [ -e "/usr/bin/memcached" ]; then \
|
2014-09-09 02:09:42 +04:00
|
|
|
time test/queryservice_test.py -m -e vtocc $$VT_TEST_FLAGS || exit 1 ; \
|
|
|
|
time test/queryservice_test.py -m -e vttablet $$VT_TEST_FLAGS || exit 1 ; \
|
2012-11-01 02:29:41 +04:00
|
|
|
else \
|
2014-09-09 02:09:42 +04:00
|
|
|
time test/queryservice_test.py -e vtocc $$VT_TEST_FLAGS || exit 1 ; \
|
|
|
|
time test/queryservice_test.py -e vttablet $$VT_TEST_FLAGS || exit 1 ; \
|
2012-11-01 02:29:41 +04:00
|
|
|
fi
|
|
|
|
|
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 \
|
|
|
|
vtgatev2_test.py \
|
|
|
|
zkocc_test.py
|
|
|
|
|
|
|
|
# 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
|
2014-10-01 05:59:51 +04:00
|
|
|
small_integration_test_files = \
|
2015-06-26 08:52:09 +03:00
|
|
|
tablet_test.py \
|
2014-12-19 21:13:53 +03:00
|
|
|
vertical_split.py \
|
|
|
|
vertical_split_vtgate.py \
|
|
|
|
schema.py \
|
2014-04-14 05:38:00 +04:00
|
|
|
keyspace_test.py \
|
|
|
|
keyrange_test.py \
|
2014-08-21 04:54:58 +04:00
|
|
|
mysqlctl.py \
|
2014-04-14 05:38:00 +04:00
|
|
|
sharded.py \
|
2014-10-01 05:59:51 +04:00
|
|
|
secure.py \
|
|
|
|
binlog.py \
|
2015-05-20 19:00:23 +03:00
|
|
|
backup.py \
|
2015-06-02 00:11:54 +03:00
|
|
|
update_stream.py \
|
|
|
|
custom_sharding.py
|
2014-10-01 05:59:51 +04:00
|
|
|
|
|
|
|
medium_integration_test_files = \
|
2014-04-14 05:38:00 +04:00
|
|
|
tabletmanager.py \
|
2014-10-01 05:59:51 +04:00
|
|
|
reparent.py \
|
2014-04-14 05:38:00 +04:00
|
|
|
vtdb_test.py \
|
2014-08-28 03:54:13 +04:00
|
|
|
vtgate_utils_test.py \
|
2015-04-01 20:53:03 +03:00
|
|
|
rowcache_invalidator.py \
|
|
|
|
worker.py
|
2014-10-01 05:59:51 +04:00
|
|
|
|
|
|
|
large_integration_test_files = \
|
2014-08-07 22:34:57 +04:00
|
|
|
vtgatev2_test.py \
|
2014-04-14 05:38:00 +04:00
|
|
|
zkocc_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
|
|
|
|
ci_skip_integration_test_files = \
|
2015-02-04 07:10:04 +03:00
|
|
|
initial_sharding_bytes.py \
|
2015-02-04 04:52:53 +03:00
|
|
|
initial_sharding.py \
|
2014-12-13 05:36:46 +03:00
|
|
|
resharding_bytes.py \
|
2015-01-18 12:14:51 +03:00
|
|
|
resharding.py
|
2014-12-13 05:12:58 +03:00
|
|
|
|
2015-01-13 07:08:44 +03:00
|
|
|
# Run the following tests after making worker changes
|
|
|
|
worker_integration_test_files = \
|
|
|
|
binlog.py \
|
|
|
|
resharding.py \
|
|
|
|
resharding_bytes.py \
|
|
|
|
vertical_split.py \
|
|
|
|
vertical_split_vtgate.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
|
|
|
|
define run_integration_tests
|
2014-04-14 05:38:00 +04:00
|
|
|
cd test ; \
|
2014-10-01 05:59:51 +04:00
|
|
|
for t in $1 ; do \
|
2014-09-04 01:00:41 +04:00
|
|
|
echo $$(date): Running test/$$t... ; \
|
2014-04-14 05:38:00 +04:00
|
|
|
output=$$(time ./$$t $$VT_TEST_FLAGS 2>&1) ; \
|
|
|
|
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
|
|
|
endef
|
|
|
|
|
|
|
|
small_integration_test:
|
|
|
|
$(call run_integration_tests, $(small_integration_test_files))
|
|
|
|
|
|
|
|
medium_integration_test:
|
|
|
|
$(call run_integration_tests, $(medium_integration_test_files))
|
|
|
|
|
|
|
|
large_integration_test:
|
|
|
|
$(call run_integration_tests, $(large_integration_test_files))
|
|
|
|
|
2014-12-13 05:12:58 +03:00
|
|
|
ci_skip_integration_test:
|
|
|
|
$(call run_integration_tests, $(ci_skip_integration_test_files))
|
|
|
|
|
2015-01-13 07:08:44 +03:00
|
|
|
worker_test:
|
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
|
|
|
|
2014-09-11 01:56:25 +04:00
|
|
|
site_integration_test:
|
2014-10-01 05:59:51 +04:00
|
|
|
$(call run_integration_tests, $(site_integration_test_files))
|
2014-09-11 01:56:25 +04:00
|
|
|
|
2014-06-18 22:33:29 +04:00
|
|
|
# this rule only works if bootstrap.sh was successfully ran in ./java
|
|
|
|
java_test:
|
|
|
|
cd java && mvn verify
|
|
|
|
|
2014-10-01 05:59:51 +04:00
|
|
|
java_vtgate_client_test:
|
|
|
|
mvn -f java/vtgate-client/pom.xml clean verify
|
|
|
|
|
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
|
|
|
|
|
|
|
# This rule rebuilds all the go files from the proto definitions for gRPC
|
2015-03-02 19:48:22 +03:00
|
|
|
# FIXME(alainjobart) also add support for python gRPC stubs, right now
|
|
|
|
# it's only the proto files without gRPC
|
2015-02-28 07:40:55 +03:00
|
|
|
proto:
|
2015-06-09 20:32:25 +03:00
|
|
|
cd go/vt/proto/vtrpc && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/vtrpc.proto --go_out=plugins=grpc:.
|
2015-06-19 18:20:58 +03:00
|
|
|
cd go/vt/proto/topodata && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/topodata.proto --go_out=plugins=grpc:.
|
|
|
|
cd go/vt/proto/replicationdata && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/replicationdata.proto --go_out=plugins=grpc:.
|
|
|
|
cd go/vt/proto/binlogdata && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/binlogdata.proto --go_out=plugins=grpc:.
|
2015-06-10 20:11:40 +03:00
|
|
|
cd go/vt/proto/binlogservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/binlogservice.proto --go_out=plugins=grpc:.
|
2015-05-05 18:45:18 +03:00
|
|
|
cd go/vt/proto/queryservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/queryservice.proto --go_out=plugins=grpc:.
|
2015-06-10 19:26:39 +03:00
|
|
|
cd go/vt/proto/query && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/query.proto --go_out=plugins=grpc:.
|
2015-06-10 19:22:08 +03:00
|
|
|
cd go/vt/proto/vtgate && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/vtgate.proto --go_out=plugins=grpc:.
|
2015-06-09 20:32:25 +03:00
|
|
|
cd go/vt/proto/vtgateservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/vtgateservice.proto --go_out=plugins=grpc:.
|
2015-06-25 17:37:19 +03:00
|
|
|
cd go/vt/proto/logutil && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/logutil.proto --go_out=plugins=grpc:.
|
2015-06-19 18:20:58 +03:00
|
|
|
cd go/vt/proto/vtctldata && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/vtctldata.proto --go_out=plugins=grpc:.
|
2015-06-10 20:39:23 +03:00
|
|
|
cd go/vt/proto/vtctlservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/vtctlservice.proto --go_out=plugins=grpc:.
|
2015-06-19 18:20:58 +03:00
|
|
|
cd go/vt/proto/tabletmanagerdata && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/tabletmanagerdata.proto --go_out=plugins=grpc:.
|
2015-06-10 19:32:15 +03:00
|
|
|
cd go/vt/proto/tabletmanagerservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/tabletmanagerservice.proto --go_out=plugins=grpc:.
|
2015-05-06 09:20:40 +03:00
|
|
|
cd go/vt/proto/automation && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/automation.proto --go_out=plugins=grpc:.
|
2015-06-10 21:35:58 +03:00
|
|
|
cd go/vt/proto/automationservice && $$VTROOT/dist/protobuf/bin/protoc -I../../../../proto ../../../../proto/automationservice.proto --go_out=plugins=grpc:.
|
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-06-25 17:37:19 +03:00
|
|
|
cd py/vtctl && $$VTROOT/dist/protobuf/bin/protoc -I../../proto ../../proto/logutil.proto --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=$$VTROOT/dist/grpc/bin/grpc_python_plugin
|
2015-06-19 18:20:58 +03:00
|
|
|
cd py/vtctl && $$VTROOT/dist/protobuf/bin/protoc -I../../proto ../../proto/vtctldata.proto --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=$$VTROOT/dist/grpc/bin/grpc_python_plugin
|
2015-06-10 20:39:23 +03:00
|
|
|
cd py/vtctl && $$VTROOT/dist/protobuf/bin/protoc -I../../proto ../../proto/vtctlservice.proto --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=$$VTROOT/dist/grpc/bin/grpc_python_plugin
|
2015-04-21 01:09:26 +03:00
|
|
|
|
|
|
|
# This rule builds a bootstrap image of the given flavor.
|
|
|
|
# Example: $ make docker_bootstrap flavor=mariadb
|
|
|
|
docker_bootstrap:
|
|
|
|
docker/bootstrap/build.sh $(flavor)
|
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-04-21 03:11:45 +03:00
|
|
|
docker/test/run.sh $(flavor) 'make test'
|
2015-04-22 06:12:20 +03:00
|
|
|
|
|
|
|
docker_unit_test:
|
|
|
|
docker/test/run.sh $(flavor) 'make unit_test'
|