Skip to content

Commit

Permalink
pass ut
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Aug 7, 2023
1 parent 99fbc63 commit b2931c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions server/cluster/cluster_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cluster

import (
"context"
"github.com/tikv/pd/pkg/schedule"
"testing"

"github.com/pingcap/kvproto/pkg/metapb"
Expand Down Expand Up @@ -47,6 +48,7 @@ func TestReportSplit(t *testing.T) {
_, opt, err := newTestScheduleConfig()
re.NoError(err)
cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster())
cluster.coordinator = schedule.NewCoordinator(cluster.ctx, cluster, nil)
right := &metapb.Region{Id: 1, StartKey: []byte("a"), EndKey: []byte("c"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}),
RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1}}
region := core.NewRegionInfo(right, right.Peers[0])
Expand Down Expand Up @@ -104,12 +106,27 @@ func TestReportBatchSplit(t *testing.T) {
_, opt, err := newTestScheduleConfig()
re.NoError(err)
cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster())
cluster.coordinator = schedule.NewCoordinator(ctx, cluster, nil)
regions := []*metapb.Region{
{Id: 1, StartKey: []byte(""), EndKey: []byte("a"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3})},
{Id: 2, StartKey: []byte("a"), EndKey: []byte("b"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3})},
{Id: 3, StartKey: []byte("b"), EndKey: []byte("c"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3})},
{Id: 3, StartKey: []byte("c"), EndKey: []byte(""), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3})},
}
_, err = cluster.HandleBatchReportSplit(&pdpb.ReportBatchSplitRequest{Regions: regions})
re.Error(err)

meta := &metapb.Region{Id: 1, StartKey: []byte(""), EndKey: []byte(""), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}),
RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1}}
region := core.NewRegionInfo(meta, meta.Peers[0])
cluster.putRegion(region)

regions = []*metapb.Region{
{Id: 2, StartKey: []byte(""), EndKey: []byte("a"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}), RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 2}},
{Id: 3, StartKey: []byte("a"), EndKey: []byte("b"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}), RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 2}},
{Id: 4, StartKey: []byte("b"), EndKey: []byte("c"), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}), RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 2}},
{Id: 1, StartKey: []byte("c"), EndKey: []byte(""), Peers: mockRegionPeer(cluster, []uint64{1, 2, 3}), RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 2}},
}
_, err = cluster.HandleBatchReportSplit(&pdpb.ReportBatchSplitRequest{Regions: regions})
re.NoError(err)
}
1 change: 0 additions & 1 deletion server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ retryLoop:
select {
case <-ctx.Done():
break retryLoop

case <-time.After(10 * time.Millisecond):
}
}
Expand Down

0 comments on commit b2931c7

Please sign in to comment.