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 <tocker@gmail.com>
This commit is contained in:
Morgan Tocker 2019-12-07 12:11:06 -07:00
Родитель 761c44f2f7
Коммит b25d149479
79 изменённых файлов: 282 добавлений и 482 удалений

175
.github/bootstrap.sh поставляемый
Просмотреть файл

@ -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"

9
.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

14
.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

14
.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

13
.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

11
.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

13
.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

12
.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

7
.gitignore поставляемый
Просмотреть файл

@ -79,3 +79,10 @@ releases
# Vagrant
.vagrant
dist/*
py-vtdb*
vthook*
bin*
vtdataroot*

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

@ -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

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

@ -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"

42
build.env Normal file → Executable file
Просмотреть файл

@ -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..
source ./tools/shell_functions.inc
# 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
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+"
export VTTOP=$(pwd)
export VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
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

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

@ -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.

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

@ -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"]

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

@ -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 && \

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

@ -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)

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

@ -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

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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 .")
bashcmd=""
# 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"
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")

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

@ -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' \

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

@ -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' \

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

@ -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),

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

@ -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/

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

@ -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

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

@ -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.

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

@ -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"

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

@ -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' \

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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)

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

@ -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)

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

@ -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{

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

@ -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...),

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

@ -72,13 +72,13 @@ public class TestEnv {
* Get setup command to launch a cluster.
*/
public List<String> 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<String> command = new ArrayList<String>();
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 class TestEnv {
}
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() {

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

@ -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 \

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

@ -40,7 +40,7 @@ class MySqlDBMysqlctl(mysql_db.MySqlDB):
'-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

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

@ -23,17 +23,15 @@ import os
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)

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

@ -27,7 +27,7 @@ run against a given flavor, it may take some time for the corresponding
bootstrap image (vitess/bootstrap:<flavor>) 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.

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

@ -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)

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

@ -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)

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

@ -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)

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

@ -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

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

@ -121,7 +121,7 @@ class K8sEnvironment(base_environment.BaseEnvironment):
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:

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

@ -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=<desired password> KEYTAR_PORT=<desired port, default 8080> KEYTAR_CONFIG=<desired configuration, default vitess_config.yaml> ./keytar-up.sh
```
* Add a Docker Hub webhook pointing to the Keytar service. The webhook URL should be in the form:

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

@ -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:

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

@ -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'),

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

@ -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:

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

@ -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()

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

@ -81,7 +81,7 @@ class HelmComponent(sandlet.SandletComponent):
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)

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

@ -46,7 +46,7 @@ class VitessKubernetesSandbox(sandbox.Sandbox):
"""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 @@ class VitessKubernetesSandbox(sandbox.Sandbox):
'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(

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

@ -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()

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

@ -261,7 +261,7 @@
"Args": [],
"Command": [],
"Manual": false,
"Shard": 4,
"Shard": 5,
"RetryMax": 0,
"Tags": []
},

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

@ -53,14 +53,6 @@ if os.getuid() == 1:
'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

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

@ -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)

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

@ -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

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

@ -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 @@ class Tablet(object):
"""
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],

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

@ -1214,8 +1214,8 @@ class Vtctld(object):
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',

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

@ -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)

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

@ -86,12 +86,12 @@ class TestVtctldWeb(unittest.TestCase):
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'

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

@ -82,9 +82,9 @@ class TestMysqlctl(unittest.TestCase):
'--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())

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

@ -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."

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

@ -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"

26
tools/dependency_check.sh Executable file
Просмотреть файл

@ -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;

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

@ -19,6 +19,9 @@
# All Go packages with test files.
# Output per line: <full Go package name> <all _test.go files in the package>*
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)

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

@ -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

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

@ -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

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

@ -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

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

@ -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

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

@ -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