Skip to content

Commit

Permalink
*: make race with debug level (pingcap#1687)
Browse files Browse the repository at this point in the history
* *: make race with debug level

* *: fix the problem of compatibility on the Mac

* ddl: pass make race
  • Loading branch information
zimulala authored Sep 5, 2016
1 parent 232605a commit 3e3ae88
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ endif

path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH)

GO := GO15VENDOREXPERIMENT="1" go

ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
Expand Down Expand Up @@ -97,12 +97,19 @@ test: gotest

gotest:
rm -rf vendor && ln -s _vendor/vendor vendor
@export log_level=error;\
$(GO) test -cover $(PACKAGES)
rm -rf vendor

race:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) test --race $(PACKAGES)
@export log_level=debug; \
dirs=`go list ./... | grep -vE 'vendor' | awk '{sub("github.com/pingcap/tidb/",""); print}'`;\
for dir in $$dirs; do \
cd $$dir;\
go test -race | awk 'END{if($$1=="FAIL") {exit 1}}' || exit 1;\
cd -;\
done;
rm -rf vendor

tikv_integration_test:
Expand Down
6 changes: 6 additions & 0 deletions ddl/column_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package ddl

import (
"fmt"
"sync"

"github.com/juju/errors"
. "github.com/pingcap/check"
Expand Down Expand Up @@ -67,6 +68,7 @@ func (s *testColumnChangeSuite) TestColumnChange(c *C) {
err = ctx.CommitTxn()
c.Assert(err, IsNil)

var mu sync.Mutex
tc := &testDDLCallback{}
// set up hook
prevState := model.StateNone
Expand Down Expand Up @@ -98,6 +100,7 @@ func (s *testColumnChangeSuite) TestColumnChange(c *C) {
checkErr = errors.Trace(err)
}
case model.StatePublic:
mu.Lock()
publicTable, err = getCurrentTable(d, s.dbInfo.ID, tblInfo.ID)
if err != nil {
checkErr = errors.Trace(err)
Expand All @@ -106,14 +109,17 @@ func (s *testColumnChangeSuite) TestColumnChange(c *C) {
if err != nil {
checkErr = errors.Trace(err)
}
mu.Unlock()
}
}
d.hook = tc
defaultValue := int64(3)
job := testCreateColumn(c, ctx, d, s.dbInfo, tblInfo, "c3", &ast.ColumnPosition{Tp: ast.ColumnPositionNone}, defaultValue)
c.Assert(errors.ErrorStack(checkErr), Equals, "")
testCheckJobDone(c, d, job, true)
mu.Lock()
s.testColumnDrop(c, ctx, d, publicTable)
mu.Unlock()
s.testAddColumnNoDefault(c, ctx, d, tblInfo)
d.close()
}
Expand Down
4 changes: 3 additions & 1 deletion ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package ddl_test

import (
"os"
"testing"

"github.com/ngaut/log"
Expand Down Expand Up @@ -46,6 +47,7 @@ func (ts *testSuite) SetUpSuite(c *C) {
}

func init() {
log.SetLevelByString("warn")
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.Lshortfile)
}
4 changes: 3 additions & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package executor_test
import (
"flag"
"fmt"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -66,7 +67,8 @@ func (s *testSuite) SetUpSuite(c *C) {
c.Assert(err, IsNil)
s.store = store
}
log.SetLevelByString("warn")
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
executor.BaseLookupTableTaskSize = 2
}

Expand Down
4 changes: 3 additions & 1 deletion privilege/privileges/privileges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package privileges_test

import (
"fmt"
"os"
"testing"

"github.com/ngaut/log"
Expand Down Expand Up @@ -53,7 +54,8 @@ type testPrivilegeSuite struct {
}

func (s *testPrivilegeSuite) SetUpSuit(c *C) {
log.SetLevelByString("error")
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
}

func (s *testPrivilegeSuite) SetUpTest(c *C) {
Expand Down
4 changes: 2 additions & 2 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ func (s *testKVSuite) SetUpSuite(c *C) {

cacheS, _ := tidb.NewStore(fmt.Sprintf("%s://%s", *testStore, *testStorePath))
c.Assert(cacheS, Equals, store)
log.SetLevelByString("warn")
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
}

func (s *testKVSuite) TearDownSuite(c *C) {
log.SetLevelByString("debug")
err := s.s.Close()
c.Assert(err, IsNil)
}
Expand Down
3 changes: 2 additions & 1 deletion tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import (
var store = flag.String("store", "memory", "registered store name, [memory, goleveldb, boltdb]")

func TestT(t *testing.T) {
log.SetLevelByString("error")
logLevel := os.Getenv("log_level")
log.SetLevelByString(logLevel)
TestingT(t)
}

Expand Down

0 comments on commit 3e3ae88

Please sign in to comment.