Skip to content

Commit

Permalink
tests: testify the api and storage tests (#5166)
Browse files Browse the repository at this point in the history
ref #4813

Testify the api and storage tests.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
  • Loading branch information
JmPotato and ti-chi-bot authored Jun 17, 2022
1 parent 9acd56a commit cb23d6c
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 350 deletions.
34 changes: 0 additions & 34 deletions tests/pdctl/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sort"

"github.com/gogo/protobuf/proto"
"github.com/pingcap/check"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -105,20 +104,6 @@ func MustPutStore(re *require.Assertions, svr *server.Server, store *metapb.Stor
re.NoError(err)
}

// MustPutStoreWithCheck is a temporary function for test purpose.
func MustPutStoreWithCheck(c *check.C, svr *server.Server, store *metapb.Store) {
store.Address = fmt.Sprintf("tikv%d", store.GetId())
if len(store.Version) == 0 {
store.Version = versioninfo.MinSupportedVersion(versioninfo.Version2_0).String()
}
grpcServer := &server.GrpcServer{Server: svr}
_, err := grpcServer.PutStore(context.Background(), &pdpb.PutStoreRequest{
Header: &pdpb.RequestHeader{ClusterId: svr.ClusterID()},
Store: store,
})
c.Assert(err, check.IsNil)
}

// MustPutRegion is used for test purpose.
func MustPutRegion(re *require.Assertions, cluster *tests.TestCluster, regionID, storeID uint64, start, end []byte, opts ...core.RegionCreateOption) *core.RegionInfo {
leader := &metapb.Peer{
Expand All @@ -138,25 +123,6 @@ func MustPutRegion(re *require.Assertions, cluster *tests.TestCluster, regionID,
return r
}

// MustPutRegionWithCheck is a temporary function for test purpose.
func MustPutRegionWithCheck(c *check.C, cluster *tests.TestCluster, regionID, storeID uint64, start, end []byte, opts ...core.RegionCreateOption) *core.RegionInfo {
leader := &metapb.Peer{
Id: regionID,
StoreId: storeID,
}
metaRegion := &metapb.Region{
Id: regionID,
StartKey: start,
EndKey: end,
Peers: []*metapb.Peer{leader},
RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1},
}
r := core.NewRegionInfo(metaRegion, leader, opts...)
err := cluster.HandleRegionHeartbeat(r)
c.Assert(err, check.IsNil)
return r
}

func checkerWithNilAssert(re *require.Assertions) *assertutil.Checker {
checker := assertutil.NewChecker(func() {
re.FailNow("should be nil")
Expand Down
Loading

0 comments on commit cb23d6c

Please sign in to comment.