From b25d1494795b94046470fc077e10a166319fbcdd Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Sat, 7 Dec 2019 12:11:06 -0700 Subject: [PATCH 1/4] Merge VTTOP and VTROOT variables Disable prepared_statement test Add a check to examples to make sure etcd is not running Signed-off-by: Morgan Tocker --- .github/bootstrap.sh | 175 ------------------ .github/workflows/check_make_parser.yml | 9 +- .github/workflows/cluster_endtoend.yml | 14 +- .github/workflows/e2e_race.yml | 14 +- .github/workflows/endtoend.yml | 13 +- .github/workflows/local_example.yml | 11 +- .github/workflows/unit.yml | 13 +- .github/workflows/unit_race.yml | 12 +- .gitignore | 7 + Makefile | 34 ++-- bootstrap.sh | 54 +----- build.env | 46 +++-- dev.env | 7 +- docker/bootstrap/Dockerfile.common | 13 +- docker/k8s/Dockerfile | 9 +- docker/lite/Dockerfile | 5 +- docker/lite/Dockerfile.alpine | 5 +- docker/lite/Dockerfile.mariadb | 5 +- docker/lite/Dockerfile.mariadb103 | 5 +- docker/lite/Dockerfile.mysql56 | 5 +- docker/lite/Dockerfile.mysql57 | 5 +- docker/lite/Dockerfile.mysql80 | 5 +- docker/lite/Dockerfile.percona | 5 +- docker/lite/Dockerfile.percona57 | 5 +- docker/lite/Dockerfile.percona80 | 5 +- docker/test/run.sh | 53 +++--- examples/compose/docker-compose.beginners.yml | 4 +- examples/compose/vtcompose/vtcompose.go | 4 +- examples/demo/run.py | 4 +- examples/kubernetes/guestbook/extract.sh | 2 +- .../vtctld-controller-template.yaml | 4 +- examples/local/env.sh | 6 +- examples/local/etcd-up.sh | 3 + examples/local/vtctld-up.sh | 4 +- go/test/endtoend/vtgate/main_test.go | 2 +- go/test/endtoend/vtgate/sequence/seq_test.go | 2 +- .../vtgate/transaction/trxn_mode_test.go | 2 +- .../endtoend/vtgate/vschema/vschema_test.go | 2 +- go/vt/mysqlctl/mycnf_test.go | 9 +- .../vtgate/endtoend/deletetest/delete_test.go | 2 +- go/vt/vtgate/endtoend/main_test.go | 2 +- .../tabletserver/vstreamer/testenv/testenv.go | 2 +- go/vt/vttest/environment.go | 4 +- .../test/java/io/vitess/client/TestEnv.java | 16 +- misc/git/hooks/pylint | 4 +- py/vttest/mysql_db_mysqlctl.py | 2 +- py/vttest/mysql_flavor.py | 16 +- test.go | 9 +- test/backup.py | 2 +- test/backup_only.py | 2 +- test/backup_transform.py | 2 +- test/client_test.sh | 4 +- test/cluster/k8s_environment.py | 2 +- test/cluster/keytar/README.md | 6 +- test/cluster/keytar/config/vitess_config.yaml | 6 +- test/cluster/keytar/keytar_web_test.py | 2 +- test/cluster/keytar/test_config.yaml | 1 - test/cluster/sandbox/create_schema.py | 2 +- test/cluster/sandbox/kubernetes_components.py | 2 +- .../sandbox/vitess_kubernetes_sandbox.py | 4 +- test/cluster/sandbox/vtctl_sandbox.py | 2 +- test/config.json | 2 +- test/environment.py | 10 +- test/initial_sharding_multi.py | 2 +- test/local_example.sh | 4 +- test/tablet.py | 8 +- test/utils.py | 4 +- test/vtbackup.py | 2 +- test/vtctld_web_test.py | 8 +- test/vttest_sample_test.py | 4 +- tools/bootstrap_web.sh | 4 +- tools/check_make_parser.sh | 2 + tools/dependency_check.sh | 26 +++ tools/e2e_test_cluster.sh | 3 + tools/e2e_test_race.sh | 5 +- tools/e2e_test_runner.sh | 3 + tools/generate_web_artifacts.sh | 2 +- tools/unit_test_race.sh | 2 + tools/unit_test_runner.sh | 3 + 79 files changed, 285 insertions(+), 485 deletions(-) delete mode 100755 .github/bootstrap.sh mode change 100644 => 100755 build.env create mode 100755 tools/dependency_check.sh diff --git a/.github/bootstrap.sh b/.github/bootstrap.sh deleted file mode 100755 index f02bffd1f1b..00000000000 --- a/.github/bootstrap.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2164 - -# Copyright 2019 The Vitess Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This is a next-gen bootstrap which skips Python and Java tests, -# and does not use the VTROOT/VTTOP layout. -# -# My original intention was to use the same bootstrap.sh and gate -# for new features, but it has turned out to be difficult to do, -# due to the way that Docker cache works in the CI environment. - -function fail() { - echo "ERROR: $1" - exit 1 -} - -[[ "$(dirname "$0")" = "." ]] || fail "bootstrap.sh must be run from its current directory" - -# Create main directories. - -VTROOT="$PWD" - -mkdir -p dist -mkdir -p bin -mkdir -p lib -mkdir -p vthook - -source ./dev.env - -go version &>/dev/null || fail "Go is not installed or is not on \$PATH" -goversion_min 1.12 || fail "Go is not version 1.12+" - -# Set up required soft links. -# TODO(mberlin): Which of these can be deleted? -ln -snf "$VTROOT/py" "$VTROOT/py-vtdb" -ln -snf "$VTROOT/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh" -ln -snf "$VTROOT/test/vthook-test.sh" "$VTROOT/vthook/test.sh" -ln -snf "$VTROOT/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error" -ln -snf "$VTROOT/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform" - -# git hooks are only required if someone intends to contribute. - -echo "creating git hooks" -mkdir -p "$VTROOT/.git/hooks" -ln -sf "$VTROOT/misc/git/pre-commit" "$VTROOT/.git/hooks/pre-commit" -ln -sf "$VTROOT/misc/git/commit-msg" "$VTROOT/.git/hooks/commit-msg" -git config core.hooksPath "$VTROOT/.git/hooks" - -# install_dep is a helper function to generalize the download and installation of dependencies. -# -# If the installation is successful, it puts the installed version string into -# the $dist/.installed_version file. If the version has not changed, bootstrap -# will skip future installations. -function install_dep() { - if [[ $# != 4 ]]; then - fail "install_dep function requires exactly 4 parameters (and not $#). Parameters: $*" - fi - local name="$1" - local version="$2" - local dist="$3" - local install_func="$4" - - version_file="$dist/.installed_version" - if [[ -f "$version_file" && "$(cat "$version_file")" == "$version" ]]; then - echo "skipping $name install. remove $dist to force re-install." - return - fi - - echo "installing $name $version" - - # shellcheck disable=SC2064 - trap "fail '$name build failed'; exit 1" ERR - - # Cleanup any existing data and re-create the directory. - rm -rf "$dist" - mkdir -p "$dist" - - # Change $CWD to $dist before calling "install_func". - pushd "$dist" >/dev/null - # -E (same as "set -o errtrace") makes sure that "install_func" inherits the - # trap. If here's an error, the trap will be called which will exit this - # script. - set -E - $install_func "$version" "$dist" - set +E - popd >/dev/null - - trap - ERR - - echo "$version" > "$version_file" -} - - -# -# 1. Installation of dependencies. -# - -# Wrapper around the `arch` command which plays nice with OS X -function get_arch() { - case $(uname) in - Linux) arch;; - Darwin) uname -m;; - esac -} - -# Install protoc. -function install_protoc() { - local version="$1" - local dist="$2" - - case $(uname) in - Linux) local platform=linux;; - Darwin) local platform=osx;; - esac - - case $(get_arch) in - aarch64) local target=aarch_64;; - x86_64) local target=x86_64;; - *) echo "ERROR: unsupported architecture"; exit 1;; - esac - - wget https://github.com/protocolbuffers/protobuf/releases/download/v$version/protoc-$version-$platform-${target}.zip - unzip "protoc-$version-$platform-${target}.zip" - ln -snf "$dist/bin/protoc" "$VTROOT/bin/protoc" -} -protoc_ver=3.6.1 -install_dep "protoc" "$protoc_ver" "$VTROOT/dist/vt-protoc-$protoc_ver" install_protoc - -# Download and install etcd, link etcd binary into our root. -function install_etcd() { - local version="$1" - local dist="$2" - - case $(uname) in - Linux) local platform=linux; local ext=tar.gz;; - Darwin) local platform=darwin; local ext=zip;; - esac - - case $(get_arch) in - aarch64) local target=arm64;; - x86_64) local target=amd64;; - *) echo "ERROR: unsupported architecture"; exit 1;; - esac - - download_url=https://github.com/coreos/etcd/releases/download - file="etcd-${version}-${platform}-${target}.${ext}" - - wget "$download_url/$version/$file" - if [ "$ext" = "tar.gz" ]; then - tar xzf "$file" - else - unzip "$file" - fi - rm "$file" - ln -snf "$dist/etcd-${version}-${platform}-${target}/etcd" "$VTROOT/bin/etcd" -} - -# Install etcd if not detected -which etcd || install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd - -echo -echo "bootstrap finished" diff --git a/.github/workflows/check_make_parser.yml b/.github/workflows/check_make_parser.yml index 1cf47a6d4a7..0657236fc38 100644 --- a/.github/workflows/check_make_parser.yml +++ b/.github/workflows/check_make_parser.yml @@ -24,14 +24,11 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make minimaltools run: | - echo "Copying new bootstrap over location of legacy one." - cp .github/bootstrap.sh . - ./bootstrap.sh + make minimaltools - name: check_make_parser run: | - export PATH=$PWD/bin:$PATH - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD tools/check_make_parser.sh + tools/check_make_parser.sh diff --git a/.github/workflows/cluster_endtoend.yml b/.github/workflows/cluster_endtoend.yml index 61ddea9a5b9..a2f3f9d7d3d 100644 --- a/.github/workflows/cluster_endtoend.yml +++ b/.github/workflows/cluster_endtoend.yml @@ -24,18 +24,10 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make minimaltools run: | - echo "Copying new bootstrap over location of legacy one." - cp .github/bootstrap.sh . - ./bootstrap.sh - - - name: Build - run: | - VTROOT=$PWD VTTOP=$PWD make build + make minimaltools - name: cluster_endtoend run: | - export PATH=$PWD/bin:$PATH - source ./dev.env - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD make e2e_test_cluster + make e2e_test_cluster diff --git a/.github/workflows/e2e_race.yml b/.github/workflows/e2e_race.yml index a0404cfefb6..0439d067116 100644 --- a/.github/workflows/e2e_race.yml +++ b/.github/workflows/e2e_race.yml @@ -24,18 +24,10 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make minimaltools run: | - echo "Copying new bootstrap over location of legacy one." - cp .github/bootstrap.sh . - ./bootstrap.sh - - - name: Build - run: | - VTROOT=$PWD VTTOP=$PWD make build + make minimaltools - name: e2e_race run: | - export PATH=$PWD/bin:$PATH - source ./dev.env - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD make e2e_test_race + make e2e_test_race diff --git a/.github/workflows/endtoend.yml b/.github/workflows/endtoend.yml index a83ad499040..6ebec31c3b5 100644 --- a/.github/workflows/endtoend.yml +++ b/.github/workflows/endtoend.yml @@ -24,19 +24,14 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make minimaltools run: | - echo "Copying new bootstrap over location of legacy one." - cp .github/bootstrap.sh . - ./bootstrap.sh + make minimaltools - name: Build run: | - VTROOT=$PWD VTTOP=$PWD make build + make build - name: endtoend run: | - export PATH=$PWD/bin:$PATH - source ./dev.env - mkdir -p /tmp/vtdataroot - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD tools/e2e_test_runner.sh + tools/e2e_test_runner.sh diff --git a/.github/workflows/local_example.yml b/.github/workflows/local_example.yml index 9e9467a7f92..fe0035ec10e 100644 --- a/.github/workflows/local_example.yml +++ b/.github/workflows/local_example.yml @@ -24,18 +24,15 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make minimaltools run: | - echo "Copying new bootstrap over location of legacy one." - cp .github/bootstrap.sh . - ./bootstrap.sh + make minimaltools - name: Build run: | - VTROOT=$PWD VTTOP=$PWD make build + make build - name: local_example run: | - export PATH=$PWD/bin:$PATH - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD test/local_example.sh + test/local_example.sh diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 774bdbd7365..dd53b59a1d6 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -24,17 +24,10 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make tools run: | - VTTOP=$PWD VTROOT=$PWD BUILD_PYTHON=0 ./bootstrap.sh - - - name: Build - run: | - VTROOT=$PWD VTTOP=$PWD make build + make tools - name: unit run: | - export PATH=$PWD/bin:$PATH - source ./dev.env - mkdir -p /tmp/vtdataroot - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD tools/unit_test_runner.sh + make test diff --git a/.github/workflows/unit_race.yml b/.github/workflows/unit_race.yml index fd2e7ecd671..4cada70f482 100644 --- a/.github/workflows/unit_race.yml +++ b/.github/workflows/unit_race.yml @@ -24,16 +24,10 @@ jobs: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download - - name: Run bootstrap.sh + - name: Run make tools run: | - VTTOP=$PWD VTROOT=$PWD BUILD_PYTHON=0 ./bootstrap.sh - - - name: Build - run: | - VTROOT=$PWD VTTOP=$PWD make build + make tools - name: unit_race run: | - export PATH=$PWD/bin:$PATH - source ./dev.env - VTDATAROOT=/tmp/vtdataroot VTTOP=$PWD VTROOT=$PWD make unit_test_race + make unit_test_race diff --git a/.gitignore b/.gitignore index 86b6f1b3850..2561bdd9379 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,10 @@ releases # Vagrant .vagrant + +dist/* +py-vtdb* +vthook* +bin* + +vtdataroot* diff --git a/Makefile b/Makefile index d0c1d58dae7..8eab33561d7 100644 --- a/Makefile +++ b/Makefile @@ -14,17 +14,14 @@ MAKEFLAGS = -s -# Soon this can be $PWD/bin, with no dependencies -# Waiting on https://github.com/vitessio/vitess/issues/5378 - -export GOBIN=$(VTROOT)/bin +export GOBIN=$(PWD)/bin export GO111MODULE=on # 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: -.PHONY: all build build_web test clean unit_test unit_test_cover unit_test_race integration_test proto proto_banner site_test site_integration_test docker_bootstrap docker_test docker_unit_test java_test reshard_tests e2e_test e2e_test_race +.PHONY: all build build_web test clean unit_test unit_test_cover unit_test_race integration_test proto proto_banner site_test site_integration_test docker_bootstrap docker_test docker_unit_test java_test reshard_tests e2e_test e2e_test_race minimaltools tools all: build @@ -48,6 +45,7 @@ build: ifndef NOBANNER echo $$(date): Building source tree endif + bash ./build.env go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" ./go/... parser: @@ -56,8 +54,9 @@ parser: # 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 -test: - go run test.go -docker=false +test: build dependency_check + echo $$(date): Running unit tests + tools/unit_test_runner.sh site_test: unit_test site_integration_test @@ -80,11 +79,7 @@ cleanall: # - exclude vtdataroot and vthook as they may have data we want rm -rf ../../../../bin ../../../../dist ../../../../lib ../../../../pkg # Remind people to run bootstrap.sh again - echo "Please run bootstrap.sh again to setup your environment" - -unit_test: build - echo $$(date): Running unit tests - go test $(VT_GO_PARALLEL) ./go/... + echo "Please run 'make tools' again to setup your environment" e2e_test: build echo $$(date): Running endtoend tests @@ -96,7 +91,7 @@ e2e_test: build unit_test_cover: build go test $(VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py -unit_test_race: build +unit_test_race: build dependency_check tools/unit_test_race.sh e2e_test_race: build @@ -118,7 +113,7 @@ site_integration_test: java_test: go install ./go/cmd/vtgateclienttest ./go/cmd/vtcombo - mvn -f java/pom.xml -B clean verify + VTROOT=${PWD} mvn -f java/pom.xml -B clean verify install_protoc-gen-go: go install github.com/golang/protobuf/protoc-gen-go @@ -284,3 +279,14 @@ packages: docker_base docker build -f docker/packaging/Dockerfile -t vitess/packaging . docker run --rm -v ${PWD}/releases:/vt/releases --env VERSION=$(VERSION) vitess/packaging --package /vt/releases -t deb --deb-no-default-config-files docker run --rm -v ${PWD}/releases:/vt/releases --env VERSION=$(VERSION) vitess/packaging --package /vt/releases -t rpm + +tools: + echo $$(date): Installing dependencies + BUILD_PYTHON=0 ./bootstrap.sh + +minimaltools: + echo $$(date): Installing minimal dependencies + BUILD_PYTHON=0 BUILD_JAVA=0 BUILD_CONSUL=0 ./bootstrap.sh + +dependency_check: + ./tools/dependency_check.sh diff --git a/bootstrap.sh b/bootstrap.sh index a5f73105d4a..c0a1af875ba 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -15,14 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +### This file is executed by 'make tools'. You do not need to execute it directly. # Outline of this file. # 0. Initialization and helper methods. # 1. Installation of dependencies. -BUILD_TESTS=${BUILD_TESTS:-1} BUILD_PYTHON=${BUILD_PYTHON:-1} BUILD_JAVA=${BUILD_JAVA:-1} +BUILD_CONSUL=${BUILD_CONSUL:-1} # # 0. Initialization and helper methods. @@ -36,47 +37,8 @@ function fail() { [[ "$(dirname "$0")" = "." ]] || fail "bootstrap.sh must be run from its current directory" # Create main directories. -VTROOT="${VTROOT:-${PWD/\/src\/vitess.io\/vitess/}}" -mkdir -p "$VTROOT/dist" -mkdir -p "$VTROOT/bin" -mkdir -p "$VTROOT/lib" -mkdir -p "$VTROOT/vthook" - -# This is required for VIRTUALENV -# Used by Python below - -if [ "$BUILD_TESTS" == 1 ] ; then - source ./dev.env -else - source ./build.env -fi - -go version &>/dev/null || fail "Go is not installed or is not on \$PATH" -goversion_min 1.12 || fail "Go is not version 1.12+" - -if [ "$BUILD_TESTS" == 1 ] ; then - # Set up required soft links. - # TODO(mberlin): Which of these can be deleted? - ln -snf "$VTTOP/config" "$VTROOT/config" - ln -snf "$VTTOP/data" "$VTROOT/data" - ln -snf "$VTTOP/py" "$VTROOT/py-vtdb" - ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh" - ln -snf "$VTTOP/test/vthook-test.sh" "$VTROOT/vthook/test.sh" - ln -snf "$VTTOP/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error" - ln -snf "$VTTOP/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform" -else - ln -snf "$VTTOP/config" "$VTROOT/config" - ln -snf "$VTTOP/data" "$VTROOT/data" - ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh" -fi -# git hooks are only required if someone intends to contribute. - -echo "creating git hooks" -mkdir -p "$VTTOP/.git/hooks" -ln -sf "$VTTOP/misc/git/pre-commit" "$VTTOP/.git/hooks/pre-commit" -ln -sf "$VTTOP/misc/git/commit-msg" "$VTTOP/.git/hooks/commit-msg" -(cd "$VTTOP" && git config core.hooksPath "$VTTOP/.git/hooks") +source ./dev.env # install_dep is a helper function to generalize the download and installation of dependencies. # @@ -236,7 +198,7 @@ function install_etcd() { ln -snf "$dist/etcd-${version}-${platform}-${target}/etcd" "$VTROOT/bin/etcd" ln -snf "$dist/etcd-${version}-${platform}-${target}/etcdctl" "$VTROOT/bin/etcdctl" } -which etcd || install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd +command -v etcd && echo "etcd already installed" || install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd # Download and install consul, link consul binary into our root. @@ -260,8 +222,10 @@ function install_consul() { unzip "consul_${version}_${platform}_${target}.zip" ln -snf "$dist/consul" "$VTROOT/bin/consul" } -install_dep "Consul" "1.4.0" "$VTROOT/dist/consul" install_consul +if [ "$BUILD_CONSUL" == 1 ] ; then + install_dep "Consul" "1.4.0" "$VTROOT/dist/consul" install_consul +fi # Install py-mock. function install_pymock() { @@ -273,7 +237,7 @@ function install_pymock() { PYTHONPATH=$(prepend_path "$PYTHONPATH" "$dist/lib/python2.7/site-packages") export PYTHONPATH - pushd "$VTTOP/third_party/py" >/dev/null + pushd "$VTROOT/third_party/py" >/dev/null tar -xzf "mock-$version.tar.gz" cd "mock-$version" $PYTHON ./setup.py install --prefix="$dist" @@ -335,4 +299,4 @@ if [ "$BUILD_PYTHON" == 1 ] ; then fi echo -echo "bootstrap finished - run 'source dev.env' or 'source build.env' in your shell before building." +echo "bootstrap finished - run 'make build' to compile" diff --git a/build.env b/build.env old mode 100644 new mode 100755 index 5719714f344..6fb37f47a62 --- a/build.env +++ b/build.env @@ -14,19 +14,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Plese ensure dev.env is written in a way which is POSIX (bourne) -# shell compatible. -# - Some build systems like rpm require the different scriptlets used -# to build a package to be run under a POSIX shell so non-POSIX -# syntax will break that as dev.env will not be sourced by bash.. - -# Import prepend_path function. -dir="$(dirname "${BASH_SOURCE[0]}")" -# shellcheck source=tools/shell_functions.inc -if ! source "${dir}/tools/shell_functions.inc"; then - echo "failed to load tools/shell_functions.inc" - return 1 -fi - -export VTTOP=$(pwd) -export VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}" +source ./tools/shell_functions.inc + +go version &>/dev/null || fail "Go is not installed or is not on \$PATH" +goversion_min 1.12 || fail "Go is not version 1.12+" + +mkdir -p dist +mkdir -p bin +mkdir -p lib +mkdir -p vthook + +export VTROOT="$PWD" +export VTDATAROOT="${VTDATAROOT:-${VTROOT}/vtdataroot}" +export PATH="$PWD/bin:$PATH" + +mkdir -p "$VTDATAROOT" + +# Set up required soft links. +# TODO(mberlin): Which of these can be deleted? +ln -snf "$PWD/py" py-vtdb +ln -snf "$PWD/go/vt/zkctl/zksrv.sh" bin/zksrv.sh +ln -snf "$PWD/test/vthook-test.sh" vthook/test.sh +ln -snf "$PWD/test/vthook-test_backup_error" vthook/test_backup_error +ln -snf "$PWD/test/vthook-test_backup_transform" vthook/test_backup_transform + +# install git hooks + +mkdir -p .git/hooks +ln -sf "$PWD/misc/git/pre-commit" .git/hooks/pre-commit +ln -sf "$PWD/misc/git/commit-msg" .git/hooks/commit-msg +git config core.hooksPath .git/hooks diff --git a/dev.env b/dev.env index 060dd0ef1b5..f256abbd93a 100644 --- a/dev.env +++ b/dev.env @@ -22,9 +22,6 @@ source ./build.env -export VTDATAROOT="${VTDATAROOT:-${VTROOT}/vtdataroot}" -mkdir -p "$VTDATAROOT" - export VTPORTSTART=15000 # Add all site-packages or dist-packages directories below $VTROOT/dist to $PYTHONPATH. @@ -40,8 +37,8 @@ IFS="$BACKUP_IFS" PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/py-vtdb") PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/dist/selenium") -PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test") -PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTTOP/test/cluster/sandbox") +PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/test") +PYTHONPATH=$(prepend_path "$PYTHONPATH" "$VTROOT/test/cluster/sandbox") export PYTHONPATH # Ensure bootstrap.sh uses python2 on systems which default to python3. diff --git a/docker/bootstrap/Dockerfile.common b/docker/bootstrap/Dockerfile.common index e645b31a447..6a9255b38e7 100644 --- a/docker/bootstrap/Dockerfile.common +++ b/docker/bootstrap/Dockerfile.common @@ -30,16 +30,15 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && rm -rf /var/lib/apt/lists/* # Install Maven 3.1+ -RUN mkdir -p /vt/dist && \ - cd /vt/dist && \ +RUN mkdir -p /vt/src/vitess.io/vitess/dist && \ + cd /vt/src/vitess.io/vitess/dist && \ curl -sL --connect-timeout 10 --retry 3 \ http://www-us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz | tar -xz && \ mv apache-maven-3.3.9 maven # Set up Vitess environment (equivalent to '. dev.env') -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV VTPORTSTART 15000 ENV PYTHONPATH $VTROOT/dist/grpc/usr/local/lib/python2.7/site-packages:$VTROOT/dist/py-mock-1.0.1/lib/python2.7/site-packages:$VTROOT/py-vtdb:$VTROOT/dist/selenium/lib/python2.7/site-packages ENV PATH $VTROOT/bin:$VTROOT/dist/maven/bin:$VTROOT/dist/chromedriver:$PATH @@ -64,6 +63,10 @@ RUN cd /vt/src/vitess.io/vitess && \ # Create mount point for actual data (e.g. MySQL data dir) VOLUME /vt/vtdataroot +# The docker lite images copy from the builder in /vt/bin +# Add compatibility to the previous layout for now +RUN su vitess -c "mkdir -p /vt/src/vitess.io/vitess/bin && rm -rf /vt/bin && ln -s /vt/src/vitess.io/vitess/bin /vt/bin" + # If the user doesn't specify a command, load a shell. CMD ["/bin/bash"] diff --git a/docker/k8s/Dockerfile b/docker/k8s/Dockerfile index ddafcd95af7..391c352e4f8 100644 --- a/docker/k8s/Dockerfile +++ b/docker/k8s/Dockerfile @@ -25,9 +25,8 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTROOT /vt +ENV VTROOT /vt/src/vitess.io/vitess ENV VTDATAROOT /vtdataroot -ENV VTTOP /vt/src/vitess.io/vitess # Prepare directory structure. RUN mkdir -p /vt && \ @@ -50,13 +49,13 @@ COPY --from=base /vt/bin/vtworker /vt/bin/ COPY --from=base /vt/bin/vtbackup /vt/bin/ # copy web admin files -COPY --from=base $VTTOP/web /vt/web/ +COPY --from=base $VTROOT/web /vt/web/ # copy vitess config -COPY --from=base $VTTOP/config/init_db.sql /vt/config/ +COPY --from=base $VTROOT/config/init_db.sql /vt/config/ # my.cnf include files -COPY --from=base $VTTOP/config/mycnf /vt/config/mycnf +COPY --from=base $VTROOT/config/mycnf /vt/config/mycnf # add vitess user and add permissions RUN groupadd -r --gid 2000 vitess && useradd -r -g vitess --uid 1000 vitess && \ diff --git a/docker/lite/Dockerfile b/docker/lite/Dockerfile index f110b58fc67..a63321a42f5 100644 --- a/docker/lite/Dockerfile +++ b/docker/lite/Dockerfile @@ -62,9 +62,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && rm -rf /var/lib/mysql/ # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.alpine b/docker/lite/Dockerfile.alpine index a50fec877d9..b8fc9467f9a 100644 --- a/docker/lite/Dockerfile.alpine +++ b/docker/lite/Dockerfile.alpine @@ -22,9 +22,8 @@ RUN echo '@edge http://nl.alpinelinux.org/alpine/edge/main' >> /etc/apk/reposito apk add --no-cache mariadb@edge mariadb-client@edge bzip2 bash # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Create vitess user diff --git a/docker/lite/Dockerfile.mariadb b/docker/lite/Dockerfile.mariadb index b845e19beca..77eddfd8003 100644 --- a/docker/lite/Dockerfile.mariadb +++ b/docker/lite/Dockerfile.mariadb @@ -33,9 +33,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.mariadb103 b/docker/lite/Dockerfile.mariadb103 index a07de74fca3..a1d37b4c42c 100644 --- a/docker/lite/Dockerfile.mariadb103 +++ b/docker/lite/Dockerfile.mariadb103 @@ -32,9 +32,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.mysql56 b/docker/lite/Dockerfile.mysql56 index 0a771265c34..bb434808372 100644 --- a/docker/lite/Dockerfile.mysql56 +++ b/docker/lite/Dockerfile.mysql56 @@ -36,9 +36,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.mysql57 b/docker/lite/Dockerfile.mysql57 index 8e605fda627..809a79f9151 100644 --- a/docker/lite/Dockerfile.mysql57 +++ b/docker/lite/Dockerfile.mysql57 @@ -36,9 +36,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.mysql80 b/docker/lite/Dockerfile.mysql80 index bb6d5d54be4..0fade69bd35 100644 --- a/docker/lite/Dockerfile.mysql80 +++ b/docker/lite/Dockerfile.mysql80 @@ -36,9 +36,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.percona b/docker/lite/Dockerfile.percona index 2867aa9c33c..0698f4eb583 100644 --- a/docker/lite/Dockerfile.percona +++ b/docker/lite/Dockerfile.percona @@ -38,9 +38,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.percona57 b/docker/lite/Dockerfile.percona57 index ef01888a161..d52fbaa583a 100644 --- a/docker/lite/Dockerfile.percona57 +++ b/docker/lite/Dockerfile.percona57 @@ -39,9 +39,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/lite/Dockerfile.percona80 b/docker/lite/Dockerfile.percona80 index 02c56f48b92..5d872499cf2 100644 --- a/docker/lite/Dockerfile.percona80 +++ b/docker/lite/Dockerfile.percona80 @@ -41,9 +41,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins && groupadd -r vitess && useradd -r -g vitess vitess # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTTOP /vt/src/vitess.io/vitess -ENV VTROOT /vt -ENV VTDATAROOT $VTROOT/vtdataroot +ENV VTROOT /vt/src/vitess.io/vitess +ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH # Copy binaries (placed by build.sh) diff --git a/docker/test/run.sh b/docker/test/run.sh index 147663d028b..df0c6a20f82 100755 --- a/docker/test/run.sh +++ b/docker/test/run.sh @@ -160,37 +160,32 @@ case "$mode" in "create_cache") echo "Creating cache image $cache_image ..." ;; esac -# Construct "cp" command to copy the source code. -# -# Copy the full source tree except: -# - vendor -# That's because these directories are already part of the image. -# -# Note that we're using the Bash extended Glob support "!(vendor)" on -# purpose here to minimize the size of the cache image: With this trick, -# we do not move or overwrite the existing files while copying the other -# directories. Therefore, the existing files do not count as changed and will -# not be part of the new Docker layer of the cache image. -copy_src_cmd="cp -R /tmp/src/!(vendor|bootstrap.sh) ." -# Copy the .git directory because travis/check_make_proto.sh needs a working -# Git repository. -copy_src_cmd=$(append_cmd "$copy_src_cmd" "cp -R /tmp/src/.git .") - -# Enable gomodules -run_bootstrap_cmd="export GO111MODULE=on" -# Copy bootstrap.sh if it changed -run_bootstrap_cmd=$(append_cmd "$run_bootstrap_cmd" "if [[ \$(diff -w bootstrap.sh /tmp/src/bootstrap.sh) ]]; then cp -f /tmp/src/bootstrap.sh .; bootstrap=1; fi") -# run bootstrap.sh if necessary -run_bootstrap_cmd=$(append_cmd "$run_bootstrap_cmd" "if [[ -n \$bootstrap ]]; then ./bootstrap.sh; fi") -copy_src_cmd=$(append_cmd "$copy_src_cmd" "$run_bootstrap_cmd") - -# Construct the command we will actually run. -# -# Uncomment the next line if you need to debug "bashcmd". -#bashcmd="set -x" +bashcmd="" + if [[ -z "$existing_cache_image" ]]; then - bashcmd=$(append_cmd "$bashcmd" "$copy_src_cmd") + + # Construct "cp" command to copy the source code. + bashcmd=$(append_cmd "$bashcmd" "cp -R /tmp/src/!(vtdataroot|dist|bin|lib|vthook|py-vtdb) . && cp -R /tmp/src/.git .") + fi + +# Reset the environment if this was an old bootstrap. We can detect this from VTTOP presence. +bashcmd=$(append_cmd "$bashcmd" "export VTROOT=/vt/src/vitess.io/vitess") +bashcmd=$(append_cmd "$bashcmd" "export VTDATAROOT=/vt/vtdataroot") +bashcmd=$(append_cmd "$bashcmd" "export PYTHONPATH=/vt/src/vitess.io/vitess/dist/grpc/usr/local/lib/python2.7/site-packages:/vt/src/vitess.io/vitess/dist/py-mock-1.0.1/lib/python2.7/site-packages:/vt/src/vitess.io/vitess/py-vtdb:/vt/src/vitess.io/vitess/dist/selenium/lib/python2.7/site-packages") + +bashcmd=$(append_cmd "$bashcmd" "mkdir -p dist; mkdir -p bin; mkdir -p lib; mkdir -p vthook") +bashcmd=$(append_cmd "$bashcmd" "rm -rf /vt/dist; ln -s /vt/src/vitess.io/vitess/dist /vt/dist") +bashcmd=$(append_cmd "$bashcmd" "rm -rf /vt/bin; ln -s /vt/src/vitess.io/vitess/bin /vt/bin") +bashcmd=$(append_cmd "$bashcmd" "rm -rf /vt/lib; ln -s /vt/src/vitess.io/vitess/lib /vt/lib") +bashcmd=$(append_cmd "$bashcmd" "rm -rf /vt/vthook; ln -s /vt/src/vitess.io/vitess/vthook /vt/vthook") + +# Maven was setup in /vt/dist, may need to reinstall it. +bashcmd=$(append_cmd "$bashcmd" "echo 'Checking if mvn needs installing...'; if [[ ! \$(command -v mvn) ]]; then echo 'install maven'; curl -sL --connect-timeout 10 --retry 3 http://www-us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz | tar -xz && mv apache-maven-3.3.9 /vt/dist/maven; fi; echo 'mvn check done'") + +# Run bootstrap every time now +bashcmd=$(append_cmd "$bashcmd" "./bootstrap.sh") + # At last, append the user's command. bashcmd=$(append_cmd "$bashcmd" "$cmd") diff --git a/examples/compose/docker-compose.beginners.yml b/examples/compose/docker-compose.beginners.yml index 4f23b688f1a..67294b90c69 100644 --- a/examples/compose/docker-compose.beginners.yml +++ b/examples/compose/docker-compose.beginners.yml @@ -37,8 +37,8 @@ services: command: ["sh", "-c", " $$VTROOT/bin/vtctld \ $TOPOLOGY_FLAGS \ -cell $CELL \ - -web_dir $$VTTOP/web/vtctld \ - -web_dir2 $$VTTOP/web/vtctld2/app \ + -web_dir $$VTROOT/web/vtctld \ + -web_dir2 $$VTROOT/web/vtctld2/app \ -workflow_manager_init \ -workflow_manager_use_election \ -service_map 'grpc-vtctl' \ diff --git a/examples/compose/vtcompose/vtcompose.go b/examples/compose/vtcompose/vtcompose.go index b88099f3a6c..21de3280c10 100644 --- a/examples/compose/vtcompose/vtcompose.go +++ b/examples/compose/vtcompose/vtcompose.go @@ -466,8 +466,8 @@ func generateVtctld() string { command: ["sh", "-c", " $$VTROOT/bin/vtctld \ %[3]s \ -cell %[4]s \ - -web_dir $$VTTOP/web/vtctld \ - -web_dir2 $$VTTOP/web/vtctld2/app \ + -web_dir $$VTROOT/web/vtctld \ + -web_dir2 $$VTROOT/web/vtctld2/app \ -workflow_manager_init \ -workflow_manager_use_election \ -service_map 'grpc-vtctl' \ diff --git a/examples/demo/run.py b/examples/demo/run.py index d9a9aa2792a..5f8916bb176 100755 --- a/examples/demo/run.py +++ b/examples/demo/run.py @@ -51,8 +51,8 @@ def start_vitess(): keyspace = topology.keyspaces.add(name='lookup') keyspace.shards.add(name='0') - vttop = os.environ['VTTOP'] - args = [os.path.join(vttop, 'py/vttest/run_local_database.py'), + vtroot = os.environ['VTROOT'] + args = [os.path.join(vtroot, 'py/vttest/run_local_database.py'), '--port', '12345', '--proto_topo', text_format.MessageToString(topology, as_one_line=True), diff --git a/examples/kubernetes/guestbook/extract.sh b/examples/kubernetes/guestbook/extract.sh index e029df3fc77..04499c87397 100644 --- a/examples/kubernetes/guestbook/extract.sh +++ b/examples/kubernetes/guestbook/extract.sh @@ -17,7 +17,7 @@ set -e # Collect all the local Python libs we need. mkdir -p /out/pkg/py-vtdb -cp -R $VTTOP/py/* /out/pkg/py-vtdb/ +cp -R $VTROOT/py/* /out/pkg/py-vtdb/ cp -R /usr/local/lib/python2.7/dist-packages /out/pkg/ cp -R /vt/dist/py-* /out/pkg/ diff --git a/examples/kubernetes/vtctld-controller-template.yaml b/examples/kubernetes/vtctld-controller-template.yaml index 2ca6f6d80c1..4e28aa8bfc4 100644 --- a/examples/kubernetes/vtctld-controller-template.yaml +++ b/examples/kubernetes/vtctld-controller-template.yaml @@ -41,8 +41,8 @@ spec: chown -R vitess /vt && su -p -c "/vt/bin/vtctld -cell {{cell}} - -web_dir $VTTOP/web/vtctld - -web_dir2 $VTTOP/web/vtctld2/app + -web_dir $VTROOT/web/vtctld + -web_dir2 $VTROOT/web/vtctld2/app -workflow_manager_init -workflow_manager_use_election -log_dir $VTDATAROOT/tmp diff --git a/examples/local/env.sh b/examples/local/env.sh index 584987bb924..b1833e997f5 100644 --- a/examples/local/env.sh +++ b/examples/local/env.sh @@ -17,8 +17,10 @@ hostname=`hostname -f` vtctld_web_port=15000 -# Set up environment. -export VTTOP=${VTTOP-$VTROOT/src/vitess.io/vitess} +function fail() { + echo "ERROR: $1" + exit 1 +} if [ "${TOPO}" = "zk2" ]; then # Each ZooKeeper server needs a list of all servers in the quorum. diff --git a/examples/local/etcd-up.sh b/examples/local/etcd-up.sh index 12207e23b86..36cd4269565 100755 --- a/examples/local/etcd-up.sh +++ b/examples/local/etcd-up.sh @@ -26,6 +26,9 @@ export ETCDCTL_API=2 # shellcheck disable=SC1091 source "${script_root}/env.sh" +# Check that etcd is not already running +curl "http://${ETCD_SERVER}" > /dev/null 2>&1 && fail "etcd is already running. Exiting." + etcd --enable-v2=true --data-dir "${VTDATAROOT}/etcd/" --listen-client-urls "http://${ETCD_SERVER}" --advertise-client-urls "http://${ETCD_SERVER}" > "${VTDATAROOT}"/tmp/etcd.out 2>&1 & PID=$! echo $PID > "${VTDATAROOT}/tmp/etcd.pid" diff --git a/examples/local/vtctld-up.sh b/examples/local/vtctld-up.sh index dbd16a8de66..128152b837d 100755 --- a/examples/local/vtctld-up.sh +++ b/examples/local/vtctld-up.sh @@ -36,8 +36,8 @@ echo "Starting vtctld..." $VTROOT/bin/vtctld \ $TOPOLOGY_FLAGS \ -cell $cell \ - -web_dir $VTTOP/web/vtctld \ - -web_dir2 $VTTOP/web/vtctld2/app \ + -web_dir $VTROOT/web/vtctld \ + -web_dir2 $VTROOT/web/vtctld2/app \ -workflow_manager_init \ -workflow_manager_use_election \ -service_map 'grpc-vtctl' \ diff --git a/go/test/endtoend/vtgate/main_test.go b/go/test/endtoend/vtgate/main_test.go index d707b0d511d..9d506ee422b 100644 --- a/go/test/endtoend/vtgate/main_test.go +++ b/go/test/endtoend/vtgate/main_test.go @@ -168,7 +168,7 @@ func TestMain(m *testing.M) { flag.Parse() exitCode := func() int { - clusterInstance = cluster.NewCluster(Cell, "localhost") + clusterInstance = cluster.NewCluster(Cell, "localhost") defer clusterInstance.Teardown() // Start topo server diff --git a/go/test/endtoend/vtgate/sequence/seq_test.go b/go/test/endtoend/vtgate/sequence/seq_test.go index 72ce77bea02..03bc8f098d8 100644 --- a/go/test/endtoend/vtgate/sequence/seq_test.go +++ b/go/test/endtoend/vtgate/sequence/seq_test.go @@ -82,7 +82,7 @@ func TestMain(m *testing.M) { flag.Parse() exitCode := func() int { - clusterInstance = cluster.NewCluster(cell, hostname) + clusterInstance = cluster.NewCluster(cell, hostname) defer clusterInstance.Teardown() // Start topo server diff --git a/go/test/endtoend/vtgate/transaction/trxn_mode_test.go b/go/test/endtoend/vtgate/transaction/trxn_mode_test.go index bf20e10dd9b..106cb81010c 100644 --- a/go/test/endtoend/vtgate/transaction/trxn_mode_test.go +++ b/go/test/endtoend/vtgate/transaction/trxn_mode_test.go @@ -98,7 +98,7 @@ func TestMain(m *testing.M) { flag.Parse() exitcode, err := func() (int, error) { - clusterInstance = cluster.NewCluster(cell, hostname) + clusterInstance = cluster.NewCluster(cell, hostname) defer clusterInstance.Teardown() // Reserve vtGate port in order to pass it to vtTablet diff --git a/go/test/endtoend/vtgate/vschema/vschema_test.go b/go/test/endtoend/vtgate/vschema/vschema_test.go index bcab68351dc..1938d183e0e 100644 --- a/go/test/endtoend/vtgate/vschema/vschema_test.go +++ b/go/test/endtoend/vtgate/vschema/vschema_test.go @@ -54,7 +54,7 @@ func TestMain(m *testing.M) { flag.Parse() exitcode, err := func() (int, error) { - clusterInstance = cluster.NewCluster(cell, hostname) + clusterInstance = cluster.NewCluster(cell, hostname) defer clusterInstance.Teardown() // Start topo server diff --git a/go/vt/mysqlctl/mycnf_test.go b/go/vt/mysqlctl/mycnf_test.go index 0fd3e510833..59c4247eacb 100644 --- a/go/vt/mysqlctl/mycnf_test.go +++ b/go/vt/mysqlctl/mycnf_test.go @@ -24,6 +24,7 @@ import ( "testing" "vitess.io/vitess/go/vt/dbconfigs" + "vitess.io/vitess/go/vt/env" "vitess.io/vitess/go/vt/servenv" ) @@ -36,8 +37,12 @@ func TestMycnf(t *testing.T) { // Assigning ServerID to be different from tablet UID to make sure that there are no // assumptions in the code that those IDs are the same. cnf.ServerID = 22222 + root, err := env.VtRoot() + if err != nil { + t.Errorf("err: %v", err) + } cnfTemplatePaths := []string{ - path.Join(os.Getenv("VTTOP"), "/config/mycnf/default.cnf"), + path.Join(root, "config/mycnf/default.cnf"), } data, err := cnf.makeMycnf(cnfTemplatePaths) if err != nil { @@ -74,7 +79,7 @@ func TestMycnf(t *testing.T) { // Run this test if any changes are made to hook handling / make_mycnf hook // other tests fail if we keep the hook around -// 1. ln -snf $VTTOP/test/vthook-make_mycnf $VTROOT/vthook/make_mycnf +// 1. ln -snf $VTROOT/test/vthook-make_mycnf $VTROOT/vthook/make_mycnf // 2. Remove "No" prefix from func name // 3. go test // 4. \rm $VTROOT/vthook/make_mycnf diff --git a/go/vt/vtgate/endtoend/deletetest/delete_test.go b/go/vt/vtgate/endtoend/deletetest/delete_test.go index 9f0cb6ceb79..de6614ed7c9 100644 --- a/go/vt/vtgate/endtoend/deletetest/delete_test.go +++ b/go/vt/vtgate/endtoend/deletetest/delete_test.go @@ -127,7 +127,7 @@ func TestMain(m *testing.M) { }}, }}, } - cfg.ExtraMyCnf = []string{path.Join(os.Getenv("VTTOP"), "config/mycnf/rbr.cnf")} + cfg.ExtraMyCnf = []string{path.Join(os.Getenv("VTROOT"), "config/mycnf/rbr.cnf")} if err := cfg.InitSchemas("ks", schema, vschema); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.RemoveAll(cfg.SchemaDir) diff --git a/go/vt/vtgate/endtoend/main_test.go b/go/vt/vtgate/endtoend/main_test.go index da52636dcec..a3b69cdb6ea 100644 --- a/go/vt/vtgate/endtoend/main_test.go +++ b/go/vt/vtgate/endtoend/main_test.go @@ -171,7 +171,7 @@ func TestMain(m *testing.M) { }}, }}, } - cfg.ExtraMyCnf = []string{path.Join(os.Getenv("VTTOP"), "config/mycnf/rbr.cnf")} + cfg.ExtraMyCnf = []string{path.Join(os.Getenv("VTROOT"), "config/mycnf/rbr.cnf")} if err := cfg.InitSchemas("ks", schema, vschema); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.RemoveAll(cfg.SchemaDir) diff --git a/go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go b/go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go index 599cf3304e1..84b2365a75e 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go +++ b/go/vt/vttablet/tabletserver/vstreamer/testenv/testenv.go @@ -92,7 +92,7 @@ func Init() (*Env, error) { }, }, }, - ExtraMyCnf: []string{path.Join(os.Getenv("VTTOP"), "config/mycnf/rbr.cnf")}, + ExtraMyCnf: []string{path.Join(os.Getenv("VTROOT"), "config/mycnf/rbr.cnf")}, OnlyMySQL: true, } te.cluster = &vttest.LocalCluster{ diff --git a/go/vt/vttest/environment.go b/go/vt/vttest/environment.go index 551cc4e1d9b..130791bce4b 100644 --- a/go/vt/vttest/environment.go +++ b/go/vt/vttest/environment.go @@ -119,7 +119,7 @@ func GetMySQLOptions(flavor string) (string, []string, error) { mycnf = append(mycnf, "config/mycnf/default-fast.cnf") for i, cnf := range mycnf { - mycnf[i] = path.Join(os.Getenv("VTTOP"), cnf) + mycnf[i] = path.Join(os.Getenv("VTROOT"), cnf) } return flavor, mycnf, nil @@ -139,7 +139,7 @@ func (env *LocalTestEnv) BinaryPath(binary string) string { func (env *LocalTestEnv) MySQLManager(mycnf []string, snapshot string) (MySQLManager, error) { return &Mysqlctl{ Binary: env.BinaryPath("mysqlctl"), - InitFile: path.Join(os.Getenv("VTTOP"), "config/init_db.sql"), + InitFile: path.Join(os.Getenv("VTROOT"), "config/init_db.sql"), Directory: env.TmpPath, Port: env.PortForProtocol("mysql", ""), MyCnf: append(env.DefaultMyCnf, mycnf...), diff --git a/java/client/src/test/java/io/vitess/client/TestEnv.java b/java/client/src/test/java/io/vitess/client/TestEnv.java index 1e631e8bfb4..1b12162fcce 100644 --- a/java/client/src/test/java/io/vitess/client/TestEnv.java +++ b/java/client/src/test/java/io/vitess/client/TestEnv.java @@ -72,13 +72,13 @@ public void setPythonScriptProcess(Process process) { * Get setup command to launch a cluster. */ public List getSetupCommand(int port) { - String vtTop = System.getenv("VTTOP"); - if (vtTop == null) { - throw new RuntimeException("cannot find env variable: VTTOP"); + String vtRoot = System.getenv("VTROOT"); + if (vtRoot == null) { + throw new RuntimeException("cannot find env variable: VTROOT"); } String schemaDir = getTestDataPath() + "/schema"; List command = new ArrayList(); - command.add(vtTop + "/py/vttest/run_local_database.py"); + command.add(vtRoot + "/py/vttest/run_local_database.py"); command.add("--port"); command.add(Integer.toString(port)); command.add("--proto_topo"); @@ -89,11 +89,11 @@ public List getSetupCommand(int port) { } public String getTestDataPath() { - String vtTop = System.getenv("VTTOP"); - if (vtTop == null) { - throw new RuntimeException("cannot find env variable: VTTOP"); + String vtRoot = System.getenv("VTROOT"); + if (vtRoot == null) { + throw new RuntimeException("cannot find env variable: VTROOT"); } - return vtTop + "/data/test"; + return vtRoot + "/data/test"; } public String getTestOutputPath() { diff --git a/misc/git/hooks/pylint b/misc/git/hooks/pylint index 4452647f6f9..35f04cee37c 100755 --- a/misc/git/hooks/pylint +++ b/misc/git/hooks/pylint @@ -26,7 +26,7 @@ function msg() { } PYLINT=${PYLINT:-/usr/bin/gpylint} -pylint_script=$VTTOP/tools/pylint.sh +pylint_script=$VTROOT/tools/pylint.sh # This script does not handle file names that contain spaces. pyfiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.*\.py$' | grep -v '^py/vtproto/') @@ -70,7 +70,7 @@ if [[ $? -eq 0 ]]; then do echo msg "Press enter to show the warnings for $pyfile:" - read -p " \$VTTOP/tools/pylint.sh $pyfile" + read -p " \$VTROOT/tools/pylint.sh $pyfile" $pylint_script $pyfile done read -r -p \ diff --git a/py/vttest/mysql_db_mysqlctl.py b/py/vttest/mysql_db_mysqlctl.py index f79f5c6504f..c1ecc8d049f 100644 --- a/py/vttest/mysql_db_mysqlctl.py +++ b/py/vttest/mysql_db_mysqlctl.py @@ -40,7 +40,7 @@ def setup(self): '-mysql_port', str(self._port), 'init', '-init_db_sql_file', - os.path.join(os.environ['VTTOP'], 'config/init_db.sql'), + os.path.join(os.environ['VTROOT'], 'config/init_db.sql'), ] env = os.environ env['VTDATAROOT'] = self._directory diff --git a/py/vttest/mysql_flavor.py b/py/vttest/mysql_flavor.py index 3da1570e05d..c28bf979e02 100644 --- a/py/vttest/mysql_flavor.py +++ b/py/vttest/mysql_flavor.py @@ -23,17 +23,15 @@ import sys -# For now, vttop is only used in this module. If other people +# For now, vtroot is only used in this module. If other people # need this, we should move it to environment. -if "VTTOP" not in os.environ: +if "VTROOT" not in os.environ: sys.stderr.write( "ERROR: Vitess environment not set up. " 'Please run "source dev.env" first.\n') sys.exit(1) -# vttop is the toplevel of the vitess source tree -vttop = os.environ["VTTOP"] - +vtroot = os.environ["VTROOT"] class MysqlFlavor(object): """Base class with default SQL statements.""" @@ -48,7 +46,7 @@ class MariaDB(MysqlFlavor): def my_cnf(self): files = [ - os.path.join(vttop, "config/mycnf/default-fast.cnf"), + os.path.join(vtroot, "config/mycnf/default-fast.cnf"), ] return ":".join(files) @@ -57,7 +55,7 @@ class MariaDB103(MysqlFlavor): def my_cnf(self): files = [ - os.path.join(vttop, "config/mycnf/default-fast.cnf"), + os.path.join(vtroot, "config/mycnf/default-fast.cnf"), ] return ":".join(files) @@ -66,7 +64,7 @@ class MySQL56(MysqlFlavor): def my_cnf(self): files = [ - os.path.join(vttop, "config/mycnf/default-fast.cnf"), + os.path.join(vtroot, "config/mycnf/default-fast.cnf"), ] return ":".join(files) @@ -75,7 +73,7 @@ class MySQL80(MysqlFlavor): def my_cnf(self): files = [ - os.path.join(vttop, "config/mycnf/default-fast.cnf"), + os.path.join(vtroot, "config/mycnf/default-fast.cnf"), ] return ":".join(files) diff --git a/test.go b/test.go index 73b75e9df30..846cb0c8755 100755 --- a/test.go +++ b/test.go @@ -27,7 +27,7 @@ run against a given flavor, it may take some time for the corresponding bootstrap image (vitess/bootstrap:) to be downloaded. It is meant to be run from the Vitess root, like so: - ~/src/vitess.io/vitess$ go run test.go [args] + $ go run test.go [args] For a list of options, run: $ go run test.go --help @@ -195,6 +195,7 @@ func (t *Test) run(dir, dataDir string) ([]byte, error) { // Also try to make them use different port ranges // to mitigate failures due to zombie processes. cmd.Env = updateEnv(os.Environ(), map[string]string{ + "VTROOT": "/vt/src/vitess.io/vitess", "VTDATAROOT": dataDir, "VTPORTSTART": strconv.FormatInt(int64(getPortStart(100)), 10), }) @@ -370,7 +371,7 @@ func main() { } tests = dup - vtTop := "." + vtRoot := "." tmpDir := "" if *docker { // Copy working repo to tmpDir. @@ -387,7 +388,7 @@ func main() { if out, err := exec.Command("chmod", "-R", "go=u", tmpDir).CombinedOutput(); err != nil { log.Printf("Can't set permissions on temp dir %v: %v: %s", tmpDir, err, out) } - vtTop = tmpDir + vtRoot = tmpDir } else { // Since we're sharing the working dir, do the build once for all tests. log.Printf("Running make build...") @@ -473,7 +474,7 @@ func main() { // Run the test. start := time.Now() - output, err := test.run(vtTop, dataDir) + output, err := test.run(vtRoot, dataDir) duration := time.Since(start) // Save/print test output. diff --git a/test/backup.py b/test/backup.py index 823e2a2ba2a..51b7a94eef4 100755 --- a/test/backup.py +++ b/test/backup.py @@ -95,7 +95,7 @@ def setUpModule(): # Create a new init_db.sql file that sets up passwords for all users. # Then we use a db-credentials-file with the passwords. new_init_db = environment.tmproot + '/init_db_with_passwords.sql' - with open(environment.vttop + '/config/init_db.sql') as fd: + with open(environment.vtroot + '/config/init_db.sql') as fd: init_db = fd.read() with open(new_init_db, 'w') as fd: fd.write(init_db) diff --git a/test/backup_only.py b/test/backup_only.py index dd9b547dacf..04f2db4dfdc 100755 --- a/test/backup_only.py +++ b/test/backup_only.py @@ -95,7 +95,7 @@ def setUpModule(): # Create a new init_db.sql file that sets up passwords for all users. # Then we use a db-credentials-file with the passwords. new_init_db = environment.tmproot + '/init_db_with_passwords.sql' - with open(environment.vttop + '/config/init_db.sql') as fd: + with open(environment.vtroot + '/config/init_db.sql') as fd: init_db = fd.read() with open(new_init_db, 'w') as fd: fd.write(init_db) diff --git a/test/backup_transform.py b/test/backup_transform.py index b0e665b6fa8..00f3ef9223e 100755 --- a/test/backup_transform.py +++ b/test/backup_transform.py @@ -79,7 +79,7 @@ def setUpModule(): # Create a new init_db.sql file that sets up passwords for all users. # Then we use a db-credentials-file with the passwords. new_init_db = environment.tmproot + '/init_db_with_passwords.sql' - with open(environment.vttop + '/config/init_db.sql') as fd: + with open(environment.vtroot + '/config/init_db.sql') as fd: init_db = fd.read() with open(new_init_db, 'w') as fd: fd.write(init_db) diff --git a/test/client_test.sh b/test/client_test.sh index 82be7996c8d..6ad69b2023f 100755 --- a/test/client_test.sh +++ b/test/client_test.sh @@ -17,8 +17,10 @@ # This runs client tests. It used to be part of local_example, # but has been moved to its own test. It hijacks the public examples scripts +source build.env + set -xe -cd "$VTTOP/examples/local" +cd "$VTROOT/examples/local" CELL=test ./etcd-up.sh CELL=test ./vtctld-up.sh diff --git a/test/cluster/k8s_environment.py b/test/cluster/k8s_environment.py index 0951ae58a09..d0026fb70b5 100644 --- a/test/cluster/k8s_environment.py +++ b/test/cluster/k8s_environment.py @@ -121,7 +121,7 @@ def create(self, **kwargs): if 'VITESS_NAME' not in kwargs: kwargs['VITESS_NAME'] = getpass.getuser() kwargs['TEST_MODE'] = '1' - self.script_dir = os.path.join(os.environ['VTTOP'], 'examples/kubernetes') + self.script_dir = os.path.join(os.environ['VTROOT'], 'examples/kubernetes') try: subprocess.check_output(['gcloud', 'config', 'list']) except OSError: diff --git a/test/cluster/keytar/README.md b/test/cluster/keytar/README.md index 081957d192a..b9279dfc235 100644 --- a/test/cluster/keytar/README.md +++ b/test/cluster/keytar/README.md @@ -7,8 +7,8 @@ Keytar is an internally used Vitess system for continuous execution of cluster t How to set up Keytar for Vitess: * Create service account keys with GKE credentials on the account to run the tests on. Follow [step 1 from the GKE developers page](https://developers.google.com/identity/protocols/application-default-credentials?hl=en_US#howtheywork). -* Move the generated keyfile to `$VTTOP/test/cluster/keytar/config`. -* Create or modify the test configuration file (`$VTTOP/test/cluster/keytar/config/vitess_config.yaml`). +* Move the generated keyfile to `$VTROOT/test/cluster/keytar/config`. +* Create or modify the test configuration file (`$VTROOT/test/cluster/keytar/config/vitess_config.yaml`). * Ensure the configuration has the correct values for GKE project name and keyfile: ``` cluster_setup: @@ -18,7 +18,7 @@ How to set up Keytar for Vitess: ``` * Then run the following commands: ``` - > cd $VTTOP/test/cluster/keytar + > cd $VTROOT/test/cluster/keytar > KEYTAR_PASSWORD= KEYTAR_PORT= KEYTAR_CONFIG= ./keytar-up.sh ``` * Add a Docker Hub webhook pointing to the Keytar service. The webhook URL should be in the form: diff --git a/test/cluster/keytar/config/vitess_config.yaml b/test/cluster/keytar/config/vitess_config.yaml index a8b0e8a995b..34213cfaeb9 100644 --- a/test/cluster/keytar/config/vitess_config.yaml +++ b/test/cluster/keytar/config/vitess_config.yaml @@ -20,17 +20,15 @@ config: - docker_image: vitess/root github: repo: vitessio/vitess - repo_prefix: src/vitess.io/vitess environment: sandbox: test/cluster/sandbox/vitess_kubernetes_sandbox.py config: test/cluster/sandbox/example_sandbox.yaml cluster_type: gke application_type: k8s before_test: - - export VTTOP=$(pwd) - - export VTROOT="${VTROOT:-${VTTOP/\/src\/github.com\/youtube\/vitess/}}" + - export VTROOT=$(pwd) - export GOPATH=$VTROOT - - export PYTHONPATH=$VTTOP/py:$VTTOP/test:$VTTOP/test/cluster/sandbox:/usr/lib/python2.7/dist-packages:/env/lib/python2.7/site-packages + - export PYTHONPATH=$VTROOT/py:$VTROOT/test:$VTROOT/test/cluster/sandbox:/usr/lib/python2.7/dist-packages:/env/lib/python2.7/site-packages - go get vitess.io/vitess/go/cmd/vtctlclient - export PATH=$GOPATH/bin:$PATH tests: diff --git a/test/cluster/keytar/keytar_web_test.py b/test/cluster/keytar/keytar_web_test.py index 5784d3335f5..247cec4478a 100755 --- a/test/cluster/keytar/keytar_web_test.py +++ b/test/cluster/keytar/keytar_web_test.py @@ -35,7 +35,7 @@ class TestKeytarWeb(unittest.TestCase): def setUpClass(cls): cls.driver = environment.create_webdriver() port = environment.reserve_ports(1) - keytar_folder = os.path.join(environment.vttop, 'test/cluster/keytar') + keytar_folder = os.path.join(environment.vtroot, 'test/cluster/keytar') cls.flask_process = subprocess.Popen( [os.path.join(keytar_folder, 'keytar.py'), '--config_file=%s' % os.path.join(keytar_folder, 'test_config.yaml'), diff --git a/test/cluster/keytar/test_config.yaml b/test/cluster/keytar/test_config.yaml index 308c6de7026..8eaad2c36b1 100644 --- a/test/cluster/keytar/test_config.yaml +++ b/test/cluster/keytar/test_config.yaml @@ -5,7 +5,6 @@ config: - docker_image: test/image github: repo: vitessio/vitess - repo_prefix: src/vitess.io/vitess before_test: - touch /tmp/test_file environment: diff --git a/test/cluster/sandbox/create_schema.py b/test/cluster/sandbox/create_schema.py index 198858eeffe..d60839bd013 100755 --- a/test/cluster/sandbox/create_schema.py +++ b/test/cluster/sandbox/create_schema.py @@ -33,7 +33,7 @@ def main(): parser.add_option( '-s', '--sql_file', help='File containing sql schema', default=os.path.join( - os.environ['VTTOP'], 'examples/kubernetes/create_test_table.sql')) + os.environ['VTROOT'], 'examples/kubernetes/create_test_table.sql')) logging.getLogger().setLevel(logging.INFO) options, _ = parser.parse_args() diff --git a/test/cluster/sandbox/kubernetes_components.py b/test/cluster/sandbox/kubernetes_components.py index e67c4bf379c..94d3ac5e947 100755 --- a/test/cluster/sandbox/kubernetes_components.py +++ b/test/cluster/sandbox/kubernetes_components.py @@ -81,7 +81,7 @@ def start(self): logging.info('Installing helm.') try: subprocess.check_output( - ['helm', 'install', os.path.join(os.environ['VTTOP'], 'helm/vitess'), + ['helm', 'install', os.path.join(os.environ['VTROOT'], 'helm/vitess'), '-n', self.sandbox_name, '--namespace', self.sandbox_name, '--replace', '--values', self.helm_config], stderr=subprocess.STDOUT) diff --git a/test/cluster/sandbox/vitess_kubernetes_sandbox.py b/test/cluster/sandbox/vitess_kubernetes_sandbox.py index 734f8d1ac46..016a8d99916 100755 --- a/test/cluster/sandbox/vitess_kubernetes_sandbox.py +++ b/test/cluster/sandbox/vitess_kubernetes_sandbox.py @@ -46,7 +46,7 @@ def generate_guestbook_sandlet(self): """Creates a sandlet encompassing the guestbook app built on Vitess.""" guestbook_sandlet = sandlet.Sandlet('guestbook') guestbook_sandlet.dependencies = ['helm'] - template_dir = os.path.join(os.environ['VTTOP'], 'examples/kubernetes') + template_dir = os.path.join(os.environ['VTROOT'], 'examples/kubernetes') guestbook_sandlet.components.add_component( self.cluster_env.Port('%s-guestbook' % self.name, 80)) for keyspace in self.app_options.keyspaces: @@ -54,7 +54,7 @@ def generate_guestbook_sandlet(self): 'create_schema_%s' % keyspace['name'], self.name, 'create_schema.py', self.log_dir, namespace=self.name, keyspace=keyspace['name'], drop_table='messages', sql_file=os.path.join( - os.environ['VTTOP'], 'examples/kubernetes/create_test_table.sql')) + os.environ['VTROOT'], 'examples/kubernetes/create_test_table.sql')) guestbook_sandlet.components.add_component(create_schema_subprocess) guestbook_sandlet.components.add_component( kubernetes_components.KubernetesResource( diff --git a/test/cluster/sandbox/vtctl_sandbox.py b/test/cluster/sandbox/vtctl_sandbox.py index ef0f1d978ed..3e495b414ab 100755 --- a/test/cluster/sandbox/vtctl_sandbox.py +++ b/test/cluster/sandbox/vtctl_sandbox.py @@ -68,7 +68,7 @@ def execute_vtctl_command(vtctl_args, namespace='default', timeout_s=180): # Default to trying to use kvtctl.sh if a forwarded port cannot be found. os.environ['VITESS_NAME'] = namespace vtctl_cmd_args = ( - [os.path.join(os.environ['VTTOP'], 'examples/kubernetes/kvtctl.sh')] + [os.path.join(os.environ['VTROOT'], 'examples/kubernetes/kvtctl.sh')] + vtctl_args) start_time = time.time() diff --git a/test/config.json b/test/config.json index a8648f96063..be3ddd1b574 100644 --- a/test/config.json +++ b/test/config.json @@ -261,7 +261,7 @@ "Args": [], "Command": [], "Manual": false, - "Shard": 4, + "Shard": 5, "RetryMax": 0, "Tags": [] }, diff --git a/test/environment.py b/test/environment.py index ce3b58db683..eee51cc4523 100644 --- a/test/environment.py +++ b/test/environment.py @@ -53,14 +53,6 @@ 'ERROR: Vitess and mysqld ' 'should not be run as root.\n') sys.exit(1) -if 'VTTOP' not in os.environ: - sys.stderr.write( - 'ERROR: Vitess environment not set up. ' - 'Please run "source dev.env" first.\n') - sys.exit(1) - -# vttop is the toplevel of the vitess source tree -vttop = os.environ['VTTOP'] # vtroot is where everything gets installed vtroot = os.environ['VTROOT'] @@ -162,7 +154,7 @@ def prog_compile(name): return compiled_progs.append(name) logging.debug('Compiling %s', name) - run(['go', 'install'], cwd=os.path.join(vttop, 'go', 'cmd', name)) + run(['go', 'install'], cwd=os.path.join(vtroot, 'go', 'cmd', name)) # binary management: returns the full path for a binary this should diff --git a/test/initial_sharding_multi.py b/test/initial_sharding_multi.py index af0b167ed2d..8edad5a73e5 100755 --- a/test/initial_sharding_multi.py +++ b/test/initial_sharding_multi.py @@ -127,7 +127,7 @@ def setUpModule(): # Create a new init_db.sql file that sets up passwords for all users. # Then we use a db-credentials-file with the passwords. new_init_db = environment.tmproot + '/init_db_with_passwords.sql' - with open(environment.vttop + '/config/init_db.sql') as fd: + with open(environment.vtroot + '/config/init_db.sql') as fd: init_db = fd.read() with open(new_init_db, 'w') as fd: fd.write(init_db) diff --git a/test/local_example.sh b/test/local_example.sh index f0ba0f4278b..26c41abf15f 100755 --- a/test/local_example.sh +++ b/test/local_example.sh @@ -18,9 +18,11 @@ # It should be kept in sync with the steps in https://vitess.io/docs/get-started/local/ # So we can detect if a regression affecting a tutorial is introduced. +source build.env + set -xe -cd "$VTTOP/examples/local" +cd "$VTROOT/examples/local" ./101_initial_cluster.sh diff --git a/test/tablet.py b/test/tablet.py index 552c7d5031d..ba7ff2716ee 100644 --- a/test/tablet.py +++ b/test/tablet.py @@ -55,7 +55,7 @@ def get_backup_storage_flags(): def get_all_extra_my_cnf(extra_my_cnf): - all_extra_my_cnf = [environment.vttop + '/config/mycnf/default-fast.cnf'] + all_extra_my_cnf = [environment.vtroot + '/config/mycnf/default-fast.cnf'] flavor_my_cnf = mysql_flavor().extra_my_cnf() if flavor_my_cnf: all_extra_my_cnf.append(flavor_my_cnf) @@ -186,12 +186,12 @@ def init_mysql(self, extra_my_cnf=None, init_db=None, extra_args=None, """ if use_rbr: if extra_my_cnf: - extra_my_cnf += ':' + environment.vttop + '/config/mycnf/rbr.cnf' + extra_my_cnf += ':' + environment.vtroot + '/config/mycnf/rbr.cnf' else: - extra_my_cnf = environment.vttop + '/config/mycnf/rbr.cnf' + extra_my_cnf = environment.vtroot + '/config/mycnf/rbr.cnf' if not init_db: - init_db = environment.vttop + '/config/init_db.sql' + init_db = environment.vtroot + '/config/init_db.sql' if self.use_mysqlctld: self.mysqlctld_process = self.mysqlctld(['-init_db_sql_file', init_db], diff --git a/test/utils.py b/test/utils.py index 0a162375fff..8f645c6cbd8 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1214,8 +1214,8 @@ def start(self, enable_schema_change_dir=False, extra_flags=None): args = environment.binary_args('vtctld') + [ '-enable_queries', '-cell', 'test_nj', - '-web_dir', environment.vttop + '/web/vtctld', - '-web_dir2', environment.vttop + '/web/vtctld2', + '-web_dir', environment.vtroot + '/web/vtctld', + '-web_dir2', environment.vtroot + '/web/vtctld2', '--log_dir', environment.vtlogroot, '--port', str(self.port), '-tablet_manager_protocol', diff --git a/test/vtbackup.py b/test/vtbackup.py index f42831ea4e0..fecaca6612d 100644 --- a/test/vtbackup.py +++ b/test/vtbackup.py @@ -35,7 +35,7 @@ def get_backup_storage_flags(): os.path.join(environment.tmproot, 'backupstorage')] def get_all_extra_my_cnf(extra_my_cnf): - all_extra_my_cnf = [environment.vttop + '/config/mycnf/default-fast.cnf'] + all_extra_my_cnf = [environment.vtroot + '/config/mycnf/default-fast.cnf'] flavor_my_cnf = mysql_flavor().extra_my_cnf() if flavor_my_cnf: all_extra_my_cnf.append(flavor_my_cnf) diff --git a/test/vtctld_web_test.py b/test/vtctld_web_test.py index 19738abf77f..33fd8e00861 100755 --- a/test/vtctld_web_test.py +++ b/test/vtctld_web_test.py @@ -86,12 +86,12 @@ def setUpClass(cls): cls.db = local_database.LocalDatabase( topology, - os.path.join(environment.vttop, 'test/vttest_schema'), + os.path.join(environment.vtroot, 'test/vttest_schema'), False, None, - web_dir=os.path.join(environment.vttop, 'web/vtctld'), + web_dir=os.path.join(environment.vtroot, 'web/vtctld'), default_schema_dir=os.path.join( - environment.vttop, 'test/vttest_schema/default'), - web_dir2=os.path.join(environment.vttop, 'web/vtctld2/app')) + environment.vtroot, 'test/vttest_schema/default'), + web_dir2=os.path.join(environment.vtroot, 'web/vtctld2/app')) cls.db.setup() cls.vtctld_addr = 'http://localhost:%d' % cls.db.config()['port'] utils.pause('Paused test after vtcombo was started.\n' diff --git a/test/vttest_sample_test.py b/test/vttest_sample_test.py index 98888a97777..a4a7de4639f 100755 --- a/test/vttest_sample_test.py +++ b/test/vttest_sample_test.py @@ -82,9 +82,9 @@ def test_standalone(self): '--port', str(port), '--proto_topo', text_format.MessageToString(topology, as_one_line=True), - '--schema_dir', os.path.join(environment.vttop, 'test', + '--schema_dir', os.path.join(environment.vtroot, 'test', 'vttest_schema'), - '--web_dir', environment.vttop + '/web/vtctld', + '--web_dir', environment.vtroot + '/web/vtctld', ] sp = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) config = json.loads(sp.stdout.readline()) diff --git a/tools/bootstrap_web.sh b/tools/bootstrap_web.sh index aecc89b8f80..cc0e40966c9 100755 --- a/tools/bootstrap_web.sh +++ b/tools/bootstrap_web.sh @@ -39,12 +39,12 @@ else # Add the node directory to PATH to make sure that the Angular # installation below can find the "node" binary. # (dev.env does actually append it to PATH.) - source $VTTOP/dev.env + source $VTROOT/dev.env fi echo "Installing dependencies for building web UI" angular_cli_dir=$VTROOT/dist/angular-cli -web_dir2=$VTTOP/web/vtctld2 +web_dir2=$VTROOT/web/vtctld2 angular_cli_commit=cacaa4eff10e135016ef81076fab1086a3bce92f if [[ -d $angular_cli_dir && `cd $angular_cli_dir && git rev-parse HEAD` == "$angular_cli_commit" ]]; then echo "skipping angular cli download. remove $angular_cli_dir to force download." diff --git a/tools/check_make_parser.sh b/tools/check_make_parser.sh index d28d4f18f09..ef59eb67a9f 100755 --- a/tools/check_make_parser.sh +++ b/tools/check_make_parser.sh @@ -6,6 +6,8 @@ # This is used in Travis to verify that the currently committed version was # generated with the proper version of goyacc. +source build.env + CUR="sql.go" TMP="/tmp/sql.$$.go" diff --git a/tools/dependency_check.sh b/tools/dependency_check.sh new file mode 100755 index 00000000000..33b3f1ecb24 --- /dev/null +++ b/tools/dependency_check.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright 2019 The Vitess Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source build.env + +function fail() { + echo "ERROR: $1" + exit 1 +} + +for binary in mysqld consul etcd etcdctl zksrv.sh; do + command -v "$binary" > /dev/null || fail "${binary} is not installed in PATH. Run 'make tools' to install dependencies." +done; diff --git a/tools/e2e_test_cluster.sh b/tools/e2e_test_cluster.sh index d9ca94f6557..991cd29ce53 100755 --- a/tools/e2e_test_cluster.sh +++ b/tools/e2e_test_cluster.sh @@ -19,6 +19,9 @@ # All Go packages with test files. # Output per line: * + +source build.env + packages_with_tests=$(go list -f '{{if len .TestGoFiles}}{{.ImportPath}} {{join .TestGoFiles " "}}{{end}}' ./go/.../endtoend/... | sort) cluster_tests=$(echo "$packages_with_tests" | grep -E "go/test/endtoend" | cut -d" " -f1) diff --git a/tools/e2e_test_race.sh b/tools/e2e_test_race.sh index f3a31ac3af8..32374a25c17 100755 --- a/tools/e2e_test_race.sh +++ b/tools/e2e_test_race.sh @@ -14,12 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +source build.env + temp_log_file="$(mktemp --suffix .unit_test_race.log)" trap '[ -f "$temp_log_file" ] && rm $temp_log_file' EXIT -# This can be removed once the docker images are rebuilt -export GO111MODULE=on - # Wrapper around go test -race. # This script exists because the -race test doesn't allow to distinguish diff --git a/tools/e2e_test_runner.sh b/tools/e2e_test_runner.sh index e2b9da256ad..c581957a366 100755 --- a/tools/e2e_test_runner.sh +++ b/tools/e2e_test_runner.sh @@ -29,6 +29,9 @@ # Set VT_GO_PARALLEL variable in the same way as the Makefile does. # We repeat this here because this script is called directly by test.go # and not via the Makefile. + +source build.env + if [[ -z $VT_GO_PARALLEL && -n $VT_GO_PARALLEL_VALUE ]]; then VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" fi diff --git a/tools/generate_web_artifacts.sh b/tools/generate_web_artifacts.sh index d21da7e84e6..a7080db7828 100755 --- a/tools/generate_web_artifacts.sh +++ b/tools/generate_web_artifacts.sh @@ -20,7 +20,7 @@ set -e -vtctld2_dir=$VTTOP/web/vtctld2 +vtctld2_dir=$VTROOT/web/vtctld2 if [[ -d $vtctld2_dir/app ]]; then rm -rf $vtctld2_dir/app fi diff --git a/tools/unit_test_race.sh b/tools/unit_test_race.sh index 6fee1b9a9eb..2253cab77bc 100755 --- a/tools/unit_test_race.sh +++ b/tools/unit_test_race.sh @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +source build.env + if [[ -z $VT_GO_PARALLEL && -n $VT_GO_PARALLEL_VALUE ]]; then VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" fi diff --git a/tools/unit_test_runner.sh b/tools/unit_test_runner.sh index 382dd2f0b76..4cffb3eb913 100755 --- a/tools/unit_test_runner.sh +++ b/tools/unit_test_runner.sh @@ -29,6 +29,9 @@ # Set VT_GO_PARALLEL variable in the same way as the Makefile does. # We repeat this here because this script is called directly by test.go # and not via the Makefile. + +source build.env + if [[ -z $VT_GO_PARALLEL && -n $VT_GO_PARALLEL_VALUE ]]; then VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" fi From df9f5bf9fb82d41911c58325979c99de7475082a Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Sat, 7 Dec 2019 12:24:10 -0700 Subject: [PATCH 2/4] Auto-detect VTDATAROOT if not set Signed-off-by: Morgan Tocker --- examples/local/env.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/local/env.sh b/examples/local/env.sh index b1833e997f5..648a71beb4c 100644 --- a/examples/local/env.sh +++ b/examples/local/env.sh @@ -16,6 +16,7 @@ hostname=`hostname -f` vtctld_web_port=15000 +export VTDATAROOT="${VTDATAROOT:-${VTROOT}/vtdataroot}" function fail() { echo "ERROR: $1" From 3ece1fc7d6424415f5a769e2a9ea81f00bb64bbe Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 9 Dec 2019 13:58:08 -0700 Subject: [PATCH 3/4] Disable tls13 for go 1.13 unit tests to pass Signed-off-by: Morgan Tocker --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 8eab33561d7..b41ad53a9fe 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ MAKEFLAGS = -s export GOBIN=$(PWD)/bin export GO111MODULE=on +export GODEBUG=tls13=0 # 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. From 65e2b22cf44054e39b61799fae9950bbba0bb269 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 9 Dec 2019 15:42:49 -0700 Subject: [PATCH 4/4] Fix 'make cleanall' and remove older make target Signed-off-by: Morgan Tocker --- Makefile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Makefile b/Makefile index b41ad53a9fe..04b3c121e3f 100644 --- a/Makefile +++ b/Makefile @@ -66,19 +66,11 @@ clean: rm -rf third_party/acolyte rm -rf go/vt/.proto.tmp -# 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 - # Remove everything including stuff pulled down by bootstrap.sh cleanall: - # symlinks - for f in config data py-vtdb; do test -L ../../../../$$f && rm ../../../../$$f; done # directories created by bootstrap.sh # - exclude vtdataroot and vthook as they may have data we want - rm -rf ../../../../bin ../../../../dist ../../../../lib ../../../../pkg + rm -rf bin dist lib pkg # Remind people to run bootstrap.sh again echo "Please run 'make tools' again to setup your environment"