@@ -174,19 +174,6 @@ class VolumeIOImpl {
174174 });
175175 }
176176
177- <<<<<<< HEAD
178- void verify_all_data () {
179- for (auto & [lba, data_pattern] : m_lba_data) {
180- auto buffer = iomanager.iobuf_alloc (512 , 4096 );
181- vol_interface_req_ptr req (new vol_interface_req{buffer, lba, 1 });
182-
183- auto vol_mgr = g_helper->inst ()->volume_manager ();
184- vol_mgr->read (m_vol_ptr, req).get ();
185- test_common::HBTestHelper::validate_data_buf (buffer, 4096 , data_pattern);
186- LOGDEBUG (" Verify data vol={} lba={} pattern={} {}" , m_vol_name, lba, data_pattern,
187- *r_cast< uint64_t * >(buffer));
188- iomanager.iobuf_free (buffer);
189- =======
190177 void read_and_verify (lba_t start_lba, uint32_t nlbas) {
191178 auto sz = nlbas * m_vol_ptr->info ()->page_size ;
192179 sisl::io_blob_safe read_blob (sz, 512 );
@@ -209,7 +196,7 @@ class VolumeIOImpl {
209196 }
210197 }
211198
212- void verify_data (uint64_t nlbas_per_io = 1 ) {
199+ void verify_all_data (uint64_t nlbas_per_io = 1 ) {
213200 auto start_lba = m_lba_data.begin ()->first ;
214201 auto max_lba = m_lba_data.rbegin ()->first ;
215202 verify_data (start_lba, max_lba, nlbas_per_io);
@@ -221,7 +208,6 @@ class VolumeIOImpl {
221208 auto num_lbas_this_round = std::min (nlbas_per_io, max_lba - lba);
222209 read_and_verify (lba, num_lbas_this_round);
223210 num_lbas_verified += num_lbas_this_round;
224- >>>>>>> read API implementation
225211 }
226212 LOGINFO (" Verified {} lbas for volume {}" , num_lbas_verified, m_vol_ptr->info ()->name );
227213 }
@@ -283,36 +269,34 @@ class VolumeIOTest : public ::testing::Test {
283269 LOGINFO (" IO completed" );
284270 }
285271
286- <<<<<<< HEAD
287- void verify_all_data (shared< VolumeIOImpl > vol_impl = nullptr ) {
288- if (vol_impl) {
289- vol_impl->verify_all_data ();
290- =======
291- void verify_data (shared< VolumeIOImpl > vol_impl = nullptr , uint64_t nlbas_per_io = 1 ) {
272+ void verify_all_data (shared< VolumeIOImpl > vol_impl = nullptr , uint64_t nlbas_per_io = 1 ) {
292273 if (vol_impl) {
293- vol_impl->verify_data (nlbas_per_io);
294- >>>>>>> read API implementation
274+ vol_impl->verify_all_data (nlbas_per_io);
295275 return ;
296276 }
297277
298278 for (auto & vol_impl : m_vols_impl) {
299- <<<<<<< HEAD
300- vol_impl->verify_all_data ();
279+ vol_impl->verify_all_data (nlbas_per_io);
301280 }
302281 }
303282
304283 void restart (int shutdown_delay) {
305284 g_helper->restart (shutdown_delay);
306285 for (auto & vol_impl : m_vols_impl) {
307286 vol_impl->reset ();
308- =======
309- vol_impl->verify_data (nlbas_per_io);
310- >>>>>>> read API implementation
311287 }
312288 }
313289
314290 std::vector< shared< VolumeIOImpl > >& volume_list () { return m_vols_impl; }
315291
292+ template < typename T >
293+ T get_random_number (T min, T max) {
294+ static std::random_device rd;
295+ static std::mt19937 gen (rd ());
296+ std::uniform_int_distribution< T > dis (min, max);
297+ return dis (gen);
298+ }
299+
316300private:
317301 std::vector< shared< VolumeIOImpl > > m_vols_impl;
318302};
@@ -333,34 +317,25 @@ TEST_F(VolumeIOTest, SingleVolumeWriteData) {
333317 restart (5 );
334318
335319 LOGINFO (" Verify data" );
336- <<<<<<< HEAD
337320 verify_all_data (vol);
338- =======
339- verify_data (vol, 30 /* nlbas_per_io */ );
340- >>>>>>> read API implementation
321+ // verify_data(vol, 30 /* nlbas_per_io */);
341322
342323 // Write and verify again on same LBA range to single volume multiple times.
343324 LOGINFO (" Write and verify data with num_iter={} start={} nblks={}" , num_iter, start_lba, nblks);
344325 for (uint32_t i = 0 ; i < num_iter; i++) {
345326 generate_io_single (vol, start_lba, nblks);
346327 }
347- <<<<<<< HEAD
348328
349- verify_all_data (vol);
350- =======
351- verify_data (vol);
352-
353- // verify random lba ranges
329+ verify_all_data (vol, 30 /* nlbas_per_io */ );
354330
355- >>>>>>> read API implementation
356331 LOGINFO (" SingleVolumeWriteData test done." );
357332}
358333
359334TEST_F (VolumeIOTest, SingleVolumeReadData) {
360335 // Write and verify fixed LBA range to single volume multiple times.
361336 auto vol = volume_list ().back ();
362- uint32_t nblks = 500 ;
363- lba_t start_lba = 1000 ;
337+ uint32_t nblks = 5000 ;
338+ lba_t start_lba = 500 ;
364339 uint32_t num_iter = 1 ;
365340 LOGINFO (" Write and verify data with num_iter={} start={} nblks={}" , num_iter, start_lba, nblks);
366341 for (uint32_t i = 0 ; i < num_iter; i++) {
@@ -371,7 +346,17 @@ TEST_F(VolumeIOTest, SingleVolumeReadData) {
371346 vol->verify_data (2000 , 3000 , 40 );
372347 vol->verify_data (800 , 1800 , 40 );
373348
374- LOGINFO (" SingleVolumeReadHoles test done." );
349+ // random reads
350+ num_iter = 100 ;
351+ for (uint32_t i = 0 ; i < num_iter; i++) {
352+ auto start_lba = get_random_number< lba_t >(0 , 10000 );
353+ auto nblks = get_random_number< uint32_t >(1 , 64 );
354+ auto no_lbas_per_io = get_random_number< uint64_t >(1 , 50 );
355+ LOGINFO (" iter {}: Read data start={} nblks={} no_lbas_per_io {}" , i, start_lba, nblks, no_lbas_per_io);
356+ vol->verify_data (start_lba, start_lba + nblks, no_lbas_per_io);
357+ }
358+
359+ LOGINFO (" SingleVolumeRead test done." );
375360}
376361
377362TEST_F (VolumeIOTest, MultipleVolumeWriteData) {
0 commit comments