Skip to content

Commit

Permalink
*: remove pingcap/check dependency (#34734)
Browse files Browse the repository at this point in the history
close #28328
  • Loading branch information
tisonkun authored May 17, 2022
1 parent a3193a8 commit 810f8ae
Show file tree
Hide file tree
Showing 160 changed files with 1,000 additions and 1,926 deletions.
17 changes: 6 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ut: tools/bin/ut tools/bin/xprog failpoint-enable
gotest: failpoint-enable
@echo "Running in native mode."
@export log_level=info; export TZ='Asia/Shanghai'; \
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -timeout 20m -cover $(PACKAGES_TIDB_TESTS) -coverprofile=coverage.txt -check.p true > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -timeout 20m -cover $(PACKAGES_TIDB_TESTS) -coverprofile=coverage.txt > gotest.log || { $(FAILPOINT_DISABLE); cat 'gotest.log'; exit 1; }
@$(FAILPOINT_DISABLE)

gotest_in_verify_ci: tools/bin/xprog tools/bin/ut failpoint-enable
Expand All @@ -151,11 +151,6 @@ race: failpoint-enable
@$(FAILPOINT_DISABLE)
@$(CLEAN_UT_BINARY)

leak: failpoint-enable
@export log_level=debug; \
$(GOTEST) -tags leak $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

server:
ifeq ($(TARGET), "")
CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
Expand Down Expand Up @@ -273,7 +268,7 @@ ifeq ("$(pkg)", "")
else
@echo "Running unit test for github.com/pingcap/tidb/$(pkg)"
@export log_level=fatal; export TZ='Asia/Shanghai'; \
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover github.com/pingcap/tidb/$(pkg) -check.p true -check.timeout 4s || { $(FAILPOINT_DISABLE); exit 1; }
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover github.com/pingcap/tidb/$(pkg) || { $(FAILPOINT_DISABLE); exit 1; }
endif
@$(FAILPOINT_DISABLE)

Expand Down Expand Up @@ -336,15 +331,15 @@ 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) -coverprofile=coverage.txt || ( make failpoint-disable && exit 1 )
$(GOTEST) $(RACE_FLAG) -ldflags '$(LDFLAGS)' $(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
@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 )
$(ARGS) -coverprofile="$(TEST_COVERAGE_DIR)/br_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
@make failpoint-disable

br_integration_test: br_bins build_br build_for_br_integration_test
Expand Down Expand Up @@ -401,12 +396,12 @@ build_dumpling:

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 )
$(DUMPLING_GOTEST) $(RACE_FLAG) -coverprofile=coverage.txt -covermode=atomic $(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
@mkdir -p $(TEST_COVERAGE_DIR)
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- -tags leak $(DUMPLING_ARGS) \
CGO_ENABLED=1 tools/bin/gotestsum --junitfile "$(TEST_COVERAGE_DIR)/dumpling-junit-report.xml" -- $(DUMPLING_ARGS) \
$(RACE_FLAG) -coverprofile="$(TEST_COVERAGE_DIR)/dumpling_cov.unit_test.out" || ( make failpoint-disable && exit 1 )
@make failpoint-disable

Expand Down
4 changes: 2 additions & 2 deletions bindinfo/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package bindinfo_test
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/backup/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package backup
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/checksum/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package checksum
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

Expand All @@ -28,6 +28,6 @@ func TestMain(m *testing.M) {
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
goleak.VerifyTestMain(m, opts...)
}
4 changes: 2 additions & 2 deletions br/pkg/conn/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package conn
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

Expand All @@ -27,6 +27,6 @@ func TestMain(m *testing.M) {
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
goleak.VerifyTestMain(m, opts...)
}
4 changes: 2 additions & 2 deletions br/pkg/lightning/checkpoints/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package checkpoints_test
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/common/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package common_test
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/mydump/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package mydump
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/metautil/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package metautil
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

Expand All @@ -26,6 +26,6 @@ func TestMain(m *testing.M) {
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
goleak.VerifyTestMain(m, opts...)
}
4 changes: 2 additions & 2 deletions br/pkg/pdutil/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package pdutil
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/restore/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"testing"

"github.com/pingcap/tidb/br/pkg/mock"
"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/rtree/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package rtree_test
import (
"testing"

"github.com/pingcap/tidb/util/testbridge"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.SetupForCommonTest()
testsetup.SetupForCommonTest()
opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
Expand Down
29 changes: 10 additions & 19 deletions br/pkg/stream/decode_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
package stream_test

import (
"bytes"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/br/pkg/stream"
"github.com/stretchr/testify/require"
)

type testDecodeKVSuite struct{}

func TestT(t *testing.T) {
TestingT(t)
}

var _ = Suite(&testDecodeKVSuite{})

func (s *testDecodeKVSuite) TestDecodeKVEntry(c *C) {
func TestDecodeKVEntry(t *testing.T) {
var (
pairs = map[string]string{
"db": "tidb",
Expand All @@ -37,17 +28,17 @@ func (s *testDecodeKVSuite) TestDecodeKVEntry(c *C) {
for ei.Valid() {
ei.Next()
err := ei.GetError()
c.Assert(err, IsNil)
require.NoError(t, err)

key := ei.Key()
value := ei.Value()
v, exist := pairs[string(key)]
c.Assert(exist, IsTrue)
c.Assert(string(value), Equals, v)
require.True(t, exist)
require.Equal(t, v, string(value))
}
}

func (s *testDecodeKVSuite) TestDecodeKVEntryError(c *C) {
func TestDecodeKVEntryError(t *testing.T) {
var (
k = []byte("db")
v = []byte("tidb")
Expand All @@ -59,10 +50,10 @@ func (s *testDecodeKVSuite) TestDecodeKVEntryError(c *C) {

ei := stream.NewEventIterator(buff)
ei.Next()
c.Assert(bytes.Equal(k, ei.Key()), IsTrue)
c.Assert(bytes.Equal(v, ei.Value()), IsTrue)
c.Assert(ei.Valid(), IsTrue)
require.Equal(t, k, ei.Key())
require.Equal(t, v, ei.Value())
require.True(t, ei.Valid())

ei.Next()
c.Assert(ei.GetError(), NotNil)
require.Error(t, ei.GetError())
}
Loading

0 comments on commit 810f8ae

Please sign in to comment.