Skip to content

Commit 494d29c

Browse files
authored
Merge pull request ceph#56922 from ifed01/wip-ifed-store-test-no-sleeps
test/store_test: get rid off sleep() call wherever possible Reviewed-by: Pere Diaz Bou <[email protected]>
2 parents ef1d00c + 888cd79 commit 494d29c

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
@@ -10118,6 +10118,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) {
1011810118
bstore->mount();
1011910119
ghobject_t hoid4 = make_object("Object 4", pool);
1012010120
auto ch = store->open_collection(cid);
10121+
C_SaferCond c;
1012110122
{
1012210123
bufferlist bl;
1012310124
string s(0x1000, 'a');
@@ -10126,10 +10127,11 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairTest) {
1012610127
for(size_t i = 0; i < 0x10; i++) {
1012710128
t.write(cid, hoid4, i * bl.length(), bl.length(), bl);
1012810129
}
10129-
r = queue_transaction(store, ch, std::move(t));
10130+
t.register_on_commit(&c);
10131+
queue_transaction(store, ch, std::move(t));
1013010132
ASSERT_EQ(r, 0);
1013110133
}
10132-
sleep(5);
10134+
c.wait();
1013310135
{
1013410136
bstore->inject_zombie_spanning_blob(cid, hoid4, 12345);
1013510137
bstore->inject_zombie_spanning_blob(cid, hoid4, 23456);
@@ -10234,22 +10236,24 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenZombieRepairTest) {
1023410236
ASSERT_EQ(r, 0);
1023510237
}
1023610238
cerr << "onode preparing" << std::endl;
10239+
C_SaferCond c[col_count];
1023710240
bufferlist bl;
1023810241
string s(0x1000, 'a');
1023910242
bl.append(s);
10240-
1024110243
for (size_t i = 0; i < col_count; i++) {
10244+
ObjectStore::Transaction t;
1024210245
for (size_t j = 0; j < obj_count; j++) {
10243-
ObjectStore::Transaction t;
1024410246
t.write(*cid[i], hoid[i][j], bl.length(), bl.length(), bl);
10245-
r = queue_transaction(store, ch[i], std::move(t));
10246-
ASSERT_EQ(r, 0);
1024710247
}
10248+
t.register_on_commit(&c[i]);
10249+
r = queue_transaction(store, ch[i], std::move(t));
10250+
ASSERT_EQ(r, 0);
10251+
}
10252+
for (size_t i = 0; i < col_count; i++) {
10253+
c[i].wait();
1024810254
}
1024910255
cerr << "Zombie spanning blob injection" << std::endl;
1025010256

10251-
sleep(5);
10252-
1025310257
for (size_t i = 0; i < col_count; i++) {
1025410258
for (size_t j = 0; j < obj_count; j++) {
1025510259
bstore->inject_zombie_spanning_blob(*cid[i], hoid[i][j], 12345);
@@ -10398,15 +10402,17 @@ TEST_P(StoreTestSpecificAUSize, BluestoreBrokenNoSharedBlobRepairTest) {
1039810402
ASSERT_EQ(r, 0);
1039910403
}
1040010404
{
10405+
C_SaferCond c;
1040110406
ObjectStore::Transaction t;
1040210407
t.clone(cid, hoid, hoid_cloned);
10403-
r = queue_transaction(store, ch, std::move(t));
10408+
t.register_on_commit(&c);
10409+
queue_transaction(store, ch, std::move(t));
1040410410
ASSERT_EQ(r, 0);
10411+
c.wait();
1040510412
}
1040610413
}
1040710414
// injecting an error and checking
1040810415
cerr << "injecting" << std::endl;
10409-
sleep(3); // need some time for the previous write to land
1041010416
bstore->inject_no_shared_blob_key();
1041110417
bstore->inject_stray_shared_blob_key(12345678);
1041210418

0 commit comments

Comments
 (0)