@@ -24,6 +24,7 @@ int main(int argc, char **argv) {
2424 return RUN_ALL_TESTS ();
2525}
2626
27+ using namespace std ::literals;
2728
2829class mClockSchedulerTest : public testing ::Test {
2930public:
@@ -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