summaryrefslogtreecommitdiffstats
path: root/src/test/objectstore/TestRocksdbOptionParse.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/test/objectstore/TestRocksdbOptionParse.cc
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/objectstore/TestRocksdbOptionParse.cc')
-rw-r--r--src/test/objectstore/TestRocksdbOptionParse.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/test/objectstore/TestRocksdbOptionParse.cc b/src/test/objectstore/TestRocksdbOptionParse.cc
new file mode 100644
index 00000000..c2b08735
--- /dev/null
+++ b/src/test/objectstore/TestRocksdbOptionParse.cc
@@ -0,0 +1,74 @@
+#include <gtest/gtest.h>
+#include "include/Context.h"
+#include "rocksdb/db.h"
+#include "rocksdb/env.h"
+#include "rocksdb/thread_status.h"
+#include "kv/RocksDBStore.h"
+#include <iostream>
+
+using namespace std;
+
+const string dir("rocksdb.test_temp_dir");
+
+TEST(RocksDBOption, simple) {
+ rocksdb::Options options;
+ rocksdb::Status status;
+ map<string,string> kvoptions;
+ RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, kvoptions, NULL);
+ string options_string = ""
+ "write_buffer_size=536870912;"
+ "create_if_missing=true;"
+ "max_write_buffer_number=4;"
+ "max_background_compactions=4;"
+ "stats_dump_period_sec = 5;"
+ "min_write_buffer_number_to_merge = 2;"
+ "level0_file_num_compaction_trigger = 4;"
+ "max_bytes_for_level_base = 104857600;"
+ "target_file_size_base = 10485760;"
+ "num_levels = 3;"
+ "compression = kNoCompression;";
+ int r = db->ParseOptionsFromString(options_string, options);
+ ASSERT_EQ(0, r);
+ ASSERT_EQ(536870912u, options.write_buffer_size);
+ ASSERT_EQ(4, options.max_write_buffer_number);
+ ASSERT_EQ(4, options.max_background_compactions);
+ ASSERT_EQ(5u, options.stats_dump_period_sec);
+ ASSERT_EQ(2, options.min_write_buffer_number_to_merge);
+ ASSERT_EQ(4, options.level0_file_num_compaction_trigger);
+ ASSERT_EQ(104857600u, options.max_bytes_for_level_base);
+ ASSERT_EQ(10485760u, options.target_file_size_base);
+ ASSERT_EQ(3, options.num_levels);
+ ASSERT_EQ(rocksdb::kNoCompression, options.compression);
+}
+TEST(RocksDBOption, interpret) {
+ rocksdb::Options options;
+ rocksdb::Status status;
+ map<string,string> kvoptions;
+ RocksDBStore *db = new RocksDBStore(g_ceph_context, dir, kvoptions, NULL);
+ string options_string = "compact_on_mount = true; compaction_threads=10;flusher_threads=5;";
+
+ int r = db->ParseOptionsFromString(options_string, options);
+ ASSERT_EQ(0, r);
+ ASSERT_TRUE(db->compact_on_mount);
+ //check thread pool setting
+ options.env->SleepForMicroseconds(100000);
+ std::vector<rocksdb::ThreadStatus> thread_list;
+ status = options.env->GetThreadList(&thread_list);
+ ASSERT_TRUE(status.ok());
+
+ int num_high_pri_threads = 0;
+ int num_low_pri_threads = 0;
+ for (vector<rocksdb::ThreadStatus>::iterator it = thread_list.begin();
+ it!= thread_list.end();
+ ++it) {
+ if (it->thread_type == rocksdb::ThreadStatus::HIGH_PRIORITY)
+ num_high_pri_threads++;
+ if (it->thread_type == rocksdb::ThreadStatus::LOW_PRIORITY)
+ num_low_pri_threads++;
+ }
+ ASSERT_EQ(15u, thread_list.size());
+ //low pri threads is compaction_threads
+ ASSERT_EQ(10, num_low_pri_threads);
+ //high pri threads is flusher_threads
+ ASSERT_EQ(5, num_high_pri_threads);
+}