From: Igor Fedotov Date: Mon, 19 Aug 2019 11:39:31 +0000 (+0300) Subject: test/allocator_test: additional coverage for get_fragmentation_score X-Git-Tag: v14.2.11~31^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cca65bba2703320100faeebf6c9eae90d11a00e5;p=ceph.git test/allocator_test: additional coverage for get_fragmentation_score Tests the function results agains the same cases as we do for get_fragmentation. Signed-off-by: Igor Fedotov (cherry picked from commit 6ae213181433dd2ae392d8eed85c2606b9c4bb54) --- diff --git a/src/test/objectstore/Allocator_test.cc b/src/test/objectstore/Allocator_test.cc index f66c7bc3d29f..60ccd95174a8 100644 --- a/src/test/objectstore/Allocator_test.cc +++ b/src/test/objectstore/Allocator_test.cc @@ -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 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++) {