Fix some new usages of g_random

This commit is contained in:
A.J. Beamon 2019-05-23 09:23:27 -07:00
parent 603721e125
commit e5381e0612
4 changed files with 13 additions and 13 deletions

View File

@ -237,12 +237,12 @@ TEST_CASE("/flow/FlatBuffers/LeaderInfo") {
{
LeaderInfo in;
LeaderInfo out;
in.forward = g_random->coinflip();
in.changeID = g_random->randomUniqueID();
in.forward = deterministicRandom()->coinflip();
in.changeID = deterministicRandom()->randomUniqueID();
{
std::string rndString(g_random->randomInt(10, 400), 'x');
std::string rndString(deterministicRandom()->randomInt(10, 400), 'x');
for (auto& c : rndString) {
c = g_random->randomAlphaNumeric();
c = deterministicRandom()->randomAlphaNumeric();
}
in.serializedInfo = rndString;
}
@ -256,12 +256,12 @@ TEST_CASE("/flow/FlatBuffers/LeaderInfo") {
ASSERT(in.serializedInfo == out.serializedInfo);
}
LeaderInfo leaderInfo;
leaderInfo.forward = g_random->coinflip();
leaderInfo.changeID = g_random->randomUniqueID();
leaderInfo.forward = deterministicRandom()->coinflip();
leaderInfo.changeID = deterministicRandom()->randomUniqueID();
{
std::string rndString(g_random->randomInt(10, 400), 'x');
std::string rndString(deterministicRandom()->randomInt(10, 400), 'x');
for (auto& c : rndString) {
c = g_random->randomAlphaNumeric();
c = deterministicRandom()->randomAlphaNumeric();
}
leaderInfo.serializedInfo = rndString;
}

View File

@ -342,7 +342,7 @@ public:
// Either shrink self->files[1] to the size of self->files[0], or chop off fileShrinkBytes
int64_t maxShrink = pageFloor( std::max( self->files[1].size - desiredMaxFileSize, self->fileShrinkBytes ) );
if ((maxShrink > SERVER_KNOBS->DISK_QUEUE_MAX_TRUNCATE_BYTES) ||
(frivolouslyTruncate && g_random->random01() < 0.3)) {
(frivolouslyTruncate && deterministicRandom()->random01() < 0.3)) {
TEST(true); // Replacing DiskQueue file
TraceEvent("DiskQueueReplaceFile", self->dbgid).detail("Filename", self->files[1].f->getFilename()).detail("OldFileSize", self->files[1].size).detail("ElidedTruncateSize", maxShrink);
Reference<IAsyncFile> newFile = wait( replaceFile(self->files[1].f) );

View File

@ -490,9 +490,9 @@ TEST_CASE("/flow/FlatBuffers/VectorRef") {
TEST_CASE("/flow/FlatBuffers/Standalone") {
Standalone<VectorRef<StringRef>> vecIn;
auto numElements = g_random->randomInt(1, 20);
auto numElements = deterministicRandom()->randomInt(1, 20);
for (int i = 0; i < numElements; ++i) {
auto str = g_random->randomAlphaNumeric(g_random->randomInt(0, 30));
auto str = deterministicRandom()->randomAlphaNumeric(deterministicRandom()->randomInt(0, 30));
vecIn.push_back(vecIn.arena(), StringRef(vecIn.arena(), str));
}
Standalone<StringRef> value = ObjectWriter::toValue(vecIn);

View File

@ -257,7 +257,7 @@ TEST_CASE("/flow/FlatBuffers/ErrorOr") {
ASSERT(out.getError().code() == in.getError().code());
}
{
ErrorOr<uint32_t> in(g_random->randomUInt32());
ErrorOr<uint32_t> in(deterministicRandom()->randomUInt32());
ErrorOr<uint32_t> out;
ObjectWriter writer;
writer.serialize(in);
@ -282,7 +282,7 @@ TEST_CASE("/flow/FlatBuffers/Optional") {
ASSERT(!out.present());
}
{
Optional<uint32_t> in(g_random->randomUInt32());
Optional<uint32_t> in(deterministicRandom()->randomUInt32());
Optional<uint32_t> out;
ObjectWriter writer;
writer.serialize(in);