Skip to content

Commit

Permalink
Testify the api and storage tests
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Jun 16, 2022
1 parent ee302fc commit baeac7c
Show file tree
Hide file tree
Showing 3 changed files with 317 additions and 348 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 baeac7c

Please sign in to comment.