]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/allocator_test: additional coverage for get_fragmentation_score
authorIgor Fedotov <ifedotov@suse.com>
Mon, 19 Aug 2019 11:39:31 +0000 (14:39 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Sat, 25 Jul 2020 10:55:22 +0000 (13:55 +0300)
Tests the function results agains the same cases as we do for
get_fragmentation.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 6ae213181433dd2ae392d8eed85c2606b9c4bb54)

src/test/objectstore/Allocator_test.cc

index f66c7bc3d29f30ae6bf3a1e520d76038b5af52d8..60ccd95174a862c55e45c025bf120a3e746c8cfc 100644 (file)
@@ -272,6 +272,8 @@ TEST_P(AllocTest, test_alloc_fragmentation)
     alloc->release(release_set);
   }
   EXPECT_EQ(1.0, alloc->get_fragmentation(alloc_unit));
+  EXPECT_EQ(66u, uint64_t(alloc->get_fragmentation_score() * 100));
+
   for (size_t i = 1; i < allocated.size() / 2; i += 2)
   {
     interval_set<uint64_t> release_set;
@@ -285,6 +287,7 @@ TEST_P(AllocTest, test_alloc_fragmentation)
     // fragmentation approx = 257 intervals / 768 max intervals
     EXPECT_EQ(33u, uint64_t(alloc->get_fragmentation(alloc_unit) * 100));
   }
+  EXPECT_EQ(27u, uint64_t(alloc->get_fragmentation_score() * 100));
 
   for (size_t i = allocated.size() / 2 + 1; i < allocated.size(); i += 2)
   {
@@ -297,6 +300,11 @@ TEST_P(AllocTest, test_alloc_fragmentation)
   // Hence leaving just two 
   // digits after decimal point due to this.
   EXPECT_EQ(0u, uint64_t(alloc->get_fragmentation(alloc_unit) * 100));
+  if (bitmap_alloc) {
+    EXPECT_EQ(0u, uint64_t(alloc->get_fragmentation_score() * 100));
+  } else {
+    EXPECT_EQ(11u, uint64_t(alloc->get_fragmentation_score() * 100));
+  }
 }
 
 TEST_P(AllocTest, test_dump_fragmentation_score)
@@ -314,6 +322,7 @@ TEST_P(AllocTest, test_dump_fragmentation_score)
   alloc->init_add_free(0, capacity);
 
   EXPECT_EQ(0.0, alloc->get_fragmentation(alloc_unit));
+  EXPECT_EQ(0.0, alloc->get_fragmentation_score());
 
   uint64_t allocated_cnt = 0;
   for (size_t round = 0; round < rounds ; round++) {