Skip to content

Commit

Permalink
cmd: fix err check (#22986)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjianke authored Mar 1, 2021
1 parent e1004a2 commit 93d3c04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cmd/ddltest/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ type TestDDLSuite struct {
}

func (s *TestDDLSuite) SetUpSuite(c *C) {
logutil.InitLogger(&logutil.LogConfig{Config: zaplog.Config{Level: *logLevel}})
err := logutil.InitLogger(&logutil.LogConfig{Config: zaplog.Config{Level: *logLevel}})
c.Assert(err, IsNil)

s.quit = make(chan struct{})

var err error
s.store, err = store.New(fmt.Sprintf("tikv://%s%s", *etcd, *tikvPath))
c.Assert(err, IsNil)

Expand Down Expand Up @@ -304,7 +304,11 @@ func (s *TestDDLSuite) startServer(i int, fp *os.File) (*server, error) {
}
log.Warnf("ping addr %v failed, retry count %d err %v", addr, i, err)

db.Close()
err = db.Close()
if err != nil {
log.Warnf("close db failed, retry count %d err %v", i, err)
break
}
time.Sleep(sleepTime)
sleepTime += sleepTime
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/ddltest/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (s *TestDDLSuite) checkAddIndex(c *C, indexInfo *model.IndexInfo) {
txn, err := ctx.Txn(false)
c.Assert(err, IsNil)
defer func() {
txn.Rollback()
err = txn.Rollback()
c.Assert(err, IsNil)
}()

it, err := idx.SeekFirst(txn)
Expand Down Expand Up @@ -103,7 +104,10 @@ func (s *TestDDLSuite) checkDropIndex(c *C, indexInfo *model.IndexInfo) {
c.Assert(err, IsNil)
txn, err := ctx.Txn(false)
c.Assert(err, IsNil)
defer txn.Rollback()
defer func(){
err := txn.Rollback()
c.Assert(err, IsNil)
}()

it, err := idx.SeekFirst(txn)
c.Assert(err, IsNil)
Expand Down

0 comments on commit 93d3c04

Please sign in to comment.