Skip to content

Commit b35589f

Browse files
committed
test/osd/TestMClockScheduler: add test for very slow dequeue
Related: https://tracker.ceph.com/issues/61594 Signed-off-by: Samuel Just <[email protected]>
1 parent 8b7b046 commit b35589f

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/test/osd/TestMClockScheduler.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int main(int argc, char **argv) {
2424
return RUN_ALL_TESTS();
2525
}
2626

27+
using namespace std::literals;
2728

2829
class mClockSchedulerTest : public testing::Test {
2930
public:
@@ -49,7 +50,9 @@ class mClockSchedulerTest : public testing::Test {
4950
monc(nullptr),
5051
init_perfcounter(true),
5152
q(g_ceph_context, whoami, num_shards, shard_id, is_rotational,
52-
cutoff_priority, monc, init_perfcounter),
53+
cutoff_priority,
54+
2ms, 2ms, 1ms,
55+
monc, init_perfcounter),
5356
client1(1001),
5457
client2(9999),
5558
client3(100000001)
@@ -263,3 +266,32 @@ TEST_F(mClockSchedulerTest, TestAllQueuesEnqueueDequeue) {
263266

264267
ASSERT_TRUE(q.empty());
265268
}
269+
270+
const OpSchedulerItem *maybe_get_item(const WorkItem &item)
271+
{
272+
return std::get_if<OpSchedulerItem>(&item);
273+
}
274+
275+
TEST_F(mClockSchedulerTest, TestSlowDequeue) {
276+
ASSERT_TRUE(q.empty());
277+
278+
// Insert ops into the mClock queue
279+
unsigned i = 0;
280+
for (; i < 100; ++i) {
281+
q.enqueue(create_item(i, client1, op_scheduler_class::background_best_effort));
282+
std::this_thread::sleep_for(5ms);
283+
}
284+
for (; i < 200; ++i) {
285+
q.enqueue(create_item(i, client2, op_scheduler_class::client));
286+
std::this_thread::sleep_for(5ms);
287+
}
288+
289+
i = 0;
290+
for (; i < 200; ++i) {
291+
ASSERT_FALSE(q.empty());
292+
auto item = q.dequeue();
293+
auto *wqi = maybe_get_item(item);
294+
ASSERT_TRUE(wqi);
295+
}
296+
ASSERT_TRUE(q.empty());
297+
}

0 commit comments

Comments
 (0)