Fix WAL compression fragmentation test (#10402)

Summary:
Previously the "Fragmentation" test didn't cover fragmentation because the WAL data was compressible into trivial size. This PR changes it to use random data so the post-compression size is large enough to require fragmentation.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10402

Reviewed By: cbi42

Differential Revision: D38065596

Pulled By: ajkr

fbshipit-source-id: 0d5f89ca14d33546501a74b5d4fafbadc28a46a7
main
Andrew Kryczka 2 years ago committed by Facebook GitHub Bot
parent 5cf18c7634
commit 7b44724205
  1. 19
      db/log_test.cc

@ -960,12 +960,19 @@ TEST_P(CompressionLogTest, Fragmentation) {
return;
}
ASSERT_OK(SetupTestEnv());
Write("small");
Write(BigString("medium", 50000));
Write(BigString("large", 100000));
ASSERT_EQ("small", Read());
ASSERT_EQ(BigString("medium", 50000), Read());
ASSERT_EQ(BigString("large", 100000), Read());
Random rnd(301);
const std::vector<std::string> wal_entries = {
"small",
rnd.RandomBinaryString(3 * kBlockSize / 2), // Spans into block 2
rnd.RandomBinaryString(3 * kBlockSize), // Spans into block 5
};
for (const std::string& wal_entry : wal_entries) {
Write(wal_entry);
}
for (const std::string& wal_entry : wal_entries) {
ASSERT_EQ(wal_entry, Read());
}
ASSERT_EQ("EOF", Read());
}

Loading…
Cancel
Save