From: Igor Fedotov Date: Tue, 16 Apr 2024 13:00:42 +0000 (+0300) Subject: test/store_test: get rid off sleep() call wherever possible X-Git-Tag: testing/wip-rishabh-testing-20250414.181222-debug~3^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=888cd7955212e45759513c74f561cdc114ad9134;p=ceph-ci.git test/store_test: get rid off sleep() call wherever possible Signed-off-by: Igor Fedotov --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 4974fae125b..dfc84ac216f 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -9662,6 +9662,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) { bstore->mount(); ghobject_t hoid4 = make_object("Object 4", pool); auto ch = store->open_collection(cid); + C_SaferCond c; { bufferlist bl; string s(0x1000, 'a'); @@ -9670,10 +9671,11 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) { for(size_t i = 0; i < 0x10; i++) { t.write(cid, hoid4, i * bl.length(), bl.length(), bl); } - r = queue_transaction(store, ch, std::move(t)); + t.register_on_commit(&c); + queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); } - sleep(5); + c.wait(); { bstore->inject_zombie_spanning_blob(cid, hoid4, 12345); bstore->inject_zombie_spanning_blob(cid, hoid4, 23456); @@ -9777,22 +9779,24 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenZombieRepairTest) { ASSERT_EQ(r, 0); } cerr << "onode preparing" << std::endl; + C_SaferCond c[col_count]; bufferlist bl; string s(0x1000, 'a'); bl.append(s); - for (size_t i = 0; i < col_count; i++) { + ObjectStore::Transaction t; for (size_t j = 0; j < obj_count; j++) { - ObjectStore::Transaction t; t.write(*cid[i], hoid[i][j], bl.length(), bl.length(), bl); - r = queue_transaction(store, ch[i], std::move(t)); - ASSERT_EQ(r, 0); } + t.register_on_commit(&c[i]); + r = queue_transaction(store, ch[i], std::move(t)); + ASSERT_EQ(r, 0); + } + for (size_t i = 0; i < col_count; i++) { + c[i].wait(); } cerr << "Zombie spanning blob injection" << std::endl; - sleep(5); - for (size_t i = 0; i < col_count; i++) { for (size_t j = 0; j < obj_count; j++) { bstore->inject_zombie_spanning_blob(*cid[i], hoid[i][j], 12345); @@ -9922,15 +9926,17 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenNoSharedBlobRepairTest) { ASSERT_EQ(r, 0); } { + C_SaferCond c; ObjectStore::Transaction t; t.clone(cid, hoid, hoid_cloned); - r = queue_transaction(store, ch, std::move(t)); + t.register_on_commit(&c); + queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); + c.wait(); } } // injecting an error and checking cerr << "injecting" << std::endl; - sleep(3); // need some time for the previous write to land bstore->inject_no_shared_blob_key(); bstore->inject_stray_shared_blob_key(12345678);