mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
@@ -45,19 +45,19 @@ struct RPCWorkQueueTestBase : NoLoggerFixture {
|
||||
{"workers", ConfigValue{ConfigType::Integer}.defaultValue(4)}
|
||||
};
|
||||
|
||||
WorkQueue queue = WorkQueue::make_WorkQueue(cfg);
|
||||
WorkQueue queue = WorkQueue::makeWorkQueue(cfg);
|
||||
};
|
||||
|
||||
struct WorkQueueTest : WithPrometheus, RPCWorkQueueTestBase {};
|
||||
|
||||
TEST_F(WorkQueueTest, WhitelistedExecutionCountAddsUp)
|
||||
{
|
||||
auto constexpr static TOTAL = 512u;
|
||||
static constexpr auto kTOTAL = 512u;
|
||||
uint32_t executeCount = 0u;
|
||||
|
||||
std::mutex mtx;
|
||||
|
||||
for (auto i = 0u; i < TOTAL; ++i) {
|
||||
for (auto i = 0u; i < kTOTAL; ++i) {
|
||||
queue.postCoro(
|
||||
[&executeCount, &mtx](auto /* yield */) {
|
||||
std::lock_guard const lk(mtx);
|
||||
@@ -71,22 +71,22 @@ TEST_F(WorkQueueTest, WhitelistedExecutionCountAddsUp)
|
||||
|
||||
auto const report = queue.report();
|
||||
|
||||
EXPECT_EQ(executeCount, TOTAL);
|
||||
EXPECT_EQ(report.at("queued"), TOTAL);
|
||||
EXPECT_EQ(executeCount, kTOTAL);
|
||||
EXPECT_EQ(report.at("queued"), kTOTAL);
|
||||
EXPECT_EQ(report.at("current_queue_size"), 0);
|
||||
EXPECT_EQ(report.at("max_queue_size"), 2);
|
||||
}
|
||||
|
||||
TEST_F(WorkQueueTest, NonWhitelistedPreventSchedulingAtQueueLimitExceeded)
|
||||
{
|
||||
auto constexpr static TOTAL = 3u;
|
||||
static constexpr auto kTOTAL = 3u;
|
||||
auto expectedCount = 2u;
|
||||
auto unblocked = false;
|
||||
|
||||
std::mutex mtx;
|
||||
std::condition_variable cv;
|
||||
|
||||
for (auto i = 0u; i < TOTAL; ++i) {
|
||||
for (auto i = 0u; i < kTOTAL; ++i) {
|
||||
auto res = queue.postCoro(
|
||||
[&](auto /* yield */) {
|
||||
std::unique_lock lk{mtx};
|
||||
@@ -97,7 +97,7 @@ TEST_F(WorkQueueTest, NonWhitelistedPreventSchedulingAtQueueLimitExceeded)
|
||||
false
|
||||
);
|
||||
|
||||
if (i == TOTAL - 1) {
|
||||
if (i == kTOTAL - 1) {
|
||||
EXPECT_FALSE(res);
|
||||
|
||||
std::unique_lock const lk{mtx};
|
||||
|
||||
Reference in New Issue
Block a user