From 51c5dd54ba1a56a142bfcf4fc512a8994edba641 Mon Sep 17 00:00:00 2001 From: udi-speedb <106253580+udi-speedb@users.noreply.github.com> Date: Thu, 21 Sep 2023 12:44:58 +0300 Subject: [PATCH] Unit tests: Expose the disallow_trivial_move flag in MoveFilesToLevel utility (#678) --- HISTORY.md | 1 + db/db_test_util.cc | 9 ++++++--- db/db_test_util.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c243679fe1..fd2e43f8db 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ Fix RepeatableThread to work properly with on thread start callback feature (htt * Non-Blocking Manual Compaction (CompactRange()) - Support non-blocking manual compactions by setting a new CompactRangeOptions option (async_completion_cb). When set, the CompactRange() call will return control to the caller immediately. The manual compaction iteslf will be performed in an internally created thread. The manual compaction will ALWAYS call the specified callback upon completion and provide the completion status (#597). ### Enhancements +* Unit Testing: Expose the disallow_trivial_move flag in the MoveFilesToLevel testing utility (#677). ### Bug Fixes * db_bench: fix SeekRandomWriteRandom valid check. Use key and value only after checking iterator is valid. diff --git a/db/db_test_util.cc b/db/db_test_util.cc index 01c2f78926..c5c929a022 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -1293,12 +1293,15 @@ void DBTestBase::FillLevels(const std::string& smallest, MakeTables(db_->NumberLevels(handles_[cf]), smallest, largest, cf); } -void DBTestBase::MoveFilesToLevel(int level, int cf) { +void DBTestBase::MoveFilesToLevel(int level, int cf, + bool disallow_trivial_move) { for (int l = 0; l < level; ++l) { if (cf > 0) { - EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr, handles_[cf])); + EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr, handles_[cf], + disallow_trivial_move)); } else { - EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr)); + EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr, nullptr, + disallow_trivial_move)); } } } diff --git a/db/db_test_util.h b/db/db_test_util.h index 8d5efa4df9..408373de8a 100644 --- a/db/db_test_util.h +++ b/db/db_test_util.h @@ -1255,7 +1255,8 @@ class DBTestBase : public testing::Test { void FillLevels(const std::string& smallest, const std::string& largest, int cf); - void MoveFilesToLevel(int level, int cf = 0); + void MoveFilesToLevel(int level, int cf = 0, + bool disallow_trivial_move = false); void DumpFileCounts(const char* label);