From ebe8b0989d7e2684a8b0ee023042c58a8a52b441 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 21 Nov 2019 13:44:08 +0800 Subject: [PATCH] *: limit a single test function timeout to 4s (#13573) --- Makefile | 2 +- ddl/util/syncer_test.go | 5 +++++ go.mod | 2 ++ go.sum | 2 ++ plugin/conn_ip_example/conn_ip_example_test.go | 6 ++++++ plugin/plugin_test.go | 5 +++++ sessionctx/context_test.go | 6 ++++++ store/tikv/oracle/oracles/pd_test.go | 5 +++++ tidb-server/main_test.go | 10 +++++++++- util/arena/arena_test.go | 6 ++++++ util/execdetails/execdetails_test.go | 5 +++++ util/hack/hack_test.go | 6 ++++++ util/mvmap/mvmap_test.go | 6 ++++++ util/sys/linux/sys_test.go | 5 +++++ util/systimemon/systime_mon_test.go | 6 ++++++ 15 files changed, 75 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a67a1f9fe72df..7b5bddd3b1708 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ ifeq ("$(TRAVIS_COVERAGE)", "1") else @echo "Running in native mode." @export log_level=error; export TZ='Asia/Shanghai'; \ - $(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover $(PACKAGES) || { $(FAILPOINT_DISABLE); exit 1; } + $(GOTEST) -ldflags '$(TEST_LDFLAGS)' -cover $(PACKAGES) -check.timeout 4s || { $(FAILPOINT_DISABLE); exit 1; } endif @$(FAILPOINT_DISABLE) diff --git a/ddl/util/syncer_test.go b/ddl/util/syncer_test.go index cb1e9d4b92827..7f6ff7e1eb955 100644 --- a/ddl/util/syncer_test.go +++ b/ddl/util/syncer_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + . "github.com/pingcap/check" "github.com/pingcap/errors" "github.com/pingcap/parser/terror" . "github.com/pingcap/tidb/ddl" @@ -35,6 +36,10 @@ import ( "google.golang.org/grpc/codes" ) +func TestT(t *testing.T) { + TestingT(t) +} + const minInterval = 10 * time.Nanosecond // It's used to test timeout. func TestSyncerSimple(t *testing.T) { diff --git a/go.mod b/go.mod index edfa824c202b6..01a33dd669102 100644 --- a/go.mod +++ b/go.mod @@ -75,3 +75,5 @@ require ( ) go 1.13 + +replace github.com/pingcap/check => github.com/tiancaiamao/check v0.0.0-20191119042138-8e73d07b629d diff --git a/go.sum b/go.sum index 5a7fa014008f0..1936ca5739215 100644 --- a/go.sum +++ b/go.sum @@ -248,6 +248,8 @@ github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d h1:4J9HCZVpvDmj2t github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ= github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU= +github.com/tiancaiamao/check v0.0.0-20191119042138-8e73d07b629d h1:TMYOU9yCm2egiuzypRgFlVDw/5LzkJZaTmT26GPyFtE= +github.com/tiancaiamao/check v0.0.0-20191119042138-8e73d07b629d/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/plugin/conn_ip_example/conn_ip_example_test.go b/plugin/conn_ip_example/conn_ip_example_test.go index 70422d8ce5ffb..096ef7e3a6003 100644 --- a/plugin/conn_ip_example/conn_ip_example_test.go +++ b/plugin/conn_ip_example/conn_ip_example_test.go @@ -15,7 +15,9 @@ package main_test import ( "context" + "testing" + . "github.com/pingcap/check" "github.com/pingcap/tidb/plugin" "github.com/pingcap/tidb/sessionctx/variable" ) @@ -52,3 +54,7 @@ func LoadRunShutdownPluginExample() { plugin.Shutdown(context.Background()) } + +func TestT(t *testing.T) { + TestingT(t) +} diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go index 0f5acb6b26616..851afd5420d19 100644 --- a/plugin/plugin_test.go +++ b/plugin/plugin_test.go @@ -19,9 +19,14 @@ import ( "strconv" "testing" + "github.com/pingcap/check" "github.com/pingcap/tidb/sessionctx/variable" ) +func TestT(t *testing.T) { + check.TestingT(t) +} + func TestLoadPluginSuccess(t *testing.T) { ctx := context.Background() diff --git a/sessionctx/context_test.go b/sessionctx/context_test.go index 3e9af71335a1d..a06ee540796c3 100644 --- a/sessionctx/context_test.go +++ b/sessionctx/context_test.go @@ -16,8 +16,14 @@ package sessionctx import ( "fmt" "testing" + + . "github.com/pingcap/check" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestBasicCtxTypeToString(t *testing.T) { tests := []struct { key fmt.Stringer diff --git a/store/tikv/oracle/oracles/pd_test.go b/store/tikv/oracle/oracles/pd_test.go index 882c0dc64f578..e5199fbf2ad7f 100644 --- a/store/tikv/oracle/oracles/pd_test.go +++ b/store/tikv/oracle/oracles/pd_test.go @@ -17,10 +17,15 @@ import ( "testing" "time" + . "github.com/pingcap/check" "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/store/tikv/oracle/oracles" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestPDOracle_UntilExpired(t *testing.T) { lockAfter, lockExp := 10, 15 o := oracles.NewEmptyPDOracle() diff --git a/tidb-server/main_test.go b/tidb-server/main_test.go index bd34b09481887..747b40505cf90 100644 --- a/tidb-server/main_test.go +++ b/tidb-server/main_test.go @@ -13,7 +13,11 @@ package main -import "testing" +import ( + "testing" + + . "github.com/pingcap/check" +) var isCoverageServer = "0" @@ -24,3 +28,7 @@ func TestRunMain(t *testing.T) { main() } } + +func TestT(t *testing.T) { + TestingT(t) +} diff --git a/util/arena/arena_test.go b/util/arena/arena_test.go index c08cc6a133353..649903b954717 100644 --- a/util/arena/arena_test.go +++ b/util/arena/arena_test.go @@ -15,8 +15,14 @@ package arena import ( "testing" + + . "github.com/pingcap/check" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestSimpleArenaAllocator(t *testing.T) { arena := NewAllocator(1000) slice := arena.Alloc(10) diff --git a/util/execdetails/execdetails_test.go b/util/execdetails/execdetails_test.go index b516282095bd3..429ea11a1cf8b 100644 --- a/util/execdetails/execdetails_test.go +++ b/util/execdetails/execdetails_test.go @@ -19,10 +19,15 @@ import ( "testing" "time" + . "github.com/pingcap/check" "github.com/pingcap/tidb/util/stringutil" "github.com/pingcap/tipb/go-tipb" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestString(t *testing.T) { detail := &ExecDetails{ ProcessTime: 2*time.Second + 5*time.Millisecond, diff --git a/util/hack/hack_test.go b/util/hack/hack_test.go index 9443115eb9cf8..9025a0a745898 100644 --- a/util/hack/hack_test.go +++ b/util/hack/hack_test.go @@ -16,8 +16,14 @@ package hack import ( "bytes" "testing" + + . "github.com/pingcap/check" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestString(t *testing.T) { b := []byte("hello world") a := String(b) diff --git a/util/mvmap/mvmap_test.go b/util/mvmap/mvmap_test.go index 1c2f3ca4f7571..3c273f90d9a4e 100644 --- a/util/mvmap/mvmap_test.go +++ b/util/mvmap/mvmap_test.go @@ -19,8 +19,14 @@ import ( "fmt" "hash/fnv" "testing" + + . "github.com/pingcap/check" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestMVMap(t *testing.T) { m := NewMVMap() var vals [][]byte diff --git a/util/sys/linux/sys_test.go b/util/sys/linux/sys_test.go index b9ccc2a823bec..c11bb18354ca2 100644 --- a/util/sys/linux/sys_test.go +++ b/util/sys/linux/sys_test.go @@ -15,9 +15,14 @@ package linux_test import ( "testing" + . "github.com/pingcap/check" "github.com/pingcap/tidb/util/sys/linux" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestGetOSVersion(t *testing.T) { osRelease, err := linux.OSVersion() if err != nil { diff --git a/util/systimemon/systime_mon_test.go b/util/systimemon/systime_mon_test.go index 59d9668952481..e9e44f9170213 100644 --- a/util/systimemon/systime_mon_test.go +++ b/util/systimemon/systime_mon_test.go @@ -17,8 +17,14 @@ import ( "sync/atomic" "testing" "time" + + . "github.com/pingcap/check" ) +func TestT(t *testing.T) { + TestingT(t) +} + func TestSystimeMonitor(t *testing.T) { var jumpForward int32