add unit test
This commit is contained in:
parent
87640673f7
commit
7855dc70f2
|
@ -5651,6 +5651,62 @@ public:
|
|||
|
||||
return Void();
|
||||
}
|
||||
|
||||
ACTOR static Future<Void> GetTeam_DeprioritizeWigglePausedTeam() {
|
||||
Reference<IReplicationPolicy> policy = Reference<IReplicationPolicy>(
|
||||
new PolicyAcross(3, "zoneid", Reference<IReplicationPolicy>(new PolicyOne())));
|
||||
state int processSize = 5;
|
||||
state int teamSize = 3;
|
||||
state std::unique_ptr<DDTeamCollection> collection = testTeamCollection(teamSize, policy, processSize);
|
||||
GetStorageMetricsReply mid_avail;
|
||||
mid_avail.capacity.bytes = 1000 * 1024 * 1024;
|
||||
mid_avail.available.bytes = 400 * 1024 * 1024;
|
||||
mid_avail.load.bytes = 100 * 1024 * 1024;
|
||||
|
||||
GetStorageMetricsReply high_avail;
|
||||
high_avail.capacity.bytes = 1000 * 1024 * 1024;
|
||||
high_avail.available.bytes = 800 * 1024 * 1024;
|
||||
high_avail.load.bytes = 90 * 1024 * 1024;
|
||||
|
||||
collection->addTeam(std::set<UID>({ UID(1, 0), UID(2, 0), UID(3, 0) }), true);
|
||||
collection->addTeam(std::set<UID>({ UID(2, 0), UID(3, 0), UID(4, 0) }), true);
|
||||
collection->disableBuildingTeams();
|
||||
collection->setCheckTeamDelay();
|
||||
|
||||
/*
|
||||
* Among server teams that have healthy space available, pick the team that is
|
||||
* least utilized, if the caller says they preferLowerUtilization.
|
||||
*/
|
||||
|
||||
collection->server_info[UID(1, 0)]->setMetrics(mid_avail);
|
||||
collection->server_info[UID(2, 0)]->setMetrics(high_avail);
|
||||
collection->server_info[UID(3, 0)]->setMetrics(high_avail);
|
||||
collection->server_info[UID(4, 0)]->setMetrics(high_avail);
|
||||
|
||||
collection->wigglingId = UID(4, 0);
|
||||
collection->pauseWiggle = makeReference<AsyncVar<bool>>(true);
|
||||
|
||||
bool wantsNewServers = true;
|
||||
bool wantsTrueBest = true;
|
||||
bool preferLowerUtilization = true;
|
||||
bool teamMustHaveShards = false;
|
||||
std::vector<UID> completeSources{ UID(1, 0), UID(2, 0), UID(3, 0) };
|
||||
|
||||
state GetTeamRequest req(wantsNewServers, wantsTrueBest, preferLowerUtilization, teamMustHaveShards);
|
||||
req.completeSources = completeSources;
|
||||
|
||||
wait(collection->getTeam(req));
|
||||
|
||||
std::pair<Optional<Reference<IDataDistributionTeam>>, bool> resTeam = req.reply.getFuture().get();
|
||||
|
||||
std::set<UID> expectedServers{ UID(1, 0), UID(2, 0), UID(3, 0) };
|
||||
ASSERT(resTeam.first.present());
|
||||
auto servers = resTeam.first.get()->getServerIDs();
|
||||
const std::set<UID> selectedServers(servers.begin(), servers.end());
|
||||
ASSERT(expectedServers == selectedServers);
|
||||
|
||||
return Void();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("DataDistribution/AddTeamsBestOf/UseMachineID") {
|
||||
|
@ -5712,3 +5768,8 @@ TEST_CASE("/DataDistribution/GetTeam/ServerUtilizationNearCutoff") {
|
|||
wait(DDTeamCollectionUnitTest::GetTeam_ServerUtilizationNearCutoff());
|
||||
return Void();
|
||||
}
|
||||
|
||||
TEST_CASE("/DataDistribution/GetTeam/DeprioritizeWigglePausedTeam") {
|
||||
wait(DDTeamCollectionUnitTest::GetTeam_DeprioritizeWigglePausedTeam());
|
||||
return Void();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue