diff options
author | Adam Kupczyk <akupczyk@ibm.com> | 2023-10-10 11:04:39 +0200 |
---|---|---|
committer | Adam Kupczyk <akupczyk@ibm.com> | 2023-10-10 11:08:21 +0200 |
commit | f987b4daa097a84ca35db4037de1985fc0acaf01 (patch) | |
tree | eb56e8e9fced6f9c59ff1ff29f9d55ca5d4dddd8 /src/test/objectstore/test_kv.cc | |
parent | Merge pull request #53719 from rishabh-d-dave/mon-fscmds (diff) | |
download | ceph-f987b4daa097a84ca35db4037de1985fc0acaf01.tar.xz ceph-f987b4daa097a84ca35db4037de1985fc0acaf01.zip |
os/kv_test: Fix estimate functions
We need to use random content to estimate DB size.
Otherwise, compression will cause DB to be unreasonably small.
Fixes: https://tracker.ceph.com/issues/63121
Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
Diffstat (limited to 'src/test/objectstore/test_kv.cc')
-rw-r--r-- | src/test/objectstore/test_kv.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/test/objectstore/test_kv.cc b/src/test/objectstore/test_kv.cc index 33ffd6ab396..95c712ceffa 100644 --- a/src/test/objectstore/test_kv.cc +++ b/src/test/objectstore/test_kv.cc @@ -29,6 +29,14 @@ using namespace std; +std::string gen_random_string(size_t size) { + std::string s; + for (size_t i = 0; i < size; i++) { + s.push_back(rand()); + } + return s; +} + class KVTest : public ::testing::TestWithParam<const char*> { public: boost::scoped_ptr<KeyValueDB> db; @@ -556,10 +564,11 @@ TEST_P(KVTest, RocksDB_estimate_size) { for(int test = 0; test < 20; test++) { KeyValueDB::Transaction t = db->get_transaction(); - bufferlist v1; - v1.append(string(1000, '1')); - for (int i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { + bufferlist v1; + v1.append(gen_random_string(1000)); t->set("A", to_string(rand()%100000), v1); + } db->submit_transaction_sync(t); db->compact(); @@ -588,10 +597,11 @@ TEST_P(KVTest, RocksDB_estimate_size_column_family) { for(int test = 0; test < 20; test++) { KeyValueDB::Transaction t = db->get_transaction(); - bufferlist v1; - v1.append(string(1000, '1')); - for (int i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { + bufferlist v1; + v1.append(gen_random_string(1000)); t->set("cf1", to_string(rand()%100000), v1); + } db->submit_transaction_sync(t); db->compact(); |