@@ -34,7 +34,7 @@ dev: checklist check explaintest devgotest gogenerate br_unit_test test_part_par
34
34
# Install the check tools.
35
35
check-setup :tools/bin/revive tools/bin/goword
36
36
37
- check : fmt unconvert lint tidy testSuite check-static vet errdoc
37
+ check : fmt check-parallel unconvert lint tidy testSuite check-static vet errdoc
38
38
39
39
fmt :
40
40
@echo " gofmt (simplify)"
@@ -45,7 +45,6 @@ goword:tools/bin/goword
45
45
46
46
check-static : tools/bin/golangci-lint
47
47
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
49
48
50
49
unconvert :tools/bin/unconvert
51
50
@echo " unconvert check(skip check the genenrated or copied code in lightning)"
@@ -65,7 +64,7 @@ lint:tools/bin/revive
65
64
66
65
vet :
67
66
@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 )
69
68
70
69
tidy :
71
70
@echo " go mod tidy"
@@ -75,6 +74,13 @@ testSuite:
75
74
@echo " testSuite"
76
75
./tools/check/check_testSuite.sh
77
76
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
+
78
84
clean : failpoint-disable
79
85
$(GO ) clean -i ./...
80
86
@@ -116,38 +122,31 @@ devgotest: failpoint-enable
116
122
# - 'ok ' to ignore passed directories
117
123
@echo "Running in native mode."
118
124
@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 ) ;
120
130
@$(FAILPOINT_DISABLE )
121
131
122
132
gotest : failpoint-enable
123
133
@echo " Running in native mode."
124
134
@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; }
126
136
@$(FAILPOINT_DISABLE )
127
137
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 "
130
140
@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 ) \
133
143
-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; }
146
145
@$(FAILPOINT_DISABLE )
147
146
148
147
race : failpoint-enable
149
148
@export log_level=debug; \
150
- $(GOTEST ) -timeout 20m -race $(PACKAGES ) || { $( FAILPOINT_DISABLE) ; exit 1; }
149
+ $(GOTEST ) -timeout 25m -race $(PACKAGES ) || { $( FAILPOINT_DISABLE) ; exit 1; }
151
150
@$(FAILPOINT_DISABLE )
152
151
153
152
leak : failpoint-enable
@@ -213,6 +212,10 @@ failpoint-disable: tools/bin/failpoint-ctl
213
212
# Restoring gofail failpoints...
214
213
@$(FAILPOINT_DISABLE)
215
214
215
+ tools/bin/ut : tools/check/ut.go
216
+ cd tools/check; \
217
+ $(GO ) build -o ../bin/ut ut.go
218
+
216
219
tools/bin/megacheck : tools/check/go.mod
217
220
cd tools/check; \
218
221
$(GO ) build -o ../bin/megacheck honnef.co/go/tools/cmd/megacheck
@@ -326,13 +329,12 @@ br_unit_test:
326
329
$(GOTEST ) $(RACE_FLAG ) -ldflags ' $(LDFLAGS)' -tags leak $(ARGS ) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
327
330
@make failpoint-disable
328
331
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
330
333
@make failpoint-enable
331
334
@export TZ=' Asia/Shanghai' ;
332
335
@mkdir -p $(TEST_COVERAGE_DIR )
333
336
CGO_ENABLED=1 tools/bin/gotestsum --junitfile " $( TEST_COVERAGE_DIR) /br-junit-report.xml" -- $(RACE_FLAG ) -ldflags ' $(LDFLAGS)' \
334
337
-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"
336
338
@make failpoint-disable
337
339
338
340
br_integration_test : br_bins build_br build_for_br_integration_test
@@ -392,11 +394,10 @@ dumpling_unit_test: failpoint-enable
392
394
$(DUMPLING_GOTEST ) $(RACE_FLAG ) -coverprofile=coverage.txt -covermode=atomic -tags leak $(DUMPLING_ARGS ) || ( make failpoint-disable && exit 1 )
393
395
@make failpoint-disable
394
396
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
396
398
@mkdir -p $(TEST_COVERAGE_DIR )
397
399
CGO_ENABLED=1 tools/bin/gotestsum --junitfile " $( TEST_COVERAGE_DIR) /dumpling-junit-report.xml" -- -tags leak $(DUMPLING_ARGS ) \
398
400
$(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"
400
401
@make failpoint-disable
401
402
402
403
dumpling_integration_test : dumpling_bins failpoint-enable build_dumpling
@@ -420,9 +421,3 @@ dumpling_bins:
420
421
421
422
tools/bin/gotestsum : tools/check/go.mod
422
423
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
0 commit comments