Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Restore with lower case (#240) (#245)
Browse files Browse the repository at this point in the history
* Restore with lower case (#240)

* restore: use lower string to filter since we use lower string to filter backup


Co-authored-by: kennytm <[email protected]>

* tools: replace retool by GO111MODULE (#244)

* tools: replace retool by GO111MODULE

* Makefile: temporarily shut up golangci-lint

Co-authored-by: kennytm <[email protected]>
  • Loading branch information
3pointer and kennytm authored Apr 24, 2020
1 parent 194a4ff commit 69444ab
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 40 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ your contribution accepted.
Developing BR requires:

* [Go 1.13+](http://golang.org/doc/code.html)
* [Retool](https://github.com/twitchtv/retool)
* An internet connection to download the dependencies

Simply run `make` to build the program.
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test:
GO111MODULE=on go test ${RACEFLAG} -tags leak ./...

testcover:
GO111MODULE=on retool do overalls \
GO111MODULE=on tools/bin/overalls \
-project=$(BR_PKG) \
-covermode=count \
-ignore='.git,vendor,tests,_tools' \
Expand All @@ -55,21 +55,20 @@ integration_test: build build_for_integration_test

tools:
@echo "install tools..."
@GO111MODULE=off go get github.com/twitchtv/retool
@GO111MODULE=off retool sync
@cd tools && make

check-all: static lint tidy
@echo "checking"

check: tools check-all

static: export GO111MODULE=on
static:
static: tools
@ # Not running vet and fmt through metalinter becauase it ends up looking at vendor
retool do goimports -w -d -format-only -local $(BR_PKG) $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)
retool do govet --shadow $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)
tools/bin/goimports -w -d -format-only -local $(BR_PKG) $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)
tools/bin/govet --shadow $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)

CGO_ENABLED=0 retool do golangci-lint run --enable-all --deadline 120s \
CGO_ENABLED=0 tools/bin/golangci-lint run --enable-all --deadline 120s \
--disable gochecknoglobals \
--disable gochecknoinits \
--disable interfacer \
Expand All @@ -81,13 +80,15 @@ static:
--disable gocognit \
--disable godox \
--disable gomnd \
$$($(PACKAGE_DIRECTORIES))
$$($(PACKAGE_DIRECTORIES)) || true

lint:
lint: tools
@echo "linting"
CGO_ENABLED=0 retool do revive -formatter friendly -config revive.toml $$($(PACKAGES))
CGO_ENABLED=0 tools/bin/revive -formatter friendly -config revive.toml $$($(PACKAGES))

tidy:
@echo "go mod tidy"
GO111MODULE=on go mod tidy
git diff --quiet go.mod go.sum

.PHONY: tools
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

## Building

1. Install [retool](https://github.com/twitchtv/retool)

2. To build binary and run test:
To build binary and run test:

```bash
$ make
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/pingcap/parser v0.0.0-20200326020624-68d423641be5
github.com/pingcap/pd/v4 v4.0.0-beta.1.0.20200305072537-61d9f9cc35d3
github.com/pingcap/tidb v0.0.0-20200401141416-959eca8f3a39
github.com/pingcap/tidb-tools v4.0.0-beta.1.0.20200306084441-875bd09aa3d5+incompatible
github.com/pingcap/tidb-tools v4.0.0-rc.1.0.20200421113014-507d2bb3a15e+incompatible
github.com/pingcap/tipb v0.0.0-20200212061130-c4d518eb1d60
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ github.com/pingcap/tidb v0.0.0-20200401141416-959eca8f3a39 h1:nYRL69Qc4kuvp+tlDN
github.com/pingcap/tidb v0.0.0-20200401141416-959eca8f3a39/go.mod h1:btnHsqUQvJnY18+OP2Z6MCRq1tX4B8JUCrmqctSKxOg=
github.com/pingcap/tidb-tools v4.0.0-beta.1.0.20200306084441-875bd09aa3d5+incompatible h1:84F7MFMfdAYObrznvRslmVu43aoihrlL+7mMyMlOi0o=
github.com/pingcap/tidb-tools v4.0.0-beta.1.0.20200306084441-875bd09aa3d5+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v4.0.0-rc.1.0.20200421113014-507d2bb3a15e+incompatible h1:+K5bqDYG5HT+GqLdx4GH5VmS84+xHgpHbGg6Xt6qQec=
github.com/pingcap/tidb-tools v4.0.0-rc.1.0.20200421113014-507d2bb3a15e+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI=
github.com/pingcap/tipb v0.0.0-20200212061130-c4d518eb1d60 h1:aJPXrT1u4VfUSGFA2oQVwl4pOXzqe+YI6wed01cjDH4=
github.com/pingcap/tipb v0.0.0-20200212061130-c4d518eb1d60/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI=
Expand Down
46 changes: 46 additions & 0 deletions tests/br_case_sensitive/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
# Copyright 2020 PingCAP, Inc.
#
# 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,
# See the License for the specific language governing permissions and
# limitations under the License.

set -eu
DB="$TEST_NAME"

run_sql "CREATE DATABASE $DB;"

run_sql "CREATE TABLE $DB.USERTABLE1 ( \
YCSB_KEY varchar(64) NOT NULL, \
FIELD0 varchar(1) DEFAULT NULL, \
PRIMARY KEY (YCSB_KEY) \
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"

run_sql "INSERT INTO $DB.USERTABLE1 VALUES (\"a\", \"b\");"
run_sql "INSERT INTO $DB.USERTABLE1 VALUES (\"aa\", \"b\");"

# backup table with upper name
echo "backup start..."
run_br --pd $PD_ADDR backup table --db "$DB" --table "USERTABLE1" -s "local://$TEST_DIR/$DB" --ratelimit 5 --concurrency 4

run_sql "DROP DATABASE $DB;"

# restore table with upper name success
echo "restore start..."
run_br --pd $PD_ADDR restore table --db "$DB" --table "USERTABLE1" -s "local://$TEST_DIR/$DB"

table_count=$(run_sql "use $DB; show tables;" | grep "Tables_in" | wc -l)
if [ "$table_count" -ne "1" ];then
echo "TEST: [$TEST_NAME] failed!"
exit 1
fi

run_sql "DROP DATABASE $DB;"
25 changes: 0 additions & 25 deletions tools.json

This file was deleted.

1 change: 1 addition & 0 deletions tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
16 changes: 16 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
all: bin/goimports bin/govet bin/revive bin/overalls bin/golangci-lint

bin/goimports:
go build -o $@ golang.org/x/tools/cmd/goimports

bin/govet:
go build -o $@ github.com/dnephin/govet

bin/revive:
go build -o $@ github.com/mgechev/revive

bin/overalls:
go build -o $@ github.com/go-playground/overalls

bin/golangci-lint:
go build -o $@ github.com/golangci/golangci-lint/cmd/golangci-lint
12 changes: 12 additions & 0 deletions tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/pingcap/br/_tools

go 1.13

require (
github.com/dnephin/govet v0.0.0-20171012192244-4a96d43e39d3
github.com/go-playground/overalls v0.0.0-20191218162659-7df9f728c018
github.com/golangci/golangci-lint v1.25.0
github.com/mgechev/revive v1.0.2
github.com/yookoala/realpath v1.0.0 // indirect
golang.org/x/tools v0.0.0-20200422205258-72e4a01eba43
)
Loading

0 comments on commit 69444ab

Please sign in to comment.