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; return;
} }
ASSERT_OK(SetupTestEnv()); ASSERT_OK(SetupTestEnv());
Write("small"); Random rnd(301);
Write(BigString("medium", 50000)); const std::vector<std::string> wal_entries = {
Write(BigString("large", 100000)); "small",
ASSERT_EQ("small", Read()); rnd.RandomBinaryString(3 * kBlockSize / 2), // Spans into block 2
ASSERT_EQ(BigString("medium", 50000), Read()); rnd.RandomBinaryString(3 * kBlockSize), // Spans into block 5
ASSERT_EQ(BigString("large", 100000), Read()); };
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()); ASSERT_EQ("EOF", Read());
} }

Loading…
Cancel
Save