return RUN_ALL_TESTS();
}
+using namespace std::literals;
class mClockSchedulerTest : public testing::Test {
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)
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());
+}