Skip to content

Commit

Permalink
Makefile: add t.Parallel check to ensure tests are run in serial (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored Dec 22, 2021
1 parent 529ce88 commit 46e67db
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev: checklist check explaintest devgotest gogenerate br_unit_test test_part_par
# Install the check tools.
check-setup:tools/bin/revive tools/bin/goword

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

fmt:
@echo "gofmt (simplify)"
Expand Down Expand Up @@ -75,6 +75,13 @@ testSuite:
@echo "testSuite"
./tools/check/check_testSuite.sh

check-parallel:
# Make sure no tests are run in parallel to prevent possible unstable tests.
# See https://github.com/pingcap/tidb/pull/30692.
@! find . -name "*_test.go" -not -path "./vendor/*" -print0 | \
xargs -0 grep -F -n "t.Parallel()" || \
! echo "Error: all the go tests should be run in serial."

clean: failpoint-disable
$(GO) clean -i ./...

Expand Down
4 changes: 0 additions & 4 deletions br/pkg/task/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

func TestParseTSString(t *testing.T) {
t.Parallel()

var (
ts uint64
err error
Expand All @@ -33,8 +31,6 @@ func TestParseTSString(t *testing.T) {
}

func TestParseCompressionType(t *testing.T) {
t.Parallel()

var (
ct backup.CompressionType
err error
Expand Down
5 changes: 0 additions & 5 deletions br/pkg/task/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (f fakeValue) Type() string {
}

func TestUrlNoQuery(t *testing.T) {
t.Parallel()
flag := &pflag.Flag{
Name: flagStorage,
Value: fakeValue("s3://some/what?secret=a123456789&key=987654321"),
Expand All @@ -40,7 +39,6 @@ func TestUrlNoQuery(t *testing.T) {
}

func TestTiDBConfigUnchanged(t *testing.T) {
t.Parallel()
cfg := config.GetGlobalConfig()
restoreConfig := enableTiDBConfig()
require.NotEqual(t, config.GetGlobalConfig(), cfg)
Expand All @@ -49,7 +47,6 @@ func TestTiDBConfigUnchanged(t *testing.T) {
}

func TestStripingPDURL(t *testing.T) {
t.Parallel()
nor1, err := normalizePDURL("https://pd:5432", true)
require.NoError(t, err)
require.Equal(t, "pd:5432", nor1)
Expand All @@ -68,7 +65,6 @@ func TestStripingPDURL(t *testing.T) {
}

func TestCheckCipherKeyMatch(t *testing.T) {
t.Parallel()
cases := []struct {
CipherType encryptionpb.EncryptionMethod
CipherKey string
Expand Down Expand Up @@ -125,7 +121,6 @@ func TestCheckCipherKeyMatch(t *testing.T) {
}

func TestCheckCipherKey(t *testing.T) {
t.Parallel()
cases := []struct {
cipherKey string
keyFile string
Expand Down
2 changes: 0 additions & 2 deletions br/pkg/task/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
)

func TestRestoreConfigAdjust(t *testing.T) {
t.Parallel()

cfg := &RestoreConfig{}
cfg.adjustRestoreConfig()

Expand Down
4 changes: 0 additions & 4 deletions br/pkg/utils/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ func TestPdBackoffWithRetryableError(t *testing.T) {
}

func TestNewImportSSTBackofferWithSucess(t *testing.T) {
t.Parallel()

var counter int
backoffer := utils.NewImportSSTBackoffer()
err := utils.WithRetry(context.Background(), func() error {
Expand All @@ -142,8 +140,6 @@ func TestNewImportSSTBackofferWithSucess(t *testing.T) {
}

func TestNewDownloadSSTBackofferWithCancel(t *testing.T) {
t.Parallel()

var counter int
backoffer := utils.NewDownloadSSTBackoffer()
err := utils.WithRetry(context.Background(), func() error {
Expand Down
1 change: 0 additions & 1 deletion table/tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ func TestViewColumns(t *testing.T) {
}

func TestConstraintCheckForOptimisticUntouched(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()

Expand Down

0 comments on commit 46e67db

Please sign in to comment.