Skip to content

Commit

Permalink
tests: fix e2e-test (#34194)
Browse files Browse the repository at this point in the history
close #34195
  • Loading branch information
xuyifangreeneyes authored Apr 29, 2022
1 parent 3ee4328 commit 6ea8302
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 2,156 deletions.
4 changes: 2 additions & 2 deletions tests/globalkilltest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ buildsucc:
@echo "Build TiDB Server (Global Kill Test) successfully! Setup a cluster with PD & TiKV, then Run ./run-tests.sh --pd=<pd client path>."

clean:
rm *.log*
rm tikv-*/ pd-*/ -rf
rm -f *.log*
rm -rf tikv-*/ pd-*/

server:
ifeq ($(TARGET), "")
Expand Down
2 changes: 0 additions & 2 deletions tests/globalkilltest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ Usage: ./run-tests.sh [options]

* Execute `SELECT SLEEP(x)` as payload, and kill the query before `x` expired. If the query had no error and elapsed less than `x`, the test is PASSED.

* Run a embedded [tcp proxy](https://github.com/inetaf/tcpproxy) before PD. Stop & restart the proxy to simulate connection between TiDB and PD lost & restored.


## Usage

Expand Down
9 changes: 4 additions & 5 deletions tests/globalkilltest/global_kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (s *GlobalKillSuite) stopService(name string, cmd *exec.Cmd, graceful bool)
}
log.Info(fmt.Sprintf("service \"%s\" stopped gracefully", name))
return nil
case <-time.After(10 * time.Second):
case <-time.After(60 * time.Second):
err = fmt.Errorf("service \"%s\" can't gracefully stop in time", name)
log.Info(err.Error())
return err
Expand Down Expand Up @@ -530,7 +530,6 @@ func TestMultipleTiDB(t *testing.T) {
}

func TestLostConnection(t *testing.T) {
t.Skip("unstable, skip race test")
s, clean := createGloabalKillSuite(t)
defer clean()
require.NoErrorf(t, s.pdErr, msgErrConnectPD, s.pdErr)
Expand Down Expand Up @@ -585,15 +584,15 @@ func TestLostConnection(t *testing.T) {
// [Test Scenario 4] Existing connections are killed after PD lost connection for long time.
r := <-ch
log.Info("sleepRoutine err", zap.Error(r.err))
require.NoError(t, err)
require.NotNil(t, r.err)
require.Equal(t, r.err.Error(), "invalid connection")

// check new connection.
// [Test Scenario 5] New connections are not accepted after PD lost connection for long time.
log.Info("check connection after lost connection to PD.")
_, err = s.connectTiDB(port1)
log.Info("connectTiDB err", zap.Error(r.err))
require.NoError(t, err)
log.Info("connectTiDB err", zap.Error(err))
require.NotNil(t, err)
require.Equal(t, err.Error(), "driver: bad connection")

err = s.stopTiKV()
Expand Down
36 changes: 29 additions & 7 deletions tests/globalkilltest/go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
module github.com/pingcap/tests/globalkilltest

go 1.16
go 1.18

require (
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-20210906054005-afc726e70354
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
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.20210512015243-d19fbe541bf9
go.uber.org/goleak v1.1.11 // indirect
go.uber.org/zap v1.19.1
google.golang.org/grpc v1.40.0
go.etcd.io/etcd/client/v3 v3.5.2
go.uber.org/zap v1.21.0
google.golang.org/grpc v1.44.0
)

require (
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220216160803-4663080d8bc8 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

// fix potential security issue(CVE-2020-26160) introduced by indirect dependency.
Expand Down
1,069 changes: 77 additions & 992 deletions tests/globalkilltest/go.sum

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions tests/graceshutdown/go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
module graceshutdown

go 1.15
go 1.18

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/pingcap/errors v0.11.5-0.20210425183316-da1aaba5fb63
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
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.1
go.uber.org/goleak v1.1.12
go.uber.org/zap v1.21.0
)

require (
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

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

0 comments on commit 6ea8302

Please sign in to comment.