Use test.go for Travis and "make test".

This commit is contained in:
Anthony Yeh 2015-08-23 19:51:42 -07:00
Родитель 3ac1c1c211
Коммит 1ac3d8166a
4 изменённых файлов: 289 добавлений и 215 удалений

Просмотреть файл

@ -47,7 +47,6 @@ cache:
# Maven repository for Java dependencies.
- $HOME/.m2
- $HOME/php
- $HOME/gopath/src/github.com/youtube/vitess/test/stats.json
before_cache:
# Travis CI caching doesn't work with this symlink. Just delete it.
- rm $HOME/gopath/bin/zksrv.sh
@ -62,26 +61,22 @@ env:
# Enable parallel compilation e.g. for gRPC.
# (The Travis CI worker is allowed to use up to 2 cores, but as of 07/2015 4 parallel compilations is actually faster.)
- MAKEFLAGS=-j4
# Uncomment the next line to debug Python integration tests.
# NOTE: When -k is enabled, subsequent tests will fail because the test directory is not empty.
# I.e. modify the Makefile to make sure that the test to be debugged is run first.
#- VT_TEST_FLAGS="-v -k"
# Run go build and test with -p 4 (i.e. up to 4 packages are compiled/tested in parallel).
# As of 07/2015 this value works best in a Travis CI container.
- VT_GO_PARALLEL=4
- PHP_FLAGS="-d extension=$HOME/php/mongo.so"
- PATH="$HOME/php:$PATH"
- TEST_FLAGS="-docker=false -timeout 9m -follow -remote-stats http://enisoc.com:15123/travis/stats"
matrix:
# NOTE: Travis CI schedules up to 5 tests simultaneously.
# All our tests should be spread out as evenly as possible across these 5 slots.
# We should always utilize all 5 slots because the cost of the setup is high (up to one minute).
# NOTE: Use "" if you specify a space separated list of multiple targets.
- MAKE_TARGET="unit_test build java_test php_test queryservice_test"
- MAKE_TARGET="unit_test_race unit_test_goveralls"
# Run large tests first because they take longer than medium. This way, it evens out better when tests get queued.
- MAKE_TARGET="build large_integration_test ci_skip_integration_test"
- MAKE_TARGET="build small_integration_test"
- MAKE_TARGET="build medium_integration_test"
- TEST_MATRIX="-shard 0"
- TEST_MATRIX="-shard 1"
- TEST_MATRIX="-shard 2"
- TEST_MATRIX="-shard 3"
- TEST_MATRIX="-shard 4"
before_install:
- travis/download_mariadb.sh
- travis/php_init.sh
@ -91,10 +86,10 @@ script:
- source dev.env
# Log GOMAXPROCS (should be 2 as of 07/2015).
- go run travis/log_gomaxprocs.go
- travis/run_tests.sh
- go run test.go $TEST_FLAGS $TEST_MATRIX
after_failure:
# In case of errors, output log files to make it easier to debug the error.
# List all available files.
- ls -alR $HOME/gopath/vtdataroot
# Output *.log* and *.stderr files. (Uncomment VT_TEST_FLAGS above or tests will delete their logs.)
# Output *.log* and *.stderr files. (Add -keep-data to TEST_FLAGS above or tests will delete their logs.)
- find $HOME/gopath/vtdataroot \( -name "*.log*" -or -name "*.stderr" \) -type f -print0 | xargs -0r --verbose --max-args=1 cat

118
Makefile
Просмотреть файл

@ -8,7 +8,7 @@ MAKEFLAGS = -s
# Since we are not using this Makefile for compilation, limiting parallelism will not increase build time.
.NOTPARALLEL:
.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
.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 reshard_tests
all: build test
@ -32,7 +32,9 @@ build:
# Set VT_TEST_FLAGS to pass flags to python tests.
# For example, verbose output: export VT_TEST_FLAGS=-v
test: unit_test queryservice_test integration_test java_test
test:
go run test.go -docker=false
site_test: unit_test site_integration_test
clean:
@ -62,115 +64,22 @@ unit_test_race:
unit_test_goveralls:
travis/goveralls.sh
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"
queryservice_test: build
$(call run_integration_tests, $(queryservice_test_files))
# 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
# These tests should be run by developers after making code changes.
# Integration tests are grouped into 3 suites.
# - small: under 30 secs
# - medium: 30 secs - 1 min
# - large: over 1 min
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
# The following tests are considered too flaky to be included
# in the continous integration test suites
ci_skip_integration_test_files = \
resharding_bytes.py \
resharding.py
# Run the following tests after making worker changes.
worker_integration_test_files = \
binlog.py \
resharding.py \
resharding_bytes.py \
vertical_split.py \
initial_sharding.py \
initial_sharding_bytes.py \
worker.py
queryservice_test:
go run test.go -docker=false queryservice_vtocc queryservice_vttablet
.ONESHELL:
SHELL = /bin/bash
# function to execute a list of integration test files
# exits on first failure
define run_integration_tests
cd test ; \
for t in $1 ; do \
echo $$(date): Running test/$$t --skip-build ; \
output=$$(time timeout 5m ./$$t $$VT_TEST_FLAGS --skip-build 2>&1) ; \
if [[ $$? != 0 ]]; then \
echo "$$output" >&2 ; \
exit 1 ; \
fi ; \
echo ; \
done
endef
small_integration_test: build
$(call run_integration_tests, $(small_integration_test_files))
medium_integration_test: build
$(call run_integration_tests, $(medium_integration_test_files))
large_integration_test: build
$(call run_integration_tests, $(large_integration_test_files))
ci_skip_integration_test: build
$(call run_integration_tests, $(ci_skip_integration_test_files))
worker_test: build
# Run the following tests after making worker changes.
worker_test:
godep go test ./go/vt/worker/
$(call run_integration_tests, $(worker_integration_test_files))
go run test.go -docker=false binlog resharding resharding_bytes vertical_split initial_sharding initial_sharding_bytes worker
# These tests should be run by users to check that Vitess works in their environment.
integration_test: small_integration_test medium_integration_test large_integration_test ci_skip_integration_test
site_integration_test: build
$(call run_integration_tests, $(site_integration_test_files))
site_integration_test:
go run test.go -docker=false keyrange keyspace mysqlctl tabletmanager vtdb vtgatev2
java_test:
godep go install ./go/cmd/vtgateclienttest
@ -210,3 +119,6 @@ docker_test:
docker_unit_test:
go run test.go -flavor $(flavor) unit
reshard_tests:
go run test.go -reshard 5 -remote-stats http://enisoc.com:15123/travis/stats

37
test.go
Просмотреть файл

@ -565,14 +565,39 @@ func reshardTests(config *Config, numShards int) error {
max := totalTime / int64(numShards)
shards := make([][]TestStats, numShards)
sums := make([]int64, numShards)
for i := 0; len(tests) > 0; i++ {
n := i % numShards
// First pass: greedy approximation.
for len(tests) > 0 {
v := int64(tests[0].PassTime)
if sums[n] < max {
shards[n] = append(shards[n], tests[0])
sums[n] += v
tests = tests[1:]
found := false
for n := range shards {
if sums[n]+v < max {
shards[n] = append(shards[n], tests[0])
sums[n] += v
tests = tests[1:]
found = true
break
}
}
if !found {
break
}
}
// Second pass: distribute the remainder.
for len(tests) > 0 {
nmin := 0
min := sums[0]
for n := range sums {
if sums[n] < min {
nmin = n
min = sums[n]
}
}
shards[nmin] = append(shards[nmin], tests[0])
sums[nmin] += int64(tests[0].PassTime)
tests = tests[1:]
}
// Update config and print results.

Просмотреть файл

@ -1,100 +1,242 @@
{
"Tests": {
"unit": {
"Command": "godep go test ./go/..."
"Tests": {
"automation_horizontal_resharding": {
"File": "automation_horizontal_resharding.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
},
"java": {
"Command": "godep go install ./go/cmd/vtgateclienttest && mvn -f java/pom.xml clean verify"
"backup": {
"File": "backup.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"php": {
"Command": "godep go install ./go/cmd/vtgateclienttest && phpunit php/tests"
"binlog": {
"File": "binlog.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 0
},
"client": {
"File": "client_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"custom_sharding": {
"File": "custom_sharding.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"goveralls": {
"File": "",
"Args": "",
"Command": "travis/goveralls.sh",
"Manual": true
"Manual": true,
"Shard": 1
},
"queryservice_vtocc": {
"File": "queryservice_test.py",
"Args": "-m -e vtocc"
},
"queryservice_vttablet": {
"File": "queryservice_test.py",
"Args": "-m -e vttablet"
},
"vertical_split": {
"File": "vertical_split.py"
},
"schema": {
"File": "schema.py"
},
"keyspace": {
"File": "keyspace_test.py"
},
"keyrange": {
"File": "keyrange_test.py"
},
"mysqlctl": {
"File": "mysqlctl.py"
},
"sharded": {
"File": "sharded.py"
},
"secure": {
"File": "secure.py"
},
"binlog": {
"File": "binlog.py"
},
"backup": {
"File": "backup.py"
},
"custom_sharding": {
"File": "custom_sharding.py"
},
"python_client": {
"File": "python_client_test.py"
},
"update_stream": {
"File": "update_stream.py"
},
"tabletmanager": {
"File": "tabletmanager.py"
},
"reparent": {
"File": "reparent.py"
},
"vtdb": {
"File": "vtdb_test.py"
},
"vtgate_utils": {
"File": "vtgate_utils_test.py"
},
"rowcache_invalidator": {
"File": "rowcache_invalidator.py"
},
"vtgatev2": {
"File": "vtgatev2_test.py"
},
"initial_sharding_bytes": {
"File": "initial_sharding_bytes.py"
},
"initial_sharding": {
"File": "initial_sharding.py"
},
"resharding_bytes": {
"File": "resharding_bytes.py"
},
"resharding": {
"File": "resharding.py"
},
"worker": {
"File": "worker.py"
},
"automation_horizontal_resharding": {
"File": "automation_horizontal_resharding.py"
},
"tablet": {
"File": "tablet_test.py"
}
}
}
"initial_sharding": {
"File": "initial_sharding.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
},
"initial_sharding_bytes": {
"File": "initial_sharding_bytes.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"java": {
"File": "",
"Args": "",
"Command": "make java_test",
"Manual": false,
"Shard": 2
},
"keyrange": {
"File": "keyrange_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 2
},
"keyspace": {
"File": "keyspace_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"mysqlctl": {
"File": "mysqlctl.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 2
},
"php": {
"File": "",
"Args": "",
"Command": "make php_test",
"Manual": false,
"Shard": 3
},
"python_client": {
"File": "python_client_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"queryservice_vtocc": {
"File": "queryservice_test.py",
"Args": "-m -e vtocc",
"Command": "",
"Manual": false,
"Shard": 4
},
"queryservice_vttablet": {
"File": "queryservice_test.py",
"Args": "-m -e vttablet",
"Command": "",
"Manual": false,
"Shard": 3
},
"reparent": {
"File": "reparent.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 1
},
"resharding": {
"File": "resharding.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 0
},
"resharding_bytes": {
"File": "resharding_bytes.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 2
},
"rowcache_invalidator": {
"File": "rowcache_invalidator.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
},
"schema": {
"File": "schema.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"secure": {
"File": "secure.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"sharded": {
"File": "sharded.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"sql_builder_test": {
"File": "sql_builder_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"tablet": {
"File": "tablet_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 0
},
"tabletmanager": {
"File": "tabletmanager.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
},
"unit": {
"File": "",
"Args": "",
"Command": "make unit_test",
"Manual": false,
"Shard": 2
},
"unit_race": {
"File": "",
"Args": "",
"Command": "make unit_test_race",
"Manual": false,
"Shard": 1
},
"update_stream": {
"File": "update_stream.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"vertical_split": {
"File": "vertical_split.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"vtdb": {
"File": "vtdb_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
},
"vtgate_utils": {
"File": "vtgate_utils_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 4
},
"vtgatev2": {
"File": "vtgatev2_test.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 0
},
"worker": {
"File": "worker.py",
"Args": "",
"Command": "",
"Manual": false,
"Shard": 3
}
}
}