Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br: migrate br github actions to tidb #27598

Merged
merged 40 commits into from Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
00008b4
migrate br github action to tidb
3pointer Aug 26, 2021
7c9c1e5
add token
3pointer Aug 26, 2021
38e0135
add action to trigger action
3pointer Aug 26, 2021
65211a6
fix
3pointer Aug 26, 2021
18f8563
fix path
3pointer Aug 26, 2021
7f4b596
fix build
3pointer Aug 26, 2021
7d617ec
fix
3pointer Aug 26, 2021
f4d3913
fix build
3pointer Aug 26, 2021
2602f5a
fix build
3pointer Aug 26, 2021
d8af389
try fix tests
3pointer Aug 26, 2021
d0726bc
fix
3pointer Aug 26, 2021
0b3edc1
fix
3pointer Aug 26, 2021
c1221a2
fix
3pointer Aug 26, 2021
84d17e7
fix
3pointer Aug 26, 2021
622b4bb
fix
3pointer Aug 26, 2021
73da6cb
fix
3pointer Aug 26, 2021
5cce1c3
debug
3pointer Aug 26, 2021
806c56b
fix
3pointer Aug 26, 2021
374fd30
fix
3pointer Aug 26, 2021
aa0d250
fix
3pointer Aug 26, 2021
d7b3766
debug
3pointer Aug 26, 2021
fe1e9ba
debug
3pointer Aug 26, 2021
860887f
fix
3pointer Aug 26, 2021
0992b72
debug
3pointer Aug 26, 2021
35ac4d7
fix
3pointer Aug 26, 2021
88d47f5
fix
3pointer Aug 26, 2021
8a96189
fix go mod
3pointer Aug 26, 2021
1a74ea4
Merge branch 'master' into actions
3pointer Aug 26, 2021
e846e7c
update go mod
3pointer Aug 27, 2021
ce29e12
Merge branch 'master' into actions
kennytm Aug 30, 2021
f8c7840
Merge branch 'master' into actions
3pointer Aug 30, 2021
ac7a633
Merge branch 'master' into actions
3pointer Aug 31, 2021
83080ad
address comment
3pointer Aug 31, 2021
5827a24
update cloud-google-go to v1.16.1 to fix br gcs test
3pointer Sep 2, 2021
acbf011
Merge branch 'master' into actions
3pointer Sep 2, 2021
6595846
Merge branch 'master' into actions
3pointer Sep 7, 2021
1b2f5a8
Merge branch 'master' into actions
3pointer Sep 8, 2021
041435d
Merge branch 'master' into actions
3pointer Sep 9, 2021
3326d36
Merge branch 'master' into actions
glorv Sep 9, 2021
8c62d69
Merge branch 'master' into actions
ti-chi-bot Sep 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/br_compatible_test.yml
@@ -0,0 +1,65 @@
name: BR / Compatibility Test

on:
push:
branches:
- master
- 'release-[0-9].[0-9]*'
paths:
- 'br/**'
- '!**.html'
- '!**.md'
- '!CNAME'
- '!LICENSE'
- '!br/docs/**'
- '!br/tests/**'
- '!br/docker/**'
pull_request:
branches:
- master
- 'release-[0-9].[0-9]*'
paths:
- 'br/**'
- '!**.html'
- '!**.md'
- '!CNAME'
- '!LICENSE'
- '!br/docs/**'
- '!br/tests/**'
- '!br/docker/**'

jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 25
steps:

- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Generate compatibility test backup data
timeout-minutes: 15
run: sh br/compatibility/prepare_backup.sh

- name: Start server
run: |
TAG=nightly PORT_SUFFIX=1 docker-compose -f br/compatibility/backup_cluster.yaml rm -s -v
TAG=nightly PORT_SUFFIX=1 docker-compose -f br/compatibility/backup_cluster.yaml build
TAG=nightly PORT_SUFFIX=1 docker-compose -f br/compatibility/backup_cluster.yaml up --remove-orphans -d
TAG=nightly PORT_SUFFIX=1 docker-compose -f br/compatibility/backup_cluster.yaml exec -T control make build_br
TAG=nightly PORT_SUFFIX=1 docker-compose -f br/compatibility/backup_cluster.yaml exec -T control br/tests/run_compatible.sh run

- name: Collect component log
if: ${{ failure() }}
run: |
tar czvf ${{ github.workspace }}/logs.tar.gz /tmp/br/docker/backup_logs/*

- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: logs
path: ${{ github.workspace }}/logs.tar.gz
@@ -1,35 +1,37 @@
name: build
name: BR & Lightning
on:
push:
branches:
- master
- 'release-[0-9].[0-9]*'
paths-ignore:
- '**.html'
- '**.md'
- 'CNAME'
- 'LICENSE'
- 'docs/**'
- 'tests/**'
- 'docker/**'
- '.github/workflows/**.yml'
paths:
- 'br/**'
- '!**.html'
- '!**.md'
- '!CNAME'
- '!LICENSE'
- '!br/docs/**'
- '!br/tests/**'
- '!br/docker/**'
pull_request:
branches:
- master
- 'release-[0-9].[0-9]*'
paths-ignore:
- '**.html'
- '**.md'
- 'CNAME'
- 'LICENSE'
- 'docs/**'
- 'tests/**'
- 'docker/**'
- '.github/workflows/**.yml'
paths:
- 'br/**'
- '!**.html'
- '!**.md'
- '!CNAME'
- '!LICENSE'
- '!br/docs/**'
- '!br/tests/**'
- '!br/docker/**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
compile:
name: ${{ matrix.os }} / ${{ matrix.target}}
name: Compile for ${{ matrix.os }} / ${{ matrix.target}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -51,7 +53,7 @@ jobs:
go-version: 1.16

- name: Run build
run: make build
run: make build_tools

compile-freebsd:
name: Compile for FreeBSD job
Expand All @@ -65,4 +67,4 @@ jobs:
go-version: 1.16

- name: Compile for FreeBSD
run: GOOS=freebsd make build
run: GOOS=freebsd make build_tools
71 changes: 0 additions & 71 deletions br/.github/workflows/compatible_test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion br/README.md
Expand Up @@ -123,7 +123,7 @@ bin/br restore table --db test \
mysql --host 127.0.0.1 -P4000 -E -e "SELECT COUNT(*) FROM test.order_line" -uroot -p
```

## Compatible test
## Compatibility test

See [COMPATBILE_TEST](./COMPATIBLE_TEST.md)

Expand Down
6 changes: 3 additions & 3 deletions br/compatibility/backup_cluster.yaml
Expand Up @@ -6,13 +6,13 @@ services:
control:
image: control:nightly
build:
context: ../
dockerfile: ./docker/Dockerfile
context: ../../
dockerfile: ./br/docker/Dockerfile
volumes:
- /tmp/br/docker/backup_data/${TAG}:/data
- /tmp/br/docker/backup_logs/${TAG}:/tmp
- /tmp/br/docker/backup_logs/${TAG}:/logs
- ../bin:/go/src/github.com/pingcap/br/bin
- ../../bin:/go/src/github.com/pingcap/br/bin
- ./prepare_data:/prepare_data
command: -c "/usr/bin/tail -f /dev/null"
environment:
Expand Down
12 changes: 6 additions & 6 deletions br/compatibility/prepare_backup.sh
Expand Up @@ -16,7 +16,7 @@

set -eux

. compatibility/get_last_tags.sh
. br/compatibility/get_last_tags.sh

TAGS="v5.0.0"
getLatestTags
Expand All @@ -27,14 +27,14 @@ i=0
runBackup() {
# generate backup data in /tmp/br/docker/backup_data/$TAG/, we can do restore after all data backuped later.
echo "build $1 cluster"
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml build
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml up -d
trap "TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml down" EXIT
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f br/compatibility/backup_cluster.yaml build
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f br/compatibility/backup_cluster.yaml up -d
trap "TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f br/compatibility/backup_cluster.yaml down" EXIT
# wait for cluster ready
sleep 20
# prepare SQL data
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml exec -T control /go/bin/go-ycsb load mysql -P /prepare_data/workload -p mysql.host=tidb -p mysql.port=4000 -p mysql.user=root -p mysql.db=test
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f compatibility/backup_cluster.yaml exec -T control make compatibility_test_prepare
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f br/compatibility/backup_cluster.yaml exec -T control /go/bin/go-ycsb load mysql -P /prepare_data/workload -p mysql.host=tidb -p mysql.port=4000 -p mysql.user=root -p mysql.db=test
TAG=$1 PORT_SUFFIX=$2 docker-compose -p $1 -f br/compatibility/backup_cluster.yaml exec -T control br/tests/run_compatible.sh prepare
}

for tag in $TAGS; do
Expand Down
2 changes: 1 addition & 1 deletion br/docker/Dockerfile
@@ -1,7 +1,7 @@
# For loading data to TiDB
FROM golang:1.16.4-buster as go-ycsb-builder
WORKDIR /go/src/github.com/pingcap/
RUN git clone https://github.com/pingcap/go-ycsb.git && \
RUN git clone https://github.com/pingcap/go-ycsb.git --depth=1 && \
cd go-ycsb && \
make

Expand Down
7 changes: 4 additions & 3 deletions br/tests/docker_compatible_gcs/run.sh
Expand Up @@ -31,15 +31,16 @@ EOF
)

# save CREDENTIALS to file
echo $KEY > "tests/$TEST_NAME/config.json"
echo $KEY > "br/tests/$TEST_NAME/config.json"

# export test CREDENTIALS for gcs oauth
export GOOGLE_APPLICATION_CREDENTIALS="tests/$TEST_NAME/config.json"
export GOOGLE_APPLICATION_CREDENTIALS="br/tests/$TEST_NAME/config.json"

# restore backup data one by one
for TAG in ${TAGS}; do
echo "restore ${TAG} data starts..."
bin/br restore db --db test -s "gcs://$BUCKET/bk${TAG}" --pd $PD_ADDR --gcs.endpoint="http://$GCS_HOST:$GCS_PORT/storage/v1/"
# after BR merged into TiDB we need skip version check because the build from tidb is not a release version.
bin/br restore db --db test -s "gcs://$BUCKET/bk${TAG}" --pd $PD_ADDR --gcs.endpoint="http://$GCS_HOST:$GCS_PORT/storage/v1/" --check-requirements=false
row_count=$(run_sql_in_container "SELECT COUNT(*) FROM test.usertable;" | awk '/COUNT/{print $2}')
if [ $row_count != $EXPECTED_KVS ]; then
echo "restore kv count is not as expected(1000) $row_count"
Expand Down
3 changes: 2 additions & 1 deletion br/tests/docker_compatible_s3/run.sh
Expand Up @@ -26,7 +26,8 @@ S3_KEY="&access-key=$MINIO_ACCESS_KEY&secret-access-key=$MINIO_SECRET_KEY"
# restore backup data one by one
for TAG in ${TAGS}; do
echo "restore ${TAG} data starts..."
bin/br restore db --db test -s "s3://$BUCKET/bk${TAG}?endpoint=http://$S3_ENDPOINT$S3_KEY" --pd $PD_ADDR
# after BR merged into TiDB we need skip version check because the build from tidb is not a release version.
bin/br restore db --db test -s "s3://$BUCKET/bk${TAG}?endpoint=http://$S3_ENDPOINT$S3_KEY" --pd $PD_ADDR --check-requirements=false
row_count=$(run_sql_in_container "SELECT COUNT(*) FROM test.usertable;" | awk '/COUNT/{print $2}')
if [ $row_count != $EXPECTED_KVS ]; then
echo "restore kv count is not as expected(1000), obtain $row_count"
Expand Down
4 changes: 2 additions & 2 deletions br/tests/run_compatible.sh
Expand Up @@ -32,15 +32,15 @@ TEST_DIR=/tmp/backup_restore_compatibility_test
mkdir -p "$TEST_DIR"
rm -f "$TEST_DIR"/*.log &> /dev/null

for script in tests/docker_compatible_*/${1}.sh; do
for script in br/tests/docker_compatible_*/${1}.sh; do
echo "*===== Running test $script... =====*"
TEST_DIR="$TEST_DIR" \
PD_ADDR="$PD_ADDR" \
GCS_HOST="$GCS_HOST" \
GCS_PORT="$GCS_PORT" \
TAGS="$TAGS" \
EXPECTED_KVS="$EXPECTED_KVS" \
PATH="tests/_utils:bin:$PATH" \
PATH="br/tests/_utils:bin:$PATH" \
TEST_NAME="$(basename "$(dirname "$script")")" \
BR_LOG_TO_TERM=1 \
bash "$script"
Expand Down
18 changes: 7 additions & 11 deletions go.mod
Expand Up @@ -3,8 +3,7 @@ module github.com/pingcap/tidb
go 1.16

require (
cloud.google.com/go v0.54.0 // indirect
cloud.google.com/go/storage v1.6.0
cloud.google.com/go/storage v1.16.1-0.20210826124857-08169baa564d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps you need to keep the comment about the failing br_gcs test, until googleapis/google-cloud-go#4609 is released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.16.1 released

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.com/BurntSushi/toml v0.3.1
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/HdrHistogram/hdrhistogram-go v1.1.0 // indirect
Expand All @@ -30,8 +29,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.3
github.com/google/btree v1.0.0
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1
github.com/google/uuid v1.1.2
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0
Expand Down Expand Up @@ -76,26 +74,24 @@ require (
github.com/xitongsys/parquet-go v1.5.5-0.20201110004701-b09c49d6d457
github.com/xitongsys/parquet-go-source v0.0.0-20200817004010-026bad9b25d0
go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b
go.opencensus.io v0.22.5 // indirect
go.uber.org/atomic v1.9.0
go.uber.org/automaxprocs v1.4.0
go.uber.org/goleak v1.1.10
go.uber.org/multierr v1.7.0
go.uber.org/zap v1.19.0
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069
golang.org/x/text v0.3.7
golang.org/x/tools v0.1.5
google.golang.org/api v0.22.0
google.golang.org/grpc v1.29.1
google.golang.org/api v0.54.0
google.golang.org/grpc v1.40.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0
modernc.org/mathutil v1.2.2
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
)

// FIXME the official repo has some bug makes br_gcs test failed. https://github.com/googleapis/google-cloud-go/pull/3509
// replace cloud.google.com/go/storage => github.com/3pointer/google-cloud-go/storage v1.6.1-0.20210108125931-b59bfa0720b2
replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
kennytm marked this conversation as resolved.
Show resolved Hide resolved