mirror of
https://github.com/facebook/rocksdb.git
synced 2026-07-07 14:47:40 +08:00
Add MergeOperator UnitTest for Remote Compaction (#13683)
Summary: As title. Simple Unit Test to check MergeOperator in Remote Compaction flow. Pull Request resolved: https://github.com/facebook/rocksdb/pull/13683 Test Plan: ``` ./compaction_service_test --gtest_filter="*CompactionServiceTest.MergeOperator*" ``` Reviewed By: hx235 Differential Revision: D76459146 Pulled By: jaykorean fbshipit-source-id: 50956824d50c503e7166304a2d52f624bbdda7ec
This commit is contained in:
committed by
Facebook GitHub Bot
parent
37a26591c7
commit
873f7fe535
@@ -7,6 +7,7 @@
|
||||
#include "port/stack_trace.h"
|
||||
#include "rocksdb/utilities/options_util.h"
|
||||
#include "table/unique_id_impl.h"
|
||||
#include "utilities/merge_operators/string_append/stringappend.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
@@ -1222,6 +1223,32 @@ TEST_F(CompactionServiceTest, CompactionFilter) {
|
||||
ASSERT_GE(my_cs->GetCompactionNum(), 1);
|
||||
}
|
||||
|
||||
TEST_F(CompactionServiceTest, MergeOperator) {
|
||||
Options options = CurrentOptions();
|
||||
options.merge_operator.reset(new StringAppendOperator(','));
|
||||
ReopenWithCompactionService(&options);
|
||||
GenerateTestData();
|
||||
ASSERT_OK(dbfull()->TEST_WaitForCompact());
|
||||
for (int i = 0; i < 200; i++) {
|
||||
ASSERT_OK(db_->Merge(WriteOptions(), Key(i),
|
||||
"merge_op_append_" + std::to_string(i)));
|
||||
}
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
// verify result
|
||||
for (int i = 0; i < 200; i++) {
|
||||
auto result = Get(Key(i));
|
||||
if (i % 2) {
|
||||
ASSERT_EQ(result, "value" + std::to_string(i) + ",merge_op_append_" +
|
||||
std::to_string(i));
|
||||
} else {
|
||||
ASSERT_EQ(result, "value_new" + std::to_string(i) + ",merge_op_append_" +
|
||||
std::to_string(i));
|
||||
}
|
||||
}
|
||||
auto my_cs = GetCompactionService();
|
||||
ASSERT_GE(my_cs->GetCompactionNum(), 1);
|
||||
}
|
||||
|
||||
TEST_F(CompactionServiceTest, Snapshot) {
|
||||
Options options = CurrentOptions();
|
||||
ReopenWithCompactionService(&options);
|
||||
|
||||
Reference in New Issue
Block a user