From d90b54df2f79db33f6c629f0f2f8ebdb67209799 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Thu, 17 Oct 2024 21:36:28 -0700 Subject: [PATCH] Fix read_io in dataservice test. Previous code can overflow the io_size, i.e remaining_io_size -= sub_io_size; where sub_io_size > remaining_io_size, and remaining_io_size is unsigned which will be a huge number, takes ages to finish. Signed-off-by: Xiaoxi Chen --- conanfile.py | 2 +- src/tests/test_data_service.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index 51d8e4923..0e7fa7d89 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.4.64" + version = "6.4.65" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/tests/test_data_service.cpp b/src/tests/test_data_service.cpp index 9592da475..0cb855752 100644 --- a/src/tests/test_data_service.cpp +++ b/src/tests/test_data_service.cpp @@ -446,7 +446,7 @@ class BlkDataServiceTest : public testing::Test { void read_io(uint32_t io_size) { auto remaining_io_size = io_size; while (remaining_io_size > 0) { - auto const bid = get_rand_blkid_to_read(io_size); + auto const bid = get_rand_blkid_to_read(remaining_io_size); if (!bid.is_valid()) { // didn't find any block to read, either write blk map is empty or // all blks are pending on free. @@ -456,6 +456,7 @@ class BlkDataServiceTest : public testing::Test { // every piece in bid is a single block, e.g. nblks = 1 auto const nbids = bid.num_pieces(); auto sub_io_size = nbids * inst().get_blk_size(); + HS_REL_ASSERT_LE(sub_io_size, remaining_io_size, "not expecting sub_io_size to exceed remaining_io_size"); // we pass crc from lambda becaues if there is any async_free_blk, the written blks in the blkcrc map will // be removed by the time read thenVlue is called; @@ -582,7 +583,7 @@ class BlkDataServiceTest : public testing::Test { auto nbids = io_size / inst().get_blk_size(); // number of blks to read; // nbids should not exceed max pieces that MultiBlkId can hold; - nbids = std::max(nbids, MultiBlkId::max_addln_pieces); + nbids = std::min(nbids, MultiBlkId::max_addln_pieces); // make sure skip + nbids are in the range of m_blk_crc_map; if (skip_nbids + nbids > m_blk_crc_map.size()) { skip_nbids = m_blk_crc_map.size() - nbids; }