-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/simulator: Make simulator work with large scale cluster (tikv#8269
) close tikv#5683, ref tikv#8135 Signed-off-by: husharp <jinhao.hu@pingcap.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e8c05e0
commit 2baee83
Showing
8 changed files
with
232 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2024 TiKV Project Authors. | ||
// | ||
// 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, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cases | ||
|
||
import ( | ||
"github.com/docker/go-units" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/tikv/pd/pkg/core" | ||
sc "github.com/tikv/pd/tools/pd-simulator/simulator/config" | ||
"github.com/tikv/pd/tools/pd-simulator/simulator/info" | ||
"github.com/tikv/pd/tools/pd-simulator/simulator/simutil" | ||
) | ||
|
||
// newStableEnv provides a stable environment for test. | ||
func newStableEnv(config *sc.SimConfig) *Case { | ||
var simCase Case | ||
|
||
totalStore := config.TotalStore | ||
totalRegion := config.TotalRegion | ||
allStores := make(map[uint64]struct{}, totalStore) | ||
arrStoresID := make([]uint64, 0, totalStore) | ||
replica := int(config.ServerConfig.Replication.MaxReplicas) | ||
for i := 0; i < totalStore; i++ { | ||
id := simutil.IDAllocator.NextID() | ||
simCase.Stores = append(simCase.Stores, &Store{ | ||
ID: id, | ||
Status: metapb.StoreState_Up, | ||
}) | ||
allStores[id] = struct{}{} | ||
arrStoresID = append(arrStoresID, id) | ||
} | ||
|
||
for i := 0; i < totalRegion; i++ { | ||
peers := make([]*metapb.Peer, 0, replica) | ||
for j := 0; j < replica; j++ { | ||
peers = append(peers, &metapb.Peer{ | ||
Id: simutil.IDAllocator.NextID(), | ||
StoreId: arrStoresID[(i+j)%totalStore], | ||
}) | ||
} | ||
simCase.Regions = append(simCase.Regions, Region{ | ||
ID: simutil.IDAllocator.NextID(), | ||
Peers: peers, | ||
Leader: peers[0], | ||
Size: 96 * units.MiB, | ||
Keys: 960000, | ||
}) | ||
} | ||
|
||
simCase.Checker = func(_ []*metapb.Store, _ *core.RegionsInfo, _ []info.StoreStats) bool { | ||
return false | ||
} | ||
return &simCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.