Skip to content

Commit 888cd79

Browse files
committed
test/store_test: get rid off sleep() call wherever possible
Signed-off-by: Igor Fedotov <[email protected]>
1 parent cde67a7 commit 888cd79

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/test/objectstore/store_test.cc

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9662,6 +9662,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) {
96629662
bstore->mount();
96639663
ghobject_t hoid4 = make_object("Object 4", pool);
96649664
auto ch = store->open_collection(cid);
9665+
C_SaferCond c;
96659666
{
96669667
bufferlist bl;
96679668
string s(0x1000, 'a');
@@ -9670,10 +9671,11 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) {
96709671
for(size_t i = 0; i < 0x10; i++) {
96719672
t.write(cid, hoid4, i * bl.length(), bl.length(), bl);
96729673
}
9673-
r = queue_transaction(store, ch, std::move(t));
9674+
t.register_on_commit(&c);
9675+
queue_transaction(store, ch, std::move(t));
96749676
ASSERT_EQ(r, 0);
96759677
}
9676-
sleep(5);
9678+
c.wait();
96779679
{
96789680
bstore->inject_zombie_spanning_blob(cid, hoid4, 12345);
96799681
bstore->inject_zombie_spanning_blob(cid, hoid4, 23456);
@@ -9777,22 +9779,24 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenZombieRepairTest) {
97779779
ASSERT_EQ(r, 0);
97789780
}
97799781
cerr << "onode preparing" << std::endl;
9782+
C_SaferCond c[col_count];
97809783
bufferlist bl;
97819784
string s(0x1000, 'a');
97829785
bl.append(s);
9783-
97849786
for (size_t i = 0; i < col_count; i++) {
9787+
ObjectStore::Transaction t;
97859788
for (size_t j = 0; j < obj_count; j++) {
9786-
ObjectStore::Transaction t;
97879789
t.write(*cid[i], hoid[i][j], bl.length(), bl.length(), bl);
9788-
r = queue_transaction(store, ch[i], std::move(t));
9789-
ASSERT_EQ(r, 0);
97909790
}
9791+
t.register_on_commit(&c[i]);
9792+
r = queue_transaction(store, ch[i], std::move(t));
9793+
ASSERT_EQ(r, 0);
9794+
}
9795+
for (size_t i = 0; i < col_count; i++) {
9796+
c[i].wait();
97919797
}
97929798
cerr << "Zombie spanning blob injection" << std::endl;
97939799

9794-
sleep(5);
9795-
97969800
for (size_t i = 0; i < col_count; i++) {
97979801
for (size_t j = 0; j < obj_count; j++) {
97989802
bstore->inject_zombie_spanning_blob(*cid[i], hoid[i][j], 12345);
@@ -9922,15 +9926,17 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenNoSharedBlobRepairTest) {
99229926
ASSERT_EQ(r, 0);
99239927
}
99249928
{
9929+
C_SaferCond c;
99259930
ObjectStore::Transaction t;
99269931
t.clone(cid, hoid, hoid_cloned);
9927-
r = queue_transaction(store, ch, std::move(t));
9932+
t.register_on_commit(&c);
9933+
queue_transaction(store, ch, std::move(t));
99289934
ASSERT_EQ(r, 0);
9935+
c.wait();
99299936
}
99309937
}
99319938
// injecting an error and checking
99329939
cerr << "injecting" << std::endl;
9933-
sleep(3); // need some time for the previous write to land
99349940
bstore->inject_no_shared_blob_key();
99359941
bstore->inject_stray_shared_blob_key(12345678);
99369942

0 commit comments

Comments
 (0)