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:
|
|
|
|
|
2016-03-16 22:30:02 +03:00
|
|
|
.PHONY: all build test clean unit_test unit_test_cover unit_test_race integration_test proto site_test site_integration_test docker_bootstrap docker_test docker_unit_test java_test php_test reshard_tests
|
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.)
|
|
|
|
ifdef VT_GO_PARALLEL
|
|
|
|
VT_GO_PARALLEL := "-p" $(VT_GO_PARALLEL)
|
|
|
|
endif
|
2015-07-23 10:07:47 +03:00
|
|
|
# Link against the MySQL library in $VT_MYSQL_ROOT if it's specified.
|
|
|
|
ifdef VT_MYSQL_ROOT
|
|
|
|
# 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
|
|
|
|
endif
|
|
|
|
|
2012-11-01 02:29:41 +04:00
|
|
|
build:
|
2015-10-18 04:01:32 +03:00
|
|
|
ifndef NOBANNER
|
2015-08-21 19:51:08 +03:00
|
|
|
echo $$(date): Building source tree
|
2015-10-18 04:01:32 +03:00
|
|
|
endif
|
2016-04-07 00:52:31 +03:00
|
|
|
go install $(VT_GO_PARALLEL) -ldflags "$(tools/build_version_flags.sh)" ./go/...
|
2013-12-25 02:28:19 +04:00
|
|
|
|
2015-08-24 23:44:52 +03:00
|
|
|
# To pass extra flags, run test.go manually.
|
|
|
|
# For example: go run test.go -docker=false -- --extra-flag
|
|
|
|
# For more info see: go run test.go -help
|
2015-08-24 05:51:42 +03:00
|
|
|
test:
|
|
|
|
go run test.go -docker=false
|
|
|
|
|
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
|
|
|
|
|
2015-09-22 19:40:39 +03:00
|
|
|
unit_test: build
|
|
|
|
echo $$(date): Running unit tests
|
2016-04-07 00:52:31 +03:00
|
|
|
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
|
2015-09-22 19:40:39 +03:00
|
|
|
unit_test_cover: build
|
2016-04-07 00:52:31 +03:00
|
|
|
go test $(VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py
|
2014-05-01 00:13:59 +04:00
|
|
|
|
2015-09-22 19:40:39 +03:00
|
|
|
unit_test_race: build
|
2015-11-23 04:35:22 +03:00
|
|
|
tools/unit_test_race.sh
|
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.
|
2015-09-22 19:40:39 +03:00
|
|
|
unit_test_goveralls: build
|
2015-08-23 13:33:46 +03:00
|
|
|
travis/goveralls.sh
|
2013-10-29 15:40:01 +04:00
|
|
|
|
2014-04-14 05:38:00 +04:00
|
|
|
.ONESHELL:
|
|
|
|
SHELL = /bin/bash
|
2014-10-01 05:59:51 +04:00
|
|
|
|
2015-08-24 05:51:42 +03:00
|
|
|
# Run the following tests after making worker changes.
|
|
|
|
worker_test:
|
2016-04-07 00:52:31 +03:00
|
|
|
go test ./go/vt/worker/
|
2015-10-29 23:27:23 +03:00
|
|
|
go run test.go -docker=false -tag=worker_test
|
2015-01-13 07:08:44 +03:00
|
|
|
|
2015-08-24 05:51:42 +03:00
|
|
|
site_integration_test:
|
2015-10-29 23:27:23 +03:00
|
|
|
go run test.go -docker=false -tag=site_test
|
2014-09-11 01:56:25 +04:00
|
|
|
|
2015-08-23 05:21:26 +03:00
|
|
|
java_test:
|
2016-05-27 06:36:52 +03:00
|
|
|
go install ./go/cmd/vtgateclienttest ./go/cmd/vtcombo
|
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:
|
2016-04-07 00:52:31 +03:00
|
|
|
go install ./go/cmd/vtgateclienttest
|
2015-10-08 11:04:33 +03:00
|
|
|
phpunit php/tests
|
2015-08-23 05:21:26 +03:00
|
|
|
|
2016-04-21 00:17:00 +03:00
|
|
|
# TODO(mberlin): Remove the manual copy once govendor supports a way to
|
|
|
|
# install vendor'd programs: https://github.com/kardianos/govendor/issues/117
|
2016-04-22 01:18:13 +03:00
|
|
|
install_protoc-gen-go:
|
2016-04-21 00:17:00 +03:00
|
|
|
mkdir -p $${GOPATH}/src/github.com/golang/
|
|
|
|
cp -au vendor/github.com/golang/protobuf $${GOPATH}/src/github.com/golang/
|
|
|
|
go install github.com/golang/protobuf/protoc-gen-go
|
|
|
|
|
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/
|
2016-04-21 00:17:00 +03:00
|
|
|
proto: install_protoc-gen-go
|
2016-01-23 01:28:53 +03:00
|
|
|
find proto -maxdepth 1 -name '*.proto' -print | sed 's/^proto\///' | sed 's/\.proto//' | xargs -I{} $$VTROOT/dist/grpc/usr/local/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'
|
2016-01-23 01:28:53 +03:00
|
|
|
find proto -maxdepth 1 -name '*.proto' -print | sed 's/^proto\///' | sed 's/\.proto//' | xargs -I{} $$VTROOT/dist/grpc/usr/local/bin/protoc -Iproto proto/{}.proto --python_out=py/vtproto --grpc_out=py/vtproto --plugin=protoc-gen-grpc=$$VTROOT/dist/grpc/usr/local/bin/grpc_python_plugin
|
2015-04-21 01:09:26 +03:00
|
|
|
|
2016-05-05 23:16:18 +03:00
|
|
|
# Generate the PHP proto files in a Docker container, and copy them back.
|
|
|
|
php_proto:
|
|
|
|
docker run -ti --name=vitess_php-proto -v $$PWD/proto:/in vitess/bootstrap:common bash -c 'cd $$VTTOP && mkdir -p proto && cp -R /in/* proto/ && tools/proto-gen-php.sh'
|
2016-05-05 00:48:50 +03:00
|
|
|
docker cp vitess_php-proto:/vt/src/github.com/youtube/vitess/php/src/descriptor.php php/src/
|
|
|
|
docker cp vitess_php-proto:/vt/src/github.com/youtube/vitess/php/src/php.php php/src/
|
2016-05-05 23:16:18 +03:00
|
|
|
rm -r php/src/Vitess/Proto/*
|
2016-05-05 00:18:32 +03:00
|
|
|
docker cp vitess_php-proto:/vt/src/github.com/youtube/vitess/php/src/Vitess/Proto/. php/src/Vitess/Proto/
|
2016-05-05 00:48:50 +03:00
|
|
|
docker rm vitess_php-proto
|
2016-05-05 00:18:32 +03:00
|
|
|
|
2015-06-27 03:12:04 +03:00
|
|
|
# This rule builds the bootstrap images for all flavors.
|
2016-05-26 09:01:51 +03:00
|
|
|
DOCKER_IMAGES_FOR_TEST = mariadb mysql56 mysql57 percona
|
|
|
|
DOCKER_IMAGES = common $(DOCKER_IMAGES_FOR_TEST)
|
2015-04-21 01:09:26 +03:00
|
|
|
docker_bootstrap:
|
2016-05-26 09:01:51 +03:00
|
|
|
for i in $(DOCKER_IMAGES); do echo "image: $$i"; docker/bootstrap/build.sh $$i || exit 1; done
|
|
|
|
|
|
|
|
docker_bootstrap_test:
|
2016-06-24 21:44:06 +03:00
|
|
|
flavors='$(DOCKER_IMAGES_FOR_TEST)' && ./test.go -pull=false -parallel=4 -flavor=$${flavors// /,}
|
2016-05-26 09:01:51 +03:00
|
|
|
|
|
|
|
docker_bootstrap_push:
|
|
|
|
for i in $(DOCKER_IMAGES); do echo "image: $$i"; docker push vitess/bootstrap:$$i || exit 1; done
|
2015-04-21 02:03:01 +03:00
|
|
|
|
2015-08-26 00:12:57 +03:00
|
|
|
docker_base:
|
|
|
|
# Fix permissions before copying files, to avoid AUFS bug.
|
|
|
|
chmod -R o=g *
|
|
|
|
docker build -t vitess/base .
|
|
|
|
|
2016-05-19 22:50:28 +03:00
|
|
|
docker_base_mysql56:
|
|
|
|
chmod -R o=g *
|
|
|
|
docker build -f Dockerfile.percona -t vitess/base:mysql56 .
|
|
|
|
|
2016-03-05 02:48:34 +03:00
|
|
|
docker_base_percona:
|
|
|
|
chmod -R o=g *
|
|
|
|
docker build -f Dockerfile.percona -t vitess/base:percona .
|
|
|
|
|
|
|
|
docker_base_mariadb:
|
|
|
|
chmod -R o=g *
|
|
|
|
docker build -f Dockerfile.mariadb -t vitess/base:mariadb .
|
|
|
|
|
2016-06-30 00:31:54 +03:00
|
|
|
docker_lite: docker_base
|
2015-08-26 00:12:57 +03:00
|
|
|
cd docker/lite && ./build.sh
|
|
|
|
|
2016-06-30 00:31:54 +03:00
|
|
|
docker_lite_mysql56: docker_base_mysql56
|
2016-05-19 22:50:28 +03:00
|
|
|
cd docker/lite && ./build.sh mysql56
|
|
|
|
|
2016-06-30 00:31:54 +03:00
|
|
|
docker_lite_mariadb: docker_base_mariadb
|
2016-03-05 02:48:34 +03:00
|
|
|
cd docker/lite && ./build.sh mariadb
|
|
|
|
|
2016-06-30 00:31:54 +03:00
|
|
|
docker_lite_percona: docker_base_percona
|
2016-03-05 02:48:34 +03:00
|
|
|
cd docker/lite && ./build.sh percona
|
|
|
|
|
2015-08-26 00:12:57 +03:00
|
|
|
docker_guestbook:
|
|
|
|
cd examples/kubernetes/guestbook && ./build.sh
|
|
|
|
|
2015-10-16 01:50:31 +03:00
|
|
|
docker_etcd:
|
|
|
|
cd docker/etcd-lite && ./build.sh
|
|
|
|
|
2016-04-06 02:11:53 +03:00
|
|
|
docker_publish_site:
|
|
|
|
docker build -f docker/publish-site/Dockerfile -t vitess/publish-site .
|
|
|
|
|
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
|
2015-08-24 05:51:42 +03:00
|
|
|
|
2015-08-24 07:56:06 +03:00
|
|
|
# This can be used to rebalance the total average runtime of each group of
|
|
|
|
# tests in Travis. The results are saved in test/config.json, which you can
|
|
|
|
# then commit and push.
|
|
|
|
rebalance_tests:
|
|
|
|
go run test.go -rebalance 5 -remote-stats http://enisoc.com:15123/travis/stats
|