Fix for flaky test BackupableDBTest.RateLimiting (#7167)
Summary: BackupableDBTest.RateLimiting test is failing due to timed out on our test server. It might be because of nested loops run sequentially that test different type of combinations of parameters. This patch converts the test into parameterized test so that all combinations can be tested out. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7167 Test Plan: make check -j64 Reviewed By: zhichao-cao Differential Revision: D22709531 Pulled By: akankshamahajan15 fbshipit-source-id: 95518153e87b3b5311a6c1960a191bca58898786
This commit is contained in:
parent
0c5bb10f06
commit
7e37a5918c
@ -1832,25 +1832,47 @@ TEST_F(BackupableDBTest, KeepLogFiles) {
|
||||
AssertBackupConsistency(0, 0, 500, 600, true);
|
||||
}
|
||||
|
||||
TEST_F(BackupableDBTest, RateLimiting) {
|
||||
size_t const kMicrosPerSec = 1000 * 1000LL;
|
||||
class BackupableDBRateLimitingTestWithParam
|
||||
: public BackupableDBTest,
|
||||
public testing::WithParamInterface<
|
||||
std::tuple<bool /* make throttle */,
|
||||
int /* 0 = single threaded, 1 = multi threaded*/,
|
||||
std::pair<uint64_t, uint64_t> /* limits */>> {
|
||||
public:
|
||||
BackupableDBRateLimitingTestWithParam() {}
|
||||
};
|
||||
|
||||
uint64_t const MB = 1024 * 1024;
|
||||
|
||||
const std::vector<std::pair<uint64_t, uint64_t>> limits(
|
||||
{{1 * MB, 5 * MB}, {2 * MB, 3 * MB}});
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
RateLimiting, BackupableDBRateLimitingTestWithParam,
|
||||
::testing::Values(std::make_tuple(false, 0, std::make_pair(1 * MB, 5 * MB)),
|
||||
std::make_tuple(false, 0, std::make_pair(2 * MB, 3 * MB)),
|
||||
std::make_tuple(false, 1, std::make_pair(1 * MB, 5 * MB)),
|
||||
std::make_tuple(false, 1, std::make_pair(2 * MB, 3 * MB)),
|
||||
std::make_tuple(true, 0, std::make_pair(1 * MB, 5 * MB)),
|
||||
std::make_tuple(true, 0, std::make_pair(2 * MB, 3 * MB)),
|
||||
std::make_tuple(true, 1, std::make_pair(1 * MB, 5 * MB)),
|
||||
std::make_tuple(true, 1,
|
||||
std::make_pair(2 * MB, 3 * MB))));
|
||||
|
||||
TEST_P(BackupableDBRateLimitingTestWithParam, RateLimiting) {
|
||||
size_t const kMicrosPerSec = 1000 * 1000LL;
|
||||
|
||||
std::shared_ptr<RateLimiter> backupThrottler(NewGenericRateLimiter(1));
|
||||
std::shared_ptr<RateLimiter> restoreThrottler(NewGenericRateLimiter(1));
|
||||
|
||||
for (bool makeThrottler : {false, true}) {
|
||||
bool makeThrottler = std::get<0>(GetParam());
|
||||
if (makeThrottler) {
|
||||
backupable_options_->backup_rate_limiter = backupThrottler;
|
||||
backupable_options_->restore_rate_limiter = restoreThrottler;
|
||||
}
|
||||
|
||||
// iter 0 -- single threaded
|
||||
// iter 1 -- multi threaded
|
||||
for (int iter = 0; iter < 2; ++iter) {
|
||||
for (const auto& limit : limits) {
|
||||
int iter = std::get<1>(GetParam());
|
||||
const std::pair<uint64_t, uint64_t> limit = std::get<2>(GetParam());
|
||||
|
||||
// destroy old data
|
||||
DestroyDB(dbname_, Options());
|
||||
if (makeThrottler) {
|
||||
@ -1868,8 +1890,7 @@ TEST_F(BackupableDBTest, RateLimiting) {
|
||||
auto start_backup = db_chroot_env_->NowMicros();
|
||||
ASSERT_OK(backup_engine_->CreateNewBackup(db_.get(), false));
|
||||
auto backup_time = db_chroot_env_->NowMicros() - start_backup;
|
||||
auto rate_limited_backup_time =
|
||||
(bytes_written * kMicrosPerSec) / limit.first;
|
||||
auto rate_limited_backup_time = (bytes_written * kMicrosPerSec) / limit.first;
|
||||
ASSERT_GT(backup_time, 0.8 * rate_limited_backup_time);
|
||||
|
||||
CloseDBAndBackupEngine();
|
||||
@ -1885,9 +1906,6 @@ TEST_F(BackupableDBTest, RateLimiting) {
|
||||
|
||||
AssertBackupConsistency(0, 0, 100000, 100010);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BackupableDBTest, ReadOnlyBackupEngine) {
|
||||
DestroyDB(dbname_, options_);
|
||||
|
Loading…
Reference in New Issue
Block a user