From 8c92eb7dad1736889b9fc37f8969c9169f7fba79 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 13 Feb 2025 02:55:27 +0000 Subject: [PATCH] test/osd/TestMClockScheduler: add test for very slow dequeue Related: https://tracker.ceph.com/issues/61594 Signed-off-by: Samuel Just (cherry picked from commit b35589f7eb39e6bfabe7df1c55281f41925eca61) --- src/test/osd/TestMClockScheduler.cc | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/test/osd/TestMClockScheduler.cc b/src/test/osd/TestMClockScheduler.cc index 898817bb4c2..149dd58dbd5 100644 --- a/src/test/osd/TestMClockScheduler.cc +++ b/src/test/osd/TestMClockScheduler.cc @@ -24,6 +24,7 @@ int main(int argc, char **argv) { return RUN_ALL_TESTS(); } +using namespace std::literals; class mClockSchedulerTest : public testing::Test { public: @@ -49,7 +50,9 @@ public: monc(nullptr), init_perfcounter(true), q(g_ceph_context, whoami, num_shards, shard_id, is_rotational, - cutoff_priority, monc, init_perfcounter), + cutoff_priority, + 2ms, 2ms, 1ms, + monc, init_perfcounter), client1(1001), client2(9999), client3(100000001) @@ -263,3 +266,32 @@ TEST_F(mClockSchedulerTest, TestAllQueuesEnqueueDequeue) { ASSERT_TRUE(q.empty()); } + +const OpSchedulerItem *maybe_get_item(const WorkItem &item) +{ + return std::get_if(&item); +} + +TEST_F(mClockSchedulerTest, TestSlowDequeue) { + ASSERT_TRUE(q.empty()); + + // Insert ops into the mClock queue + unsigned i = 0; + for (; i < 100; ++i) { + q.enqueue(create_item(i, client1, op_scheduler_class::background_best_effort)); + std::this_thread::sleep_for(5ms); + } + for (; i < 200; ++i) { + q.enqueue(create_item(i, client2, op_scheduler_class::client)); + std::this_thread::sleep_for(5ms); + } + + i = 0; + for (; i < 200; ++i) { + ASSERT_FALSE(q.empty()); + auto item = q.dequeue(); + auto *wqi = maybe_get_item(item); + ASSERT_TRUE(wqi); + } + ASSERT_TRUE(q.empty()); +} -- 2.39.5