update unit tests.

This commit is contained in:
bowang 2022-05-16 12:46:37 -07:00
parent f03dfc63e7
commit 19c4f3af6f
2 changed files with 10 additions and 38 deletions

View File

@ -393,17 +393,13 @@ class CompactionJobTestBase : public testing::Test {
}
if (check_get_priority) {
CheckGetRateLimiterPriority(compaction_job);
CheckGetRateLimiterPriorityForWrite(compaction_job);
}
}
void CheckGetRateLimiterPriority(CompactionJob& compaction_job) {
void CheckGetRateLimiterPriorityForWrite(CompactionJob& compaction_job) {
// When the state from WriteController is normal.
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_LOW);
ASSERT_EQ(compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_LOW);
ASSERT_EQ(compaction_job.GetRateLimiterPriorityForWrite(), Env::IO_LOW);
WriteController* write_controller =
compaction_job.versions_->GetColumnFamilySet()->write_controller();
@ -412,36 +408,21 @@ class CompactionJobTestBase : public testing::Test {
// When the state from WriteController is CompactionPressure.
std::unique_ptr<WriteControllerToken> compaction_pressure_token =
write_controller->GetCompactionPressureToken();
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_HIGH);
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_HIGH);
ASSERT_EQ(compaction_job.GetRateLimiterPriorityForWrite(), Env::IO_HIGH);
}
{
// When the state from WriteController is Delayed.
std::unique_ptr<WriteControllerToken> delay_token =
write_controller->GetDelayToken(1000000);
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_USER);
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_USER);
ASSERT_EQ(compaction_job.GetRateLimiterPriorityForWrite(), Env::IO_USER);
}
{
// When the state from WriteController is Stopped.
std::unique_ptr<WriteControllerToken> stop_token =
write_controller->GetStopToken();
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_USER);
ASSERT_EQ(
compaction_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_USER);
ASSERT_EQ(compaction_job.GetRateLimiterPriorityForWrite(), Env::IO_USER);
}
}

View File

@ -528,7 +528,7 @@ TEST_F(FlushJobTest, Snapshots) {
job_context.Clean();
}
TEST_F(FlushJobTest, GetRateLimiterPriority) {
TEST_F(FlushJobTest, GetRateLimiterPriorityWrite) {
// Prepare a FlushJob that flush MemTables of Single Column Family.
const size_t num_mems = 2;
const size_t num_mems_to_flush = 1;
@ -574,10 +574,7 @@ TEST_F(FlushJobTest, GetRateLimiterPriority) {
Env::Priority::USER, nullptr /*IOTracer*/);
// When the state from WriteController is normal.
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_HIGH);
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_USER);
ASSERT_EQ(flush_job.GetRateLimiterPriorityWrite(), Env::IO_HIGH);
WriteController* write_controller =
flush_job.versions_->GetColumnFamilySet()->write_controller();
@ -586,20 +583,14 @@ TEST_F(FlushJobTest, GetRateLimiterPriority) {
// When the state from WriteController is Delayed.
std::unique_ptr<WriteControllerToken> delay_token =
write_controller->GetDelayToken(1000000);
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_USER);
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_USER);
ASSERT_EQ(flush_job.GetRateLimiterPriorityWrite(), Env::IO_USER);
}
{
// When the state from WriteController is Stopped.
std::unique_ptr<WriteControllerToken> stop_token =
write_controller->GetStopToken();
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kWrite),
Env::IO_USER);
ASSERT_EQ(flush_job.GetRateLimiterPriority(RateLimiter::OpType::kRead),
Env::IO_USER);
ASSERT_EQ(flush_job.GetRateLimiterPriorityWrite(), Env::IO_USER);
}
}