From 52d1e2debf7e2aca3f6c3746e54c8809f0d34172 Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 13 Jun 2019 11:28:55 +0800 Subject: [PATCH 1/3] owner: add unit tests --- owner/c.out | 100 ++++++++++++++++++++++++ owner/manager_test.go | 175 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 275 insertions(+) create mode 100644 owner/c.out create mode 100644 owner/manager_test.go diff --git a/owner/c.out b/owner/c.out new file mode 100644 index 0000000000000..fe07b240f8577 --- /dev/null +++ b/owner/c.out @@ -0,0 +1,100 @@ +mode: set +github.com/pingcap/tidb/owner/manager.go:90.107,101.2 2 1 +github.com/pingcap/tidb/owner/manager.go:104.36,106.2 1 0 +github.com/pingcap/tidb/owner/manager.go:109.39,111.2 1 1 +github.com/pingcap/tidb/owner/manager.go:114.33,116.2 1 1 +github.com/pingcap/tidb/owner/manager.go:122.35,124.22 2 1 +github.com/pingcap/tidb/owner/manager.go:127.2,128.16 2 0 +github.com/pingcap/tidb/owner/manager.go:131.2,132.12 2 0 +github.com/pingcap/tidb/owner/manager.go:124.22,126.3 1 1 +github.com/pingcap/tidb/owner/manager.go:128.16,130.3 1 0 +github.com/pingcap/tidb/owner/manager.go:136.131,141.32 4 1 +github.com/pingcap/tidb/owner/manager.go:176.2,176.39 1 1 +github.com/pingcap/tidb/owner/manager.go:141.32,142.46 1 1 +github.com/pingcap/tidb/owner/manager.go:146.3,146.61 1 1 +github.com/pingcap/tidb/owner/manager.go:154.3,154.59 1 1 +github.com/pingcap/tidb/owner/manager.go:162.3,166.17 4 1 +github.com/pingcap/tidb/owner/manager.go:169.3,169.36 1 0 +github.com/pingcap/tidb/owner/manager.go:173.3,174.14 2 0 +github.com/pingcap/tidb/owner/manager.go:142.46,144.4 1 1 +github.com/pingcap/tidb/owner/manager.go:146.61,147.18 1 0 +github.com/pingcap/tidb/owner/manager.go:147.18,148.43 1 0 +github.com/pingcap/tidb/owner/manager.go:148.43,150.6 1 0 +github.com/pingcap/tidb/owner/manager.go:154.59,155.18 1 0 +github.com/pingcap/tidb/owner/manager.go:155.18,156.62 1 0 +github.com/pingcap/tidb/owner/manager.go:156.62,158.6 1 0 +github.com/pingcap/tidb/owner/manager.go:166.17,167.9 1 1 +github.com/pingcap/tidb/owner/manager.go:169.36,171.4 1 0 +github.com/pingcap/tidb/owner/manager.go:180.65,183.16 3 1 +github.com/pingcap/tidb/owner/manager.go:186.2,187.12 2 1 +github.com/pingcap/tidb/owner/manager.go:183.16,185.3 1 1 +github.com/pingcap/tidb/owner/manager.go:191.63,193.17 2 0 +github.com/pingcap/tidb/owner/manager.go:197.2,200.16 4 0 +github.com/pingcap/tidb/owner/manager.go:204.2,205.12 2 0 +github.com/pingcap/tidb/owner/manager.go:193.17,195.3 1 0 +github.com/pingcap/tidb/owner/manager.go:200.16,202.3 1 0 +github.com/pingcap/tidb/owner/manager.go:208.62,210.2 1 1 +github.com/pingcap/tidb/owner/manager.go:213.38,215.2 1 1 +github.com/pingcap/tidb/owner/manager.go:217.92,220.15 3 1 +github.com/pingcap/tidb/owner/manager.go:229.2,232.6 4 1 +github.com/pingcap/tidb/owner/manager.go:220.15,222.31 2 1 +github.com/pingcap/tidb/owner/manager.go:222.31,226.4 3 0 +github.com/pingcap/tidb/owner/manager.go:232.6,233.17 1 1 +github.com/pingcap/tidb/owner/manager.go:237.3,237.10 1 1 +github.com/pingcap/tidb/owner/manager.go:256.3,256.56 1 1 +github.com/pingcap/tidb/owner/manager.go:264.3,266.17 3 1 +github.com/pingcap/tidb/owner/manager.go:271.3,272.17 2 1 +github.com/pingcap/tidb/owner/manager.go:276.3,281.50 5 1 +github.com/pingcap/tidb/owner/manager.go:233.17,235.4 1 1 +github.com/pingcap/tidb/owner/manager.go:238.29,242.18 4 1 +github.com/pingcap/tidb/owner/manager.go:247.21,250.10 3 1 +github.com/pingcap/tidb/owner/manager.go:251.11,251.11 0 1 +github.com/pingcap/tidb/owner/manager.go:242.18,246.5 3 1 +github.com/pingcap/tidb/owner/manager.go:256.56,257.26 1 0 +github.com/pingcap/tidb/owner/manager.go:261.4,261.12 1 0 +github.com/pingcap/tidb/owner/manager.go:257.26,260.5 2 0 +github.com/pingcap/tidb/owner/manager.go:266.17,268.12 2 1 +github.com/pingcap/tidb/owner/manager.go:272.17,273.12 1 0 +github.com/pingcap/tidb/owner/manager.go:285.82,293.2 4 1 +github.com/pingcap/tidb/owner/manager.go:296.72,298.16 2 1 +github.com/pingcap/tidb/owner/manager.go:301.2,301.24 1 1 +github.com/pingcap/tidb/owner/manager.go:304.2,304.39 1 0 +github.com/pingcap/tidb/owner/manager.go:298.16,300.3 1 0 +github.com/pingcap/tidb/owner/manager.go:301.24,303.3 1 1 +github.com/pingcap/tidb/owner/manager.go:308.103,310.16 2 1 +github.com/pingcap/tidb/owner/manager.go:315.2,317.19 3 1 +github.com/pingcap/tidb/owner/manager.go:322.2,322.37 1 1 +github.com/pingcap/tidb/owner/manager.go:310.16,314.3 2 1 +github.com/pingcap/tidb/owner/manager.go:317.19,320.3 2 0 +github.com/pingcap/tidb/owner/manager.go:325.102,330.6 5 1 +github.com/pingcap/tidb/owner/manager.go:330.6,331.10 1 1 +github.com/pingcap/tidb/owner/manager.go:332.30,333.11 1 1 +github.com/pingcap/tidb/owner/manager.go:338.4,338.21 1 1 +github.com/pingcap/tidb/owner/manager.go:344.4,344.35 1 1 +github.com/pingcap/tidb/owner/manager.go:351.29,353.10 2 1 +github.com/pingcap/tidb/owner/manager.go:354.21,356.10 2 1 +github.com/pingcap/tidb/owner/manager.go:333.11,337.5 3 0 +github.com/pingcap/tidb/owner/manager.go:338.21,342.5 3 0 +github.com/pingcap/tidb/owner/manager.go:344.35,345.33 1 1 +github.com/pingcap/tidb/owner/manager.go:345.33,349.6 3 1 +github.com/pingcap/tidb/owner/manager.go:361.13,363.16 2 1 +github.com/pingcap/tidb/owner/manager.go:363.16,365.3 1 0 +github.com/pingcap/tidb/owner/manager.go:368.56,369.9 1 1 +github.com/pingcap/tidb/owner/manager.go:377.2,379.53 1 1 +github.com/pingcap/tidb/owner/manager.go:383.2,383.12 1 1 +github.com/pingcap/tidb/owner/manager.go:370.20,371.33 1 1 +github.com/pingcap/tidb/owner/manager.go:372.10,372.10 0 1 +github.com/pingcap/tidb/owner/manager.go:379.53,381.3 1 0 +github.com/pingcap/tidb/owner/mock.go:35.67,40.2 1 0 +github.com/pingcap/tidb/owner/mock.go:43.35,45.2 1 0 +github.com/pingcap/tidb/owner/mock.go:48.38,50.2 1 0 +github.com/pingcap/tidb/owner/mock.go:52.35,54.2 1 0 +github.com/pingcap/tidb/owner/mock.go:57.37,59.2 1 0 +github.com/pingcap/tidb/owner/mock.go:62.32,64.2 1 0 +github.com/pingcap/tidb/owner/mock.go:67.71,68.17 1 0 +github.com/pingcap/tidb/owner/mock.go:71.2,71.35 1 0 +github.com/pingcap/tidb/owner/mock.go:68.17,70.3 1 0 +github.com/pingcap/tidb/owner/mock.go:75.62,78.2 2 0 +github.com/pingcap/tidb/owner/mock.go:81.62,82.17 1 0 +github.com/pingcap/tidb/owner/mock.go:85.2,85.12 1 0 +github.com/pingcap/tidb/owner/mock.go:82.17,84.3 1 0 diff --git a/owner/manager_test.go b/owner/manager_test.go new file mode 100644 index 0000000000000..21cb1652af188 --- /dev/null +++ b/owner/manager_test.go @@ -0,0 +1,175 @@ +// Copyright 2017 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package owner_test + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/coreos/etcd/clientv3" + "github.com/coreos/etcd/clientv3/concurrency" + "github.com/coreos/etcd/integration" + "github.com/pingcap/errors" + "github.com/pingcap/parser/terror" + . "github.com/pingcap/tidb/ddl" + "github.com/pingcap/tidb/owner" + "github.com/pingcap/tidb/store/mockstore" + "github.com/pingcap/tidb/util/logutil" + goctx "golang.org/x/net/context" +) + +const testLease = 5 * time.Millisecond + +func checkOwner(d DDL, fbVal bool) (isOwner bool) { + manager := d.OwnerManager() + // The longest to wait for 3 seconds to + // make sure that campaigning owners is completed. + for i := 0; i < 600; i++ { + time.Sleep(5 * time.Millisecond) + isOwner = manager.IsOwner() + if isOwner == fbVal { + break + } + } + return +} + +func TestSingle(t *testing.T) { + store, err := mockstore.NewMockTikvStore() + if err != nil { + t.Fatal(err) + } + defer store.Close() + + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) + defer clus.Terminate(t) + cli := clus.RandClient() + ctx := goctx.Background() + d := NewDDL(ctx, cli, store, nil, nil, testLease, nil) + defer d.Stop() + + isOwner := checkOwner(d, true) + if !isOwner { + t.Fatalf("expect true, got isOwner:%v", isOwner) + } + + // test for newSession failed + ctx, cancel := goctx.WithCancel(ctx) + cancel() + manager := owner.NewOwnerManager(cli, "ddl", "ddl_id", DDLOwnerKey, nil) + err = manager.CampaignOwner(ctx) + if !terror.ErrorEqual(err, goctx.Canceled) && + !terror.ErrorEqual(err, goctx.DeadlineExceeded) { + t.Fatalf("campaigned result don't match, err %v", err) + } + isOwner = checkOwner(d, true) + if !isOwner { + t.Fatalf("expect true, got isOwner:%v", isOwner) + } + // The test is used to exit campaign loop. + d.OwnerManager().Cancel() + isOwner = checkOwner(d, false) + if isOwner { + t.Fatalf("expect false, got isOwner:%v", isOwner) + } + time.Sleep(10 * time.Millisecond) + ownerID, _ := manager.GetOwnerID(goctx.Background()) + // The error is ok to be not nil since we canceled the manager. + if ownerID != "" { + t.Fatalf("owner %s is not empty", ownerID) + } +} + +func TestCluster(t *testing.T) { + tmpTTL := 3 + orignalTTL := owner.ManagerSessionTTL + owner.ManagerSessionTTL = tmpTTL + defer func() { + owner.ManagerSessionTTL = orignalTTL + }() + store, err := mockstore.NewMockTikvStore() + if err != nil { + t.Fatal(err) + } + defer store.Close() + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 4}) + defer clus.Terminate(t) + + cli := clus.Client(0) + d := NewDDL(goctx.Background(), cli, store, nil, nil, testLease, nil) + isOwner := checkOwner(d, true) + if !isOwner { + t.Fatalf("expect true, got isOwner:%v", isOwner) + } + cli1 := clus.Client(1) + d1 := NewDDL(goctx.Background(), cli1, store, nil, nil, testLease, nil) + isOwner = checkOwner(d1, false) + if isOwner { + t.Fatalf("expect false, got isOwner:%v", isOwner) + } + + // Delete the leader key, the d1 become the owner. + cliRW := clus.Client(2) + err = deleteLeader(cliRW, DDLOwnerKey) + if err != nil { + t.Fatal(err) + } + isOwner = checkOwner(d, false) + if isOwner { + t.Fatalf("expect false, got isOwner:%v", isOwner) + } + d.Stop() + + // d3 (not owner) stop + cli3 := clus.Client(3) + d3 := NewDDL(goctx.Background(), cli3, store, nil, nil, testLease, nil) + defer d3.Stop() + isOwner = checkOwner(d3, false) + if isOwner { + t.Fatalf("expect false, got isOwner:%v", isOwner) + } + d3.Stop() + + // Cancel the owner context, there is no owner. + d1.Stop() + time.Sleep(time.Duration(tmpTTL+1) * time.Second) + session, err := concurrency.NewSession(cliRW) + if err != nil { + t.Fatalf("new session failed %v", err) + } + elec := concurrency.NewElection(session, DDLOwnerKey) + logPrefix := fmt.Sprintf("[ddl] %s ownerManager %s", DDLOwnerKey, "useless id") + logCtx := logutil.WithKeyValue(context.Background(), "owner info", logPrefix) + _, err = owner.GetOwnerInfo(goctx.Background(), logCtx, elec, "useless id") + if !terror.ErrorEqual(err, concurrency.ErrElectionNoLeader) { + t.Fatalf("get owner info result don't match, err %v", err) + } +} + +func deleteLeader(cli *clientv3.Client, prefixKey string) error { + session, err := concurrency.NewSession(cli) + if err != nil { + return errors.Trace(err) + } + defer session.Close() + elec := concurrency.NewElection(session, prefixKey) + resp, err := elec.Leader(goctx.Background()) + if err != nil { + return errors.Trace(err) + } + _, err = cli.Delete(goctx.Background(), string(resp.Kvs[0].Key)) + return errors.Trace(err) +} From bae34b12f82befc78977cf84851f1a1ff5e9d97a Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 13 Jun 2019 13:08:44 +0800 Subject: [PATCH 2/3] owner: update --- owner/c.out | 100 ------------------------------------------ owner/manager_test.go | 2 +- 2 files changed, 1 insertion(+), 101 deletions(-) delete mode 100644 owner/c.out diff --git a/owner/c.out b/owner/c.out deleted file mode 100644 index fe07b240f8577..0000000000000 --- a/owner/c.out +++ /dev/null @@ -1,100 +0,0 @@ -mode: set -github.com/pingcap/tidb/owner/manager.go:90.107,101.2 2 1 -github.com/pingcap/tidb/owner/manager.go:104.36,106.2 1 0 -github.com/pingcap/tidb/owner/manager.go:109.39,111.2 1 1 -github.com/pingcap/tidb/owner/manager.go:114.33,116.2 1 1 -github.com/pingcap/tidb/owner/manager.go:122.35,124.22 2 1 -github.com/pingcap/tidb/owner/manager.go:127.2,128.16 2 0 -github.com/pingcap/tidb/owner/manager.go:131.2,132.12 2 0 -github.com/pingcap/tidb/owner/manager.go:124.22,126.3 1 1 -github.com/pingcap/tidb/owner/manager.go:128.16,130.3 1 0 -github.com/pingcap/tidb/owner/manager.go:136.131,141.32 4 1 -github.com/pingcap/tidb/owner/manager.go:176.2,176.39 1 1 -github.com/pingcap/tidb/owner/manager.go:141.32,142.46 1 1 -github.com/pingcap/tidb/owner/manager.go:146.3,146.61 1 1 -github.com/pingcap/tidb/owner/manager.go:154.3,154.59 1 1 -github.com/pingcap/tidb/owner/manager.go:162.3,166.17 4 1 -github.com/pingcap/tidb/owner/manager.go:169.3,169.36 1 0 -github.com/pingcap/tidb/owner/manager.go:173.3,174.14 2 0 -github.com/pingcap/tidb/owner/manager.go:142.46,144.4 1 1 -github.com/pingcap/tidb/owner/manager.go:146.61,147.18 1 0 -github.com/pingcap/tidb/owner/manager.go:147.18,148.43 1 0 -github.com/pingcap/tidb/owner/manager.go:148.43,150.6 1 0 -github.com/pingcap/tidb/owner/manager.go:154.59,155.18 1 0 -github.com/pingcap/tidb/owner/manager.go:155.18,156.62 1 0 -github.com/pingcap/tidb/owner/manager.go:156.62,158.6 1 0 -github.com/pingcap/tidb/owner/manager.go:166.17,167.9 1 1 -github.com/pingcap/tidb/owner/manager.go:169.36,171.4 1 0 -github.com/pingcap/tidb/owner/manager.go:180.65,183.16 3 1 -github.com/pingcap/tidb/owner/manager.go:186.2,187.12 2 1 -github.com/pingcap/tidb/owner/manager.go:183.16,185.3 1 1 -github.com/pingcap/tidb/owner/manager.go:191.63,193.17 2 0 -github.com/pingcap/tidb/owner/manager.go:197.2,200.16 4 0 -github.com/pingcap/tidb/owner/manager.go:204.2,205.12 2 0 -github.com/pingcap/tidb/owner/manager.go:193.17,195.3 1 0 -github.com/pingcap/tidb/owner/manager.go:200.16,202.3 1 0 -github.com/pingcap/tidb/owner/manager.go:208.62,210.2 1 1 -github.com/pingcap/tidb/owner/manager.go:213.38,215.2 1 1 -github.com/pingcap/tidb/owner/manager.go:217.92,220.15 3 1 -github.com/pingcap/tidb/owner/manager.go:229.2,232.6 4 1 -github.com/pingcap/tidb/owner/manager.go:220.15,222.31 2 1 -github.com/pingcap/tidb/owner/manager.go:222.31,226.4 3 0 -github.com/pingcap/tidb/owner/manager.go:232.6,233.17 1 1 -github.com/pingcap/tidb/owner/manager.go:237.3,237.10 1 1 -github.com/pingcap/tidb/owner/manager.go:256.3,256.56 1 1 -github.com/pingcap/tidb/owner/manager.go:264.3,266.17 3 1 -github.com/pingcap/tidb/owner/manager.go:271.3,272.17 2 1 -github.com/pingcap/tidb/owner/manager.go:276.3,281.50 5 1 -github.com/pingcap/tidb/owner/manager.go:233.17,235.4 1 1 -github.com/pingcap/tidb/owner/manager.go:238.29,242.18 4 1 -github.com/pingcap/tidb/owner/manager.go:247.21,250.10 3 1 -github.com/pingcap/tidb/owner/manager.go:251.11,251.11 0 1 -github.com/pingcap/tidb/owner/manager.go:242.18,246.5 3 1 -github.com/pingcap/tidb/owner/manager.go:256.56,257.26 1 0 -github.com/pingcap/tidb/owner/manager.go:261.4,261.12 1 0 -github.com/pingcap/tidb/owner/manager.go:257.26,260.5 2 0 -github.com/pingcap/tidb/owner/manager.go:266.17,268.12 2 1 -github.com/pingcap/tidb/owner/manager.go:272.17,273.12 1 0 -github.com/pingcap/tidb/owner/manager.go:285.82,293.2 4 1 -github.com/pingcap/tidb/owner/manager.go:296.72,298.16 2 1 -github.com/pingcap/tidb/owner/manager.go:301.2,301.24 1 1 -github.com/pingcap/tidb/owner/manager.go:304.2,304.39 1 0 -github.com/pingcap/tidb/owner/manager.go:298.16,300.3 1 0 -github.com/pingcap/tidb/owner/manager.go:301.24,303.3 1 1 -github.com/pingcap/tidb/owner/manager.go:308.103,310.16 2 1 -github.com/pingcap/tidb/owner/manager.go:315.2,317.19 3 1 -github.com/pingcap/tidb/owner/manager.go:322.2,322.37 1 1 -github.com/pingcap/tidb/owner/manager.go:310.16,314.3 2 1 -github.com/pingcap/tidb/owner/manager.go:317.19,320.3 2 0 -github.com/pingcap/tidb/owner/manager.go:325.102,330.6 5 1 -github.com/pingcap/tidb/owner/manager.go:330.6,331.10 1 1 -github.com/pingcap/tidb/owner/manager.go:332.30,333.11 1 1 -github.com/pingcap/tidb/owner/manager.go:338.4,338.21 1 1 -github.com/pingcap/tidb/owner/manager.go:344.4,344.35 1 1 -github.com/pingcap/tidb/owner/manager.go:351.29,353.10 2 1 -github.com/pingcap/tidb/owner/manager.go:354.21,356.10 2 1 -github.com/pingcap/tidb/owner/manager.go:333.11,337.5 3 0 -github.com/pingcap/tidb/owner/manager.go:338.21,342.5 3 0 -github.com/pingcap/tidb/owner/manager.go:344.35,345.33 1 1 -github.com/pingcap/tidb/owner/manager.go:345.33,349.6 3 1 -github.com/pingcap/tidb/owner/manager.go:361.13,363.16 2 1 -github.com/pingcap/tidb/owner/manager.go:363.16,365.3 1 0 -github.com/pingcap/tidb/owner/manager.go:368.56,369.9 1 1 -github.com/pingcap/tidb/owner/manager.go:377.2,379.53 1 1 -github.com/pingcap/tidb/owner/manager.go:383.2,383.12 1 1 -github.com/pingcap/tidb/owner/manager.go:370.20,371.33 1 1 -github.com/pingcap/tidb/owner/manager.go:372.10,372.10 0 1 -github.com/pingcap/tidb/owner/manager.go:379.53,381.3 1 0 -github.com/pingcap/tidb/owner/mock.go:35.67,40.2 1 0 -github.com/pingcap/tidb/owner/mock.go:43.35,45.2 1 0 -github.com/pingcap/tidb/owner/mock.go:48.38,50.2 1 0 -github.com/pingcap/tidb/owner/mock.go:52.35,54.2 1 0 -github.com/pingcap/tidb/owner/mock.go:57.37,59.2 1 0 -github.com/pingcap/tidb/owner/mock.go:62.32,64.2 1 0 -github.com/pingcap/tidb/owner/mock.go:67.71,68.17 1 0 -github.com/pingcap/tidb/owner/mock.go:71.2,71.35 1 0 -github.com/pingcap/tidb/owner/mock.go:68.17,70.3 1 0 -github.com/pingcap/tidb/owner/mock.go:75.62,78.2 2 0 -github.com/pingcap/tidb/owner/mock.go:81.62,82.17 1 0 -github.com/pingcap/tidb/owner/mock.go:85.2,85.12 1 0 -github.com/pingcap/tidb/owner/mock.go:82.17,84.3 1 0 diff --git a/owner/manager_test.go b/owner/manager_test.go index 21cb1652af188..a83e4dc699352 100644 --- a/owner/manager_test.go +++ b/owner/manager_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 PingCAP, Inc. +// Copyright 2019 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From e244943615a32faf57cce8ae6691fb8b996c4ec8 Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 13 Jun 2019 13:35:15 +0800 Subject: [PATCH 3/3] owner: tiny update --- owner/fail_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/owner/fail_test.go b/owner/fail_test.go index 1033d8d8e1380..71955ad99509a 100644 --- a/owner/fail_test.go +++ b/owner/fail_test.go @@ -75,6 +75,7 @@ func (s *testSuite) TestFailNewSession(c *C) { if cli != nil { cli.Close() } + c.Assert(failpoint.Disable("github.com/pingcap/tidb/owner/closeClient"), IsNil) }() c.Assert(failpoint.Enable("github.com/pingcap/tidb/owner/closeClient", `return(true)`), IsNil) _, err = NewSession(context.Background(), "fail_new_serssion", cli, retryCnt, ManagerSessionTTL) @@ -92,6 +93,7 @@ func (s *testSuite) TestFailNewSession(c *C) { if cli != nil { cli.Close() } + c.Assert(failpoint.Disable("github.com/pingcap/tidb/owner/closeGrpc"), IsNil) }() c.Assert(failpoint.Enable("github.com/pingcap/tidb/owner/closeGrpc", `return(true)`), IsNil) _, err = NewSession(context.Background(), "fail_new_serssion", cli, retryCnt, ManagerSessionTTL)