From: Samuel Just Date: Thu, 13 Feb 2025 02:55:27 +0000 (+0000) Subject: test/osd/TestMClockScheduler: add test for very slow dequeue X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8965d23ccb3a1ea23bf7ade2b45f727a4a82a4d4;p=ceph.git 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) --- diff --git a/src/test/osd/TestMClockScheduler.cc b/src/test/osd/TestMClockScheduler.cc index 807d1eb3ebcbd..0579e97fa50dd 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) @@ -259,3 +262,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()); +}