]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/osd/TestMClockScheduler: add test for very slow dequeue
authorSamuel Just <sjust@redhat.com>
Thu, 13 Feb 2025 02:55:27 +0000 (02:55 +0000)
committerSamuel Just <sjust@redhat.com>
Tue, 18 Mar 2025 17:43:58 +0000 (17:43 +0000)
Related: https://tracker.ceph.com/issues/61594
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit b35589f7eb39e6bfabe7df1c55281f41925eca61)

src/test/osd/TestMClockScheduler.cc

index 807d1eb3ebcbd9fbf225289bc7f909987422f2c3..0579e97fa50dddf675216415fdfb0100bcff5916 100644 (file)
@@ -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<OpSchedulerItem>(&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());
+}