Merge pull request #648 from pingcap/siddontang/ddl-test-flag

add test flag to skip long time DDL test.
This commit is contained in:
qiuyesuifeng
2015-11-27 19:08:35 +08:00
5 changed files with 37 additions and 0 deletions

View File

@ -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)'

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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 {