Skip to content

Commit a05e8f2

Browse files
authored
Merge branch 'master' into instance-scope-proposal
2 parents e54cff3 + dc969f0 commit a05e8f2

File tree

1,138 files changed

+61341
-39379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,138 files changed

+61341
-39379
lines changed

.codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ ignore:
4343
- "executor/seqtest/.*"
4444
- "metrics/.*"
4545
- "expression/generator/.*"
46+
- "br/pkg/mock/.*"
4647

.github/pull_request_template.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ PR Title Format:
99
-->
1010

1111
### What problem does this PR solve?
12+
<!--
13+
14+
Please create an issue first to describe the problem.
15+
16+
There MUST be one line starting with "Issue Number: " and
17+
linking the relevant issues via the "close" or "ref".
18+
19+
For more info, check https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/contribute-code.html#referring-to-an-issue.
20+
21+
-->
1222

1323
Issue Number: close #xxx
1424

.github/workflows/dumpling_integration_test.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,6 @@ concurrency:
3333
cancel-in-progress: true
3434

3535
jobs:
36-
unit-test:
37-
runs-on: ubuntu-latest
38-
timeout-minutes: 15
39-
strategy:
40-
fail-fast: true
41-
steps:
42-
- uses: actions/checkout@v2
43-
with:
44-
fetch-depth: 2
45-
- name: Set up Go 1.16
46-
uses: actions/setup-go@v2
47-
with:
48-
go-version: 1.16
49-
- name: Unit test
50-
run: make dumpling_unit_test WITH_RACE=1
51-
- uses: codecov/codecov-action@v1
52-
5336
integration-test-mysql-5735:
5437
runs-on: ubuntu-latest
5538
timeout-minutes: 15

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ coverage.out
66
*.iml
77
*.swp
88
*.log
9+
*.test.bin
910
tags
1011
profile.coverprofile
1112
explain_test

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
timeout: 7m
2+
timeout: 10m
33
linters:
44
disable-all: true
55
enable:
@@ -22,6 +22,8 @@ linters:
2222
- rowserrcheck
2323
- unconvert
2424
- makezero
25+
- durationcheck
26+
- prealloc
2527

2628
linters-settings:
2729
staticcheck:

.golangci_br.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

Makefile

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dev: checklist check explaintest devgotest gogenerate br_unit_test test_part_par
3434
# Install the check tools.
3535
check-setup:tools/bin/revive tools/bin/goword
3636

37-
check: fmt unconvert lint tidy testSuite check-static vet errdoc
37+
check: fmt check-parallel unconvert lint tidy testSuite check-static vet errdoc
3838

3939
fmt:
4040
@echo "gofmt (simplify)"
@@ -45,7 +45,6 @@ goword:tools/bin/goword
4545

4646
check-static: tools/bin/golangci-lint
4747
GO111MODULE=on CGO_ENABLED=0 tools/bin/golangci-lint run -v $$($(PACKAGE_DIRECTORIES_TIDB_TESTS)) --config .golangci.yml
48-
GO111MODULE=on CGO_ENABLED=0 tools/bin/golangci-lint run -v $$($(BR_PACKAGE_DIRECTORIES)) --config .golangci_br.yml
4948

5049
unconvert:tools/bin/unconvert
5150
@echo "unconvert check(skip check the genenrated or copied code in lightning)"
@@ -65,7 +64,7 @@ lint:tools/bin/revive
6564

6665
vet:
6766
@echo "vet"
68-
$(GO) vet -all $(PACKAGES_TIDB_TESTS) 2>&1 | $(FAIL_ON_STDOUT)
67+
$(GO) vet -all $(PACKAGES_TIDB_TESTS_WITHOUT_BR) 2>&1 | $(FAIL_ON_STDOUT)
6968

7069
tidy:
7170
@echo "go mod tidy"
@@ -75,6 +74,13 @@ testSuite:
7574
@echo "testSuite"
7675
./tools/check/check_testSuite.sh
7776

77+
check-parallel:
78+
# Make sure no tests are run in parallel to prevent possible unstable tests.
79+
# See https://github.com/pingcap/tidb/pull/30692.
80+
@! find . -name "*_test.go" -not -path "./vendor/*" -print0 | \
81+
xargs -0 grep -F -n "t.Parallel()" || \
82+
! echo "Error: all the go tests should be run in serial."
83+
7884
clean: failpoint-disable
7985
$(GO) clean -i ./...
8086

@@ -116,38 +122,31 @@ devgotest: failpoint-enable
116122
# - 'ok ' to ignore passed directories
117123
@echo "Running in native mode."
118124
@export log_level=info; export TZ='Asia/Shanghai'; \
119-
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -cover $(PACKAGES_TIDB_TESTS) -check.p true > gotest.log || { $(FAILPOINT_DISABLE); grep -v '^\([[]20\|PASS:\|ok \)' 'gotest.log'; exit 1; }
125+
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -cover $(PACKAGES_TIDB_TESTS_WITHOUT_BR) -check.p true > gotest.log || { $(FAILPOINT_DISABLE); grep -v '^\([[]20\|PASS:\|ok \)' 'gotest.log'; exit 1; }
126+
@$(FAILPOINT_DISABLE)
127+
128+
ut: failpoint-enable tools/bin/ut
129+
tools/bin/ut $(X);
120130
@$(FAILPOINT_DISABLE)
121131

122132
gotest: failpoint-enable
123133
@echo "Running in native mode."
124134
@export log_level=info; export TZ='Asia/Shanghai'; \
125-
$(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; }
135+
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -timeout 20m -cover $(PACKAGES_TIDB_TESTS_WITHOUT_BR) -coverprofile=coverage.txt -check.p true > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
126136
@$(FAILPOINT_DISABLE)
127137

128-
gotest_in_verify_ci_part_1: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
129-
@echo "Running gotest_in_verify_ci_part_1."
138+
gotest_in_verify_ci: failpoint-enable tools/bin/gotestsum
139+
@echo "Running gotest_in_verify_ci"
130140
@mkdir -p $(TEST_COVERAGE_DIR)
131-
@export log_level=info; export TZ='Asia/Shanghai'; \
132-
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/tidb-junit-report.xml" -- -v -p $(P) --race \
141+
@export TZ='Asia/Shanghai'; \
142+
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/tidb-junit-report.xml" -- -v -p $(P) \
133143
-ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" \
134-
$(PACKAGES_TIDB_TESTS_EXPENSIVE) -check.p true || { $(FAILPOINT_DISABLE); exit 1; }
135-
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/tidb-coverage.xml"
136-
@$(FAILPOINT_DISABLE)
137-
138-
gotest_in_verify_ci_part_2: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
139-
@echo "Running gotest_in_verify_ci_part_2."
140-
@mkdir -p $(TEST_COVERAGE_DIR)
141-
@export log_level=info; export TZ='Asia/Shanghai'; \
142-
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/tidb-junit-report.xml" -- -v -p $(P) --race \
143-
-ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" \
144-
$(PACKAGES_TIDB_TESTS_OTHERS) -check.p true || { $(FAILPOINT_DISABLE); exit 1; }
145-
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/tidb_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/tidb-coverage.xml"
144+
$(PACKAGES_TIDB_TESTS_WITHOUT_BR) -check.p true || { $(FAILPOINT_DISABLE); exit 1; }
146145
@$(FAILPOINT_DISABLE)
147146

148147
race: failpoint-enable
149148
@export log_level=debug; \
150-
$(GOTEST) -timeout 20m -race $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
149+
$(GOTEST) -timeout 25m -race $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
151150
@$(FAILPOINT_DISABLE)
152151

153152
leak: failpoint-enable
@@ -213,6 +212,10 @@ failpoint-disable: tools/bin/failpoint-ctl
213212
# Restoring gofail failpoints...
214213
@$(FAILPOINT_DISABLE)
215214

215+
tools/bin/ut: tools/check/ut.go
216+
cd tools/check; \
217+
$(GO) build -o ../bin/ut ut.go
218+
216219
tools/bin/megacheck: tools/check/go.mod
217220
cd tools/check; \
218221
$(GO) build -o ../bin/megacheck honnef.co/go/tools/cmd/megacheck
@@ -326,13 +329,12 @@ br_unit_test:
326329
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' -tags leak $(ARGS) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
327330
@make failpoint-disable
328331
br_unit_test_in_verify_ci: export ARGS=$$($(BR_PACKAGES))
329-
br_unit_test_in_verify_ci: tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
332+
br_unit_test_in_verify_ci: tools/bin/gotestsum
330333
@make failpoint-enable
331334
@export TZ='Asia/Shanghai';
332335
@mkdir -p $(TEST_COVERAGE_DIR)
333336
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/br-junit-report.xml" -- $(RACE_FLAG) -ldflags '$(LDFLAGS)' \
334337
-tags leak $(ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
335-
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/br-coverage.xml"
336338
@make failpoint-disable
337339

338340
br_integration_test: br_bins build_br build_for_br_integration_test
@@ -392,11 +394,10 @@ dumpling_unit_test: failpoint-enable
392394
$(DUMPLING_GOTEST) $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic -tags leak $(DUMPLING_ARGS) || ( make failpoint-disable && exit 1 )
393395
@make failpoint-disable
394396
dumpling_unit_test_in_verify_ci: export DUMPLING_ARGS=$$($(DUMPLING_PACKAGES))
395-
dumpling_unit_test_in_verify_ci: failpoint-enable tools/bin/gotestsum tools/bin/gocov tools/bin/gocov-xml
397+
dumpling_unit_test_in_verify_ci: failpoint-enable tools/bin/gotestsum
396398
@mkdir -p $(TEST_COVERAGE_DIR)
397399
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- -tags leak $(DUMPLING_ARGS) \
398400
$(RACE_FLAG) -coverprofile="$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
399-
tools/bin/gocov convert "$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" | tools/bin/gocov-xml > "$(TEST_COVERAGE_DIR)/dumpling-coverage.xml"
400401
@make failpoint-disable
401402

402403
dumpling_integration_test: dumpling_bins failpoint-enable build_dumpling
@@ -420,9 +421,3 @@ dumpling_bins:
420421

421422
tools/bin/gotestsum: tools/check/go.mod
422423
cd tools/check && $(GO) build -o ../bin/gotestsum gotest.tools/gotestsum
423-
424-
tools/bin/gocov: tools/check/go.mod
425-
cd tools/check && $(GO) build -o ../bin/gocov github.com/axw/gocov/gocov
426-
427-
tools/bin/gocov-xml: tools/check/go.mod
428-
cd tools/check && $(GO) build -o ../bin/gocov-xml github.com/AlekSi/gocov-xml

Makefile.common

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ LINUX := "Linux"
4646
MAC := "Darwin"
4747

4848
PACKAGE_LIST := go list ./...
49-
PACKAGE_LIST_TIDB_TESTS := go list ./... | grep -vE "github.com\/pingcap\/tidb\/br|github.com\/pingcap\/tidb\/cmd|github.com\/pingcap\/tidb\/dumpling"
50-
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"
49+
PACKAGE_LIST_TIDB_TESTS := go list ./... | grep -vE "github.com\/pingcap\/tidb\/cmd|github.com\/pingcap\/tidb\/dumpling"
5150
PACKAGES ?= $$($(PACKAGE_LIST))
5251
PACKAGES_TIDB_TESTS ?= $$($(PACKAGE_LIST_TIDB_TESTS))
53-
PACKAGES_TIDB_TESTS_EXPENSIVE ?= "github.com/pingcap/tidb/executor" "github.com/pingcap/tidb/ddl"
54-
PACKAGES_TIDB_TESTS_OTHERS ?= $$($(PACKAGE_LIST_TEST_OTHERS))
52+
PACKAGES_TIDB_TESTS_WITHOUT_BR ?= $$($(PACKAGE_LIST_TIDB_TESTS) | grep -v "br")
5553
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/$(PROJECT)/||'
5654
PACKAGE_DIRECTORIES_TIDB_TESTS := $(PACKAGE_LIST_TIDB_TESTS) | sed 's|github.com/pingcap/$(PROJECT)/||'
55+
PACKAGE_DIRECTORIES_TIDB_TESTS_WITHOUT_BR := $(PACKAGE_LIST_TIDB_TESTS) | sed 's|github.com/pingcap/$(PROJECT)/||' | grep -v "br"
5756
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
58-
FILES_TIDB_TESTS := $$(find $$($(PACKAGE_DIRECTORIES_TIDB_TESTS)) -name "*.go")
57+
FILES_TIDB_TESTS := $$(find $$($(PACKAGE_DIRECTORIES_TIDB_TESTS_WITHOUT_BR)) -name "*.go")
5958

6059
UNCONVERT_PACKAGES_LIST := go list ./...| grep -vE "lightning\/checkpoints|lightning\/manual|lightning\/common"
6160
UNCONVERT_PACKAGES := $$($(UNCONVERT_PACKAGES_LIST))

0 commit comments

Comments
 (0)