Merge pull request #7603 from sfc-gh-ahusain/ahusain-fix-test
Fix snapshotFormatUnitTest infinite loop
This commit is contained in:
commit
2a0381f44d
|
@ -1216,6 +1216,8 @@ TEST_CASE("/blobgranule/files/snapshotFormatUnitTest") {
|
|||
std::unordered_set<std::string> usedKeys;
|
||||
Standalone<GranuleSnapshot> data;
|
||||
int totalDataBytes = 0;
|
||||
const int maxKeyGenAttempts = 1000;
|
||||
int nAttempts = 0;
|
||||
while (totalDataBytes < targetDataBytes) {
|
||||
int keySize = deterministicRandom()->randomInt(targetKeyLength / 2, targetKeyLength * 3 / 2);
|
||||
keySize = std::min(keySize, uidSize);
|
||||
|
@ -1232,6 +1234,13 @@ TEST_CASE("/blobgranule/files/snapshotFormatUnitTest") {
|
|||
|
||||
data.push_back_deep(data.arena(), KeyValueRef(KeyRef(key), ValueRef(value)));
|
||||
totalDataBytes += key.size() + value.size();
|
||||
nAttempts = 0;
|
||||
} else if (nAttempts > maxKeyGenAttempts) {
|
||||
// KeySpace exhausted, avoid infinite loop
|
||||
break;
|
||||
} else {
|
||||
// Keep exploring the KeySpace
|
||||
nAttempts++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue