only corrupt private file checksum in backupable_db_test

Summary:
if it happens (randomly) to corrupt shared file in the test, then the
    checksum will be inconsistent between meta files from different backup.
    BackupEngine will then detect this issue and fail. But in reality, this
    does not happen since the checksum is checked on every backup. So here,
    only corrupt checksum of private file to let BackupEngine to construct
    properly (but fail during restore).

Test Plan: run test with valgrind

Reviewers: igor

Reviewed By: igor

CC: leveldb

Differential Revision: https://reviews.facebook.net/D15531
This commit is contained in:
Lei Jin 2014-01-28 16:03:55 -08:00
parent 5d2c62822e
commit 9a126ba3b3

View File

@ -250,17 +250,15 @@ class FileManager : public EnvWrapper {
return s; return s;
} }
std::vector<int64_t> positions; auto pos = metadata.find("private");
auto pos = metadata.find(" crc32 "); if (pos == std::string::npos) {
return Status::Corruption("private file is expected");
}
pos = metadata.find(" crc32 ", pos + 6);
if (pos == std::string::npos) { if (pos == std::string::npos) {
return Status::Corruption("checksum not found"); return Status::Corruption("checksum not found");
} }
do {
positions.push_back(pos);
pos = metadata.find(" crc32 ", pos + 6);
} while (pos != std::string::npos);
pos = positions[rnd_.Next() % positions.size()];
if (metadata.size() < pos + 7) { if (metadata.size() < pos + 7) {
return Status::Corruption("bad CRC32 checksum value"); return Status::Corruption("bad CRC32 checksum value");
} }