Skip to content

Commit

Permalink
Merge branch 'master' into collect-predicate-column
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyifangreeneyes authored Dec 10, 2021
2 parents 22202c3 + 03b6a8e commit 9e615b2
Show file tree
Hide file tree
Showing 168 changed files with 19,194 additions and 20,072 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/dumpling_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ concurrency:
cancel-in-progress: true

jobs:
unit-test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Unit test
run: make dumpling_unit_test WITH_RACE=1
- uses: codecov/codecov-action@v1

integration-test-mysql-5735:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ coverage.txt
var
fix.sql
export-20*/
*-coverage.xml
*-junit-report.xml
56 changes: 47 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ explaintest: server_check
ddltest:
@cd cmd/ddltest && $(GO) test -o ../../bin/ddltest -c

upload-coverage:
ifneq ($(CODECOV_TOKEN), "")
curl -LO ${FILE_SERVER_URL}/download/cicd/ci-tools/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
endif

devgotest: failpoint-enable
# grep regex: Filter out all tidb logs starting with:
# - '[20' (like [2021/09/15 ...] [INFO]..)
Expand All @@ -132,9 +125,29 @@ gotest: failpoint-enable
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -cover $(PACKAGES_TIDB_TESTS) -coverprofile=coverage.txt -check.p true > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
@$(FAILPOINT_DISABLE)

gotest_in_verify_ci_part_1: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
@echo "Running gotest_in_verify_ci_part_1."
@mkdir -p $(TEST_COVERAGE_DIR)
@export log_level=info; export TZ='Asia/Shanghai'; \
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/tidb-junit-report.xml" -- -v -p $(P) --race \
-ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" \
$(PACKAGES_TIDB_TESTS_EXPENSIVE) -check.p true || { $(FAILPOINT_DISABLE); exit 1; }
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/tidb-coverage.xml"
@$(FAILPOINT_DISABLE)

gotest_in_verify_ci_part_2: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
@echo "Running gotest_in_verify_ci_part_2."
@mkdir -p $(TEST_COVERAGE_DIR)
@export log_level=info; export TZ='Asia/Shanghai'; \
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/tidb-junit-report.xml" -- -v -p $(P) --race \
-ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" \
$(PACKAGES_TIDB_TESTS_OTHERS) -check.p true || { $(FAILPOINT_DISABLE); exit 1; }
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/tidb-coverage.xml"
@$(FAILPOINT_DISABLE)

race: failpoint-enable
@export log_level=debug; \
$(GOTEST) -timeout 20m -race $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
$(GOTEST) -timeout 25m -race $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

leak: failpoint-enable
Expand Down Expand Up @@ -310,7 +323,16 @@ br_unit_test: export ARGS=$$($(BR_PACKAGES))
br_unit_test:
@make failpoint-enable
@export TZ='Asia/Shanghai';
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' -tags leak $(ARGS) || ( make failpoint-disable && exit 1 )
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' -tags leak $(ARGS) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
@make failpoint-disable
br_unit_test_in_verify_ci: export ARGS=$$($(BR_PACKAGES))
br_unit_test_in_verify_ci: tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
@make failpoint-enable
@export TZ='Asia/Shanghai';
@mkdir -p $(TEST_COVERAGE_DIR)
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/br-junit-report.xml" -- $(RACE_FLAG) -ldflags '$(LDFLAGS)' \
-tags leak $(ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/br-coverage.xml"
@make failpoint-disable

br_integration_test: br_bins build_br build_for_br_integration_test
Expand Down Expand Up @@ -369,6 +391,13 @@ dumpling_unit_test: export DUMPLING_ARGS=$$($(DUMPLING_PACKAGES))
dumpling_unit_test: failpoint-enable
$(DUMPLING_GOTEST) $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic -tags leak $(DUMPLING_ARGS) || ( make failpoint-disable && exit 1 )
@make failpoint-disable
dumpling_unit_test_in_verify_ci: export DUMPLING_ARGS=$$($(DUMPLING_PACKAGES))
dumpling_unit_test_in_verify_ci: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
@mkdir -p $(TEST_COVERAGE_DIR)
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- -tags leak $(DUMPLING_ARGS) \
$(RACE_FLAG) -coverprofile="$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/dumpling-coverage.xml"
@make failpoint-disable

dumpling_integration_test: dumpling_bins failpoint-enable build_dumpling
@make failpoint-disable
Expand All @@ -388,3 +417,12 @@ dumpling_bins:
@which bin/minio
@which bin/tidb-lightning
@which bin/sync_diff_inspector

tools/bin/gotestsum: tools/check/go.mod
cd tools/check && $(GO) build -o ../bin/gotestsum gotest.tools/gotestsum

tools/bin/gocov: tools/check/go.mod
cd tools/check && $(GO) build -o ../bin/gocov github.com/axw/gocov/gocov

tools/bin/gocov-xml: tools/check/go.mod
cd tools/check && $(GO) build -o ../bin/gocov-xml github.com/AlekSi/gocov-xml
5 changes: 5 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ MAC := "Darwin"

PACKAGE_LIST := go list ./...
PACKAGE_LIST_TIDB_TESTS := go list ./... | grep -vE "github.com\/pingcap\/tidb\/br|github.com\/pingcap\/tidb\/cmd|github.com\/pingcap\/tidb\/dumpling"
PACKAGE_LIST_TEST_OTHERS := go list ./... | grep -vE "github.com\/pingcap\/tidb\/br|github.com\/pingcap\/tidb\/cmd|github.com\/pingcap\/tidb\/dumpling|github.com\/pingcap\/tidb\/executor|github.com\/pingcap\/tidb\/cmd|github.com\/pingcap\/tidb\/ddl"
PACKAGES ?= $$($(PACKAGE_LIST))
PACKAGES_TIDB_TESTS ?= $$($(PACKAGE_LIST_TIDB_TESTS))
PACKAGES_TIDB_TESTS_EXPENSIVE ?= "github.com/pingcap/tidb/executor" "github.com/pingcap/tidb/ddl"
PACKAGES_TIDB_TESTS_OTHERS ?= $$($(PACKAGE_LIST_TEST_OTHERS))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/$(PROJECT)/||'
PACKAGE_DIRECTORIES_TIDB_TESTS := $(PACKAGE_LIST_TIDB_TESTS) | sed 's|github.com/pingcap/$(PROJECT)/||'
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
Expand Down Expand Up @@ -111,3 +114,5 @@ DUMPLING_LDFLAGS += -X "github.com/pingcap/tidb/dumpling/cli.GoVersion=$(shell g

DUMPLING_GOBUILD := CGO_ENABLED=0 GO111MODULE=on go build -trimpath -ldflags '$(DUMPLING_LDFLAGS)'
DUMPLING_GOTEST := CGO_ENABLED=1 GO111MODULE=on go test -ldflags '$(DUMPLING_LDFLAGS)'

TEST_COVERAGE_DIR := "test_coverage"
35 changes: 0 additions & 35 deletions br/cmd/br/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,6 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error {
return nil
}

func runLogRestoreCommand(command *cobra.Command) error {
cfg := task.LogRestoreConfig{Config: task.Config{LogProgress: HasLogFile()}}
if err := cfg.ParseFromFlags(command.Flags()); err != nil {
command.SilenceUsage = false
return errors.Trace(err)
}

ctx := GetDefaultContext()
if cfg.EnableOpenTracing {
var store *appdash.MemoryStore
ctx, store = trace.TracerStartSpan(ctx)
defer trace.TracerFinishSpan(ctx, store)
}
if err := task.RunLogRestore(GetDefaultContext(), tidbGlue, &cfg); err != nil {
log.Error("failed to restore", zap.Error(err))
return errors.Trace(err)
}
return nil
}

func runRestoreRawCommand(command *cobra.Command, cmdName string) error {
cfg := task.RestoreRawConfig{
RawKvConfig: task.RawKvConfig{Config: task.Config{LogProgress: HasLogFile()}},
Expand Down Expand Up @@ -102,7 +82,6 @@ func NewRestoreCommand() *cobra.Command {
newFullRestoreCommand(),
newDBRestoreCommand(),
newTableRestoreCommand(),
newLogRestoreCommand(),
newRawRestoreCommand(),
)
task.DefineRestoreFlags(command.PersistentFlags())
Expand Down Expand Up @@ -149,20 +128,6 @@ func newTableRestoreCommand() *cobra.Command {
return command
}

func newLogRestoreCommand() *cobra.Command {
command := &cobra.Command{
Use: "cdclog",
Short: "(experimental) restore data from cdc log backup",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
return runLogRestoreCommand(cmd)
},
}
task.DefineFilterFlags(command, filterOutSysAndMemTables)
task.DefineLogRestoreFlags(command)
return command
}

func newRawRestoreCommand() *cobra.Command {
command := &cobra.Command{
Use: "raw",
Expand Down
Loading

0 comments on commit 9e615b2

Please sign in to comment.