TeamCollection: Change 1 unit test

Relax the assert condition on the random unit test.
Due to the randomness in choosing the machine team and
the server team from the machine team, it is possible that
we may not find the remaining several (e.g., 1 or 2) available teams.
For example, there are at most 10 teams available, and we have found
9 teams, the chance of finding the last one is low
when we do pure random selection.

It is ok to not find every available team because
1) In reality, we only create a small fraction of available teams, and
2) In practical system, this situation only happens when most of servers
   are *temporarily* unhealthy. When this situation happens, we will
   abandon all existing teams and restart the build team from scratch.

In simulation test, the situation happens 100 times out of 128613 test cases
when we run RandomUnitTests.txt only.

Signed-off-by: Meng Xu <meng_xu@apple.com>
This commit is contained in:
Meng Xu 2018-11-30 23:46:50 -08:00
parent f311455c45
commit a43f579f66
1 changed files with 6 additions and 1 deletions

View File

@ -3485,6 +3485,9 @@ TEST_CASE("/DataDistribution/AddTeamsBestOf/SkippingBusyServers") {
return Void();
}
// Due to the randomness in choosing the machine team and the server team from the machine team, it is possible that
// we may not find the remaining several (e.g., 1 or 2) available teams.
// It is hard to conclude what is the minimum number of teams the addTeamsBestOf() should create in this situation.
TEST_CASE("/DataDistribution/AddTeamsBestOf/NotEnoughServers") {
wait(Future<Void>(Void()));
@ -3497,7 +3500,9 @@ TEST_CASE("/DataDistribution/AddTeamsBestOf/NotEnoughServers") {
int result = collection->addTeamsBestOf(10);
delete(collection);
ASSERT(result == 8);
// If we find all available teams, result will be 8 because we prebuild 2 teams
// ASSERT(result == 8);
ASSERT(result >= 4); //At least we should build half of the teams
return Void();
}