From 8c0a4d50ae0d9937414de594d9555eedb720203b Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 27 Nov 2015 16:20:18 +0800 Subject: [PATCH] *: add test flag to skip long time DDL test. --- Makefile | 6 ++++++ ddl/column_test.go | 4 ++++ ddl/ddl_db_test.go | 14 ++++++++++++++ ddl/index_test.go | 4 ++++ ddl/worker_test.go | 9 +++++++++ 5 files changed, 37 insertions(+) diff --git a/Makefile b/Makefile index 6a4651f27c..265388c237 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,12 @@ gotest: race: $(GO) test --race -cover ./... +ddl_test: + $(GO) test ./ddl/... -skip_ddl=false + +ddl_race_test: + $(GO) test --race ./ddl/... -skip_ddl=false + interpreter: @cd interpreter && $(GO) build -ldflags '$(LDFLAGS)' diff --git a/ddl/column_test.go b/ddl/column_test.go index df8d2e6f2b..31546f6cba 100644 --- a/ddl/column_test.go +++ b/ddl/column_test.go @@ -38,6 +38,8 @@ type testColumnSuite struct { } func (s *testColumnSuite) SetUpSuite(c *C) { + trySkipTest(c) + s.store = testCreateStore(c, "test_column") lease := 50 * time.Millisecond s.d = newDDL(s.store, nil, nil, lease) @@ -47,6 +49,8 @@ func (s *testColumnSuite) SetUpSuite(c *C) { } func (s *testColumnSuite) TearDownSuite(c *C) { + trySkipTest(c) + testDropSchema(c, mock.NewContext(), s.d, s.dbInfo) s.d.close() diff --git a/ddl/ddl_db_test.go b/ddl/ddl_db_test.go index 0772b8f8f1..6e28072e20 100644 --- a/ddl/ddl_db_test.go +++ b/ddl/ddl_db_test.go @@ -15,6 +15,7 @@ package ddl_test import ( "database/sql" + "flag" "fmt" "io" "math/rand" @@ -34,6 +35,15 @@ import ( "github.com/pingcap/tidb/util/types" ) +func trySkipDBTest(c *C) { + // skip_ddl flag is defined in ddl package, we can't use it directly, so using flag Lookup to help us. + if f := flag.Lookup("skip_ddl"); f == nil || strings.ToLower(f.Value.String()) == "false" { + return + } + + c.Skip("skip DB test") +} + var _ = Suite(&testDBSuite{}) type testDBSuite struct { @@ -47,6 +57,8 @@ type testDBSuite struct { } func (s *testDBSuite) SetUpSuite(c *C) { + trySkipDBTest(c) + var err error s.schemaName = "test_db" @@ -71,6 +83,8 @@ func (s *testDBSuite) SetUpSuite(c *C) { } func (s *testDBSuite) TearDownSuite(c *C) { + trySkipDBTest(c) + s.db.Close() s.s.Close() diff --git a/ddl/index_test.go b/ddl/index_test.go index 6c0e44f440..6cff19fcbf 100644 --- a/ddl/index_test.go +++ b/ddl/index_test.go @@ -37,6 +37,8 @@ type testIndexSuite struct { } func (s *testIndexSuite) SetUpSuite(c *C) { + trySkipTest(c) + s.store = testCreateStore(c, "test_index") lease := 50 * time.Millisecond s.d = newDDL(s.store, nil, nil, lease) @@ -46,6 +48,8 @@ func (s *testIndexSuite) SetUpSuite(c *C) { } func (s *testIndexSuite) TearDownSuite(c *C) { + trySkipTest(c) + testDropSchema(c, mock.NewContext(), s.d, s.dbInfo) s.d.close() diff --git a/ddl/worker_test.go b/ddl/worker_test.go index 21cdce9685..58481ac959 100644 --- a/ddl/worker_test.go +++ b/ddl/worker_test.go @@ -14,6 +14,7 @@ package ddl import ( + "flag" "fmt" "time" @@ -29,6 +30,14 @@ import ( "github.com/pingcap/tidb/util/types" ) +var skipDDL = flag.Bool("skip_ddl", true, "only run simple DDL test") + +func trySkipTest(c *C) { + if *skipDDL { + c.Skip("skip, only run simple tests") + } +} + var _ = Suite(&testDDLSuite{}) func testCreateStore(c *C, name string) kv.Storage {