Skip to content

Commit

Permalink
tests: follow up to clean up go-check staff (#28161)
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Sep 18, 2021
1 parent fef2d48 commit 45e4b30
Show file tree
Hide file tree
Showing 11 changed files with 2,935 additions and 247 deletions.
26 changes: 11 additions & 15 deletions tests/globalkilltest/global_kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"time"

_ "github.com/go-sql-driver/mysql"
. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb/util/logutil"
Expand Down Expand Up @@ -83,7 +82,7 @@ func createGloabalKillSuite(t *testing.T) (s *GlobalKillSuite, clean func()) {
if s.pdCli != nil {
require.NoError(t, err)
}
require.NoError(t, s.cleanCluster)
require.NoError(t, s.cleanCluster())
}

return
Expand Down Expand Up @@ -443,16 +442,14 @@ func TestWithoutPD(t *testing.T) {
require.NoError(t, err)
}()

sleepTime := 2

// Test mysql client CTRL-C
// mysql client "CTRL-C" truncate connection id to 32bits, and is ignored by TiDB.
elapsed := s.killByCtrlC(t, port, sleepTime)
require.GreaterOrEqual(t, elapsed, sleepTime*time.Second)
elapsed := s.killByCtrlC(t, port, 2)
require.GreaterOrEqual(t, elapsed, 2*time.Second)

// Test KILL statement
elapsed = s.killByKillStatement(t, db, db, sleepTime)
require.Less(t, elapsed, sleepTime*time.Second)
elapsed = s.killByKillStatement(t, db, db, 2)
require.Less(t, elapsed, 2*time.Second)
}

// [Test Scenario 2] One TiDB with PD, killed by Ctrl+C, and killed by KILL.
Expand Down Expand Up @@ -488,7 +485,7 @@ func TestOneTiDB(t *testing.T) {
func TestMultipleTiDB(t *testing.T) {
s, clean := createGloabalKillSuite(t)
defer clean()
require.NoError(t, s.pdErr, Commentf(msgErrConnectPD, s.pdErr))
require.NoErrorf(t, s.pdErr, msgErrConnectPD, s.pdErr)

// tidb1 & conn1a,conn1b
port1 := *tidbStartPort + 1
Expand Down Expand Up @@ -536,7 +533,7 @@ func TestLostConnection(t *testing.T) {
t.Skip("unstable, skip race test")
s, clean := createGloabalKillSuite(t)
defer clean()
require.NoError(t, s.pdErr, Commentf(msgErrConnectPD, s.pdErr))
require.NoErrorf(t, s.pdErr, msgErrConnectPD, s.pdErr)

// tidb1
port1 := *tidbStartPort + 1
Expand Down Expand Up @@ -629,11 +626,10 @@ func TestLostConnection(t *testing.T) {
}()

// [Test Scenario 7] Connections can be killed after PD lost connection for long time and then recovered.
sleepTime := 2
elapsed := s.killByKillStatement(t, db1, db1, sleepTime)
require.Less(t, elapsed, sleepTime*time.Second)
elapsed := s.killByKillStatement(t, db1, db1, 2)
require.Less(t, elapsed, 2*time.Second)

elapsed = s.killByKillStatement(t, db1, db2, sleepTime)
require.Less(t, elapsed, sleepTime*time.Second)
elapsed = s.killByKillStatement(t, db1, db2, 2)
require.Less(t, elapsed, 2*time.Second)
}
}
21 changes: 12 additions & 9 deletions tests/globalkilltest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ module github.com/pingcap/tests/globalkilltest
go 1.16

require (
github.com/go-sql-driver/mysql v1.5.0
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/go-sql-driver/mysql v1.6.0
github.com/pingcap/errors v0.11.5-0.20210513014640-40f9a1999b3b
github.com/pingcap/log v0.0.0-20200828042413-fce0951f1463
github.com/pingcap/tidb v1.1.0-beta.0.20201020170636-b71b6323fd4d
github.com/pingcap/tipb v0.0.0-20201020032630-6dac8b6c0aab // indirect
github.com/stretchr/testify v1.5.1 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738
go.uber.org/zap v1.16.0
google.golang.org/grpc v1.26.0
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/tidb v2.0.11+incompatible
github.com/stretchr/testify v1.7.0
go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b
go.uber.org/goleak v1.1.11 // indirect
go.uber.org/zap v1.19.0
google.golang.org/grpc v1.40.0
)

replace github.com/pingcap/tidb => ../../

replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
741 changes: 586 additions & 155 deletions tests/globalkilltest/go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/globalkilltest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
package globalkilltest

import (
"os"
"testing"

"github.com/pingcap/tidb/util/testbridge"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.WorkaroundGoCheckFlags()
goleak.VerifyTestMain(m)
os.Exit(m.Run())
}
14 changes: 9 additions & 5 deletions tests/graceshutdown/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ module graceshutdown
go 1.15

require (
github.com/go-sql-driver/mysql v1.5.0
github.com/go-sql-driver/mysql v1.6.0
github.com/juju/errors v0.0.0-20200330140219-3fe23663418f
github.com/juju/testing v0.0.0-20210302031854-2c7ee8570c07 // indirect
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/pingcap/log v0.0.0-20200828042413-fce0951f1463
go.uber.org/zap v1.12.0
github.com/juju/testing v0.0.0-20210324180055-18c50b0c2098 // indirect
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/tidb v2.0.11+incompatible
github.com/stretchr/testify v1.7.0
go.uber.org/goleak v1.1.11
go.uber.org/zap v1.19.0
)

replace github.com/pingcap/tidb => ../../
Loading

0 comments on commit 45e4b30

Please sign in to comment.