mirror of https://github.com/facebook/rocksdb.git
Parameterize a few tests in DBWALTest (#7105)
Summary: As title. The goal is to shorten the execution time of several tests when they are combined together in a single TEST_F. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7105 Test Plan: make db_wal_test ./db_wal_test Reviewed By: ltamasi Differential Revision: D22442705 Pulled By: riversand963 fbshipit-source-id: 0ad49b8f21fa86dcd5a4d3c9a06af313735ac217
This commit is contained in:
parent
842bd2742a
commit
f70ad03137
|
@ -16,11 +16,12 @@
|
||||||
#include "test_util/sync_point.h"
|
#include "test_util/sync_point.h"
|
||||||
|
|
||||||
namespace ROCKSDB_NAMESPACE {
|
namespace ROCKSDB_NAMESPACE {
|
||||||
class DBWALTest : public DBTestBase {
|
class DBWALTestBase : public DBTestBase {
|
||||||
public:
|
protected:
|
||||||
DBWALTest() : DBTestBase("/db_wal_test") {}
|
explicit DBWALTestBase(const std::string& dir_name) : DBTestBase(dir_name) {}
|
||||||
|
|
||||||
#if defined(ROCKSDB_PLATFORM_POSIX)
|
#if defined(ROCKSDB_PLATFORM_POSIX)
|
||||||
|
public:
|
||||||
uint64_t GetAllocatedFileSize(std::string file_name) {
|
uint64_t GetAllocatedFileSize(std::string file_name) {
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
int err = stat(file_name.c_str(), &sbuf);
|
int err = stat(file_name.c_str(), &sbuf);
|
||||||
|
@ -30,6 +31,11 @@ class DBWALTest : public DBTestBase {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DBWALTest : public DBWALTestBase {
|
||||||
|
public:
|
||||||
|
DBWALTest() : DBWALTestBase("/db_wal_test") {}
|
||||||
|
};
|
||||||
|
|
||||||
// A SpecialEnv enriched to give more insight about deleted files
|
// A SpecialEnv enriched to give more insight about deleted files
|
||||||
class EnrichedSpecialEnv : public SpecialEnv {
|
class EnrichedSpecialEnv : public SpecialEnv {
|
||||||
public:
|
public:
|
||||||
|
@ -905,16 +911,16 @@ TEST_F(DBWALTest, PartOfWritesWithWALDisabled) {
|
||||||
class RecoveryTestHelper {
|
class RecoveryTestHelper {
|
||||||
public:
|
public:
|
||||||
// Number of WAL files to generate
|
// Number of WAL files to generate
|
||||||
static const int kWALFilesCount = 10;
|
static constexpr int kWALFilesCount = 10;
|
||||||
// Starting number for the WAL file name like 00010.log
|
// Starting number for the WAL file name like 00010.log
|
||||||
static const int kWALFileOffset = 10;
|
static constexpr int kWALFileOffset = 10;
|
||||||
// Keys to be written per WAL file
|
// Keys to be written per WAL file
|
||||||
static const int kKeysPerWALFile = 133;
|
static constexpr int kKeysPerWALFile = 133;
|
||||||
// Size of the value
|
// Size of the value
|
||||||
static const int kValueSize = 96;
|
static constexpr int kValueSize = 96;
|
||||||
|
|
||||||
// Create WAL files with values filled in
|
// Create WAL files with values filled in
|
||||||
static void FillData(DBWALTest* test, const Options& options,
|
static void FillData(DBWALTestBase* test, const Options& options,
|
||||||
const size_t wal_count, size_t* count) {
|
const size_t wal_count, size_t* count) {
|
||||||
// Calling internal functions requires sanitized options.
|
// Calling internal functions requires sanitized options.
|
||||||
Options sanitized_options = SanitizeOptions(test->dbname_, options);
|
Options sanitized_options = SanitizeOptions(test->dbname_, options);
|
||||||
|
@ -968,7 +974,7 @@ class RecoveryTestHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recreate and fill the store with some data
|
// Recreate and fill the store with some data
|
||||||
static size_t FillData(DBWALTest* test, Options* options) {
|
static size_t FillData(DBWALTestBase* test, Options* options) {
|
||||||
options->create_if_missing = true;
|
options->create_if_missing = true;
|
||||||
test->DestroyAndReopen(*options);
|
test->DestroyAndReopen(*options);
|
||||||
test->Close();
|
test->Close();
|
||||||
|
@ -979,7 +985,7 @@ class RecoveryTestHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read back all the keys we wrote and return the number of keys found
|
// Read back all the keys we wrote and return the number of keys found
|
||||||
static size_t GetData(DBWALTest* test) {
|
static size_t GetData(DBWALTestBase* test) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (size_t i = 0; i < kWALFilesCount * kKeysPerWALFile; i++) {
|
for (size_t i = 0; i < kWALFilesCount * kKeysPerWALFile; i++) {
|
||||||
if (test->Get("key" + ToString(i)) != "NOT_FOUND") {
|
if (test->Get("key" + ToString(i)) != "NOT_FOUND") {
|
||||||
|
@ -990,7 +996,7 @@ class RecoveryTestHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manuall corrupt the specified WAL
|
// Manuall corrupt the specified WAL
|
||||||
static void CorruptWAL(DBWALTest* test, const Options& options,
|
static void CorruptWAL(DBWALTestBase* test, const Options& options,
|
||||||
const double off, const double len,
|
const double off, const double len,
|
||||||
const int wal_file_id, const bool trunc = false) {
|
const int wal_file_id, const bool trunc = false) {
|
||||||
Env* env = options.env;
|
Env* env = options.env;
|
||||||
|
@ -1035,76 +1041,101 @@ class RecoveryTestHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DBWALTestWithParams
|
||||||
|
: public DBWALTestBase,
|
||||||
|
public ::testing::WithParamInterface<std::tuple<bool, int, int>> {
|
||||||
|
public:
|
||||||
|
DBWALTestWithParams() : DBWALTestBase("/db_wal_test_with_params") {}
|
||||||
|
};
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(
|
||||||
|
Wal, DBWALTestWithParams,
|
||||||
|
::testing::Combine(::testing::Bool(), ::testing::Range(0, 4, 1),
|
||||||
|
::testing::Range(RecoveryTestHelper::kWALFileOffset,
|
||||||
|
RecoveryTestHelper::kWALFileOffset +
|
||||||
|
RecoveryTestHelper::kWALFilesCount,
|
||||||
|
1)));
|
||||||
|
|
||||||
|
class DBWALTestWithParamsVaryingRecoveryMode
|
||||||
|
: public DBWALTestBase,
|
||||||
|
public ::testing::WithParamInterface<
|
||||||
|
std::tuple<bool, int, int, WALRecoveryMode>> {
|
||||||
|
public:
|
||||||
|
DBWALTestWithParamsVaryingRecoveryMode()
|
||||||
|
: DBWALTestBase("/db_wal_test_with_params_mode") {}
|
||||||
|
};
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(
|
||||||
|
Wal, DBWALTestWithParamsVaryingRecoveryMode,
|
||||||
|
::testing::Combine(
|
||||||
|
::testing::Bool(), ::testing::Range(0, 4, 1),
|
||||||
|
::testing::Range(RecoveryTestHelper::kWALFileOffset,
|
||||||
|
RecoveryTestHelper::kWALFileOffset +
|
||||||
|
RecoveryTestHelper::kWALFilesCount,
|
||||||
|
1),
|
||||||
|
::testing::Values(WALRecoveryMode::kTolerateCorruptedTailRecords,
|
||||||
|
WALRecoveryMode::kAbsoluteConsistency,
|
||||||
|
WALRecoveryMode::kPointInTimeRecovery,
|
||||||
|
WALRecoveryMode::kSkipAnyCorruptedRecords)));
|
||||||
|
|
||||||
// Test scope:
|
// Test scope:
|
||||||
// - We expect to open the data store when there is incomplete trailing writes
|
// - We expect to open the data store when there is incomplete trailing writes
|
||||||
// at the end of any of the logs
|
// at the end of any of the logs
|
||||||
// - We do not expect to open the data store for corruption
|
// - We do not expect to open the data store for corruption
|
||||||
TEST_F(DBWALTest, kTolerateCorruptedTailRecords) {
|
TEST_P(DBWALTestWithParams, kTolerateCorruptedTailRecords) {
|
||||||
const int jstart = RecoveryTestHelper::kWALFileOffset;
|
bool trunc = std::get<0>(GetParam()); // Corruption style
|
||||||
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
|
// Corruption offset position
|
||||||
|
int corrupt_offset = std::get<1>(GetParam());
|
||||||
|
int wal_file_id = std::get<2>(GetParam()); // WAL file
|
||||||
|
|
||||||
for (auto trunc : {true, false}) { /* Corruption style */
|
|
||||||
for (int i = 0; i < 3; i++) { /* Corruption offset position */
|
|
||||||
for (int j = jstart; j < jend; j++) { /* WAL file */
|
|
||||||
// Fill data for testing
|
// Fill data for testing
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
||||||
// test checksum failure or parsing
|
// test checksum failure or parsing
|
||||||
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
|
RecoveryTestHelper::CorruptWAL(this, options, corrupt_offset * .3,
|
||||||
/*len%=*/.1, /*wal=*/j, trunc);
|
/*len%=*/.1, wal_file_id, trunc);
|
||||||
|
|
||||||
|
options.wal_recovery_mode = WALRecoveryMode::kTolerateCorruptedTailRecords;
|
||||||
if (trunc) {
|
if (trunc) {
|
||||||
options.wal_recovery_mode =
|
|
||||||
WALRecoveryMode::kTolerateCorruptedTailRecords;
|
|
||||||
options.create_if_missing = false;
|
options.create_if_missing = false;
|
||||||
ASSERT_OK(TryReopen(options));
|
ASSERT_OK(TryReopen(options));
|
||||||
const size_t recovered_row_count = RecoveryTestHelper::GetData(this);
|
const size_t recovered_row_count = RecoveryTestHelper::GetData(this);
|
||||||
ASSERT_TRUE(i == 0 || recovered_row_count > 0);
|
ASSERT_TRUE(corrupt_offset == 0 || recovered_row_count > 0);
|
||||||
ASSERT_LT(recovered_row_count, row_count);
|
ASSERT_LT(recovered_row_count, row_count);
|
||||||
} else {
|
} else {
|
||||||
options.wal_recovery_mode =
|
|
||||||
WALRecoveryMode::kTolerateCorruptedTailRecords;
|
|
||||||
ASSERT_NOK(TryReopen(options));
|
ASSERT_NOK(TryReopen(options));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test scope:
|
// Test scope:
|
||||||
// We don't expect the data store to be opened if there is any corruption
|
// We don't expect the data store to be opened if there is any corruption
|
||||||
// (leading, middle or trailing -- incomplete writes or corruption)
|
// (leading, middle or trailing -- incomplete writes or corruption)
|
||||||
TEST_F(DBWALTest, kAbsoluteConsistency) {
|
TEST_P(DBWALTestWithParams, kAbsoluteConsistency) {
|
||||||
const int jstart = RecoveryTestHelper::kWALFileOffset;
|
|
||||||
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
|
|
||||||
|
|
||||||
// Verify clean slate behavior
|
// Verify clean slate behavior
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
||||||
options.wal_recovery_mode = WALRecoveryMode::kAbsoluteConsistency;
|
|
||||||
options.create_if_missing = false;
|
options.create_if_missing = false;
|
||||||
ASSERT_OK(TryReopen(options));
|
ASSERT_OK(TryReopen(options));
|
||||||
ASSERT_EQ(RecoveryTestHelper::GetData(this), row_count);
|
ASSERT_EQ(RecoveryTestHelper::GetData(this), row_count);
|
||||||
|
|
||||||
for (auto trunc : {true, false}) { /* Corruption style */
|
bool trunc = std::get<0>(GetParam()); // Corruption style
|
||||||
for (int i = 0; i < 4; i++) { /* Corruption offset position */
|
// Corruption offset position
|
||||||
if (trunc && i == 0) {
|
int corrupt_offset = std::get<1>(GetParam());
|
||||||
continue;
|
int wal_file_id = std::get<2>(GetParam()); // WAL file
|
||||||
|
|
||||||
|
if (trunc && corrupt_offset == 0) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = jstart; j < jend; j++) { /* wal files */
|
|
||||||
// fill with new date
|
// fill with new date
|
||||||
RecoveryTestHelper::FillData(this, &options);
|
RecoveryTestHelper::FillData(this, &options);
|
||||||
// corrupt the wal
|
// corrupt the wal
|
||||||
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
|
RecoveryTestHelper::CorruptWAL(this, options, corrupt_offset * .3,
|
||||||
/*len%=*/.1, j, trunc);
|
/*len%=*/.1, wal_file_id, trunc);
|
||||||
// verify
|
// verify
|
||||||
options.wal_recovery_mode = WALRecoveryMode::kAbsoluteConsistency;
|
options.wal_recovery_mode = WALRecoveryMode::kAbsoluteConsistency;
|
||||||
options.create_if_missing = false;
|
options.create_if_missing = false;
|
||||||
ASSERT_NOK(TryReopen(options));
|
ASSERT_NOK(TryReopen(options));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test scope:
|
// Test scope:
|
||||||
|
@ -1143,22 +1174,22 @@ TEST_F(DBWALTest, kPointInTimeRecoveryCFConsistency) {
|
||||||
// Test scope:
|
// Test scope:
|
||||||
// - We expect to open data store under all circumstances
|
// - We expect to open data store under all circumstances
|
||||||
// - We expect only data upto the point where the first error was encountered
|
// - We expect only data upto the point where the first error was encountered
|
||||||
TEST_F(DBWALTest, kPointInTimeRecovery) {
|
TEST_P(DBWALTestWithParams, kPointInTimeRecovery) {
|
||||||
const int jstart = RecoveryTestHelper::kWALFileOffset;
|
|
||||||
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
|
|
||||||
const int maxkeys =
|
const int maxkeys =
|
||||||
RecoveryTestHelper::kWALFilesCount * RecoveryTestHelper::kKeysPerWALFile;
|
RecoveryTestHelper::kWALFilesCount * RecoveryTestHelper::kKeysPerWALFile;
|
||||||
|
|
||||||
for (auto trunc : {true, false}) { /* Corruption style */
|
bool trunc = std::get<0>(GetParam()); // Corruption style
|
||||||
for (int i = 0; i < 4; i++) { /* Offset of corruption */
|
// Corruption offset position
|
||||||
for (int j = jstart; j < jend; j++) { /* WAL file */
|
int corrupt_offset = std::get<1>(GetParam());
|
||||||
|
int wal_file_id = std::get<2>(GetParam()); // WAL file
|
||||||
|
|
||||||
// Fill data for testing
|
// Fill data for testing
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
||||||
|
|
||||||
// Corrupt the wal
|
// Corrupt the wal
|
||||||
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
|
RecoveryTestHelper::CorruptWAL(this, options, corrupt_offset * .3,
|
||||||
/*len%=*/.1, j, trunc);
|
/*len%=*/.1, wal_file_id, trunc);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
options.wal_recovery_mode = WALRecoveryMode::kPointInTimeRecovery;
|
options.wal_recovery_mode = WALRecoveryMode::kPointInTimeRecovery;
|
||||||
|
@ -1171,7 +1202,7 @@ TEST_F(DBWALTest, kPointInTimeRecovery) {
|
||||||
|
|
||||||
bool expect_data = true;
|
bool expect_data = true;
|
||||||
for (size_t k = 0; k < maxkeys; ++k) {
|
for (size_t k = 0; k < maxkeys; ++k) {
|
||||||
bool found = Get("key" + ToString(i)) != "NOT_FOUND";
|
bool found = Get("key" + ToString(corrupt_offset)) != "NOT_FOUND";
|
||||||
if (expect_data && !found) {
|
if (expect_data && !found) {
|
||||||
expect_data = false;
|
expect_data = false;
|
||||||
}
|
}
|
||||||
|
@ -1179,35 +1210,31 @@ TEST_F(DBWALTest, kPointInTimeRecovery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t min = RecoveryTestHelper::kKeysPerWALFile *
|
const size_t min = RecoveryTestHelper::kKeysPerWALFile *
|
||||||
(j - RecoveryTestHelper::kWALFileOffset);
|
(wal_file_id - RecoveryTestHelper::kWALFileOffset);
|
||||||
ASSERT_GE(recovered_row_count, min);
|
ASSERT_GE(recovered_row_count, min);
|
||||||
if (!trunc && i != 0) {
|
if (!trunc && corrupt_offset != 0) {
|
||||||
const size_t max = RecoveryTestHelper::kKeysPerWALFile *
|
const size_t max = RecoveryTestHelper::kKeysPerWALFile *
|
||||||
(j - RecoveryTestHelper::kWALFileOffset + 1);
|
(wal_file_id - RecoveryTestHelper::kWALFileOffset + 1);
|
||||||
ASSERT_LE(recovered_row_count, max);
|
ASSERT_LE(recovered_row_count, max);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test scope:
|
// Test scope:
|
||||||
// - We expect to open the data store under all scenarios
|
// - We expect to open the data store under all scenarios
|
||||||
// - We expect to have recovered records past the corruption zone
|
// - We expect to have recovered records past the corruption zone
|
||||||
TEST_F(DBWALTest, kSkipAnyCorruptedRecords) {
|
TEST_P(DBWALTestWithParams, kSkipAnyCorruptedRecords) {
|
||||||
const int jstart = RecoveryTestHelper::kWALFileOffset;
|
bool trunc = std::get<0>(GetParam()); // Corruption style
|
||||||
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
|
// Corruption offset position
|
||||||
|
int corrupt_offset = std::get<1>(GetParam());
|
||||||
|
int wal_file_id = std::get<2>(GetParam()); // WAL file
|
||||||
|
|
||||||
for (auto trunc : {true, false}) { /* Corruption style */
|
|
||||||
for (int i = 0; i < 4; i++) { /* Corruption offset */
|
|
||||||
for (int j = jstart; j < jend; j++) { /* wal files */
|
|
||||||
// Fill data for testing
|
// Fill data for testing
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
const size_t row_count = RecoveryTestHelper::FillData(this, &options);
|
||||||
|
|
||||||
// Corrupt the WAL
|
// Corrupt the WAL
|
||||||
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
|
RecoveryTestHelper::CorruptWAL(this, options, corrupt_offset * .3,
|
||||||
/*len%=*/.1, j, trunc);
|
/*len%=*/.1, wal_file_id, trunc);
|
||||||
|
|
||||||
// Verify behavior
|
// Verify behavior
|
||||||
options.wal_recovery_mode = WALRecoveryMode::kSkipAnyCorruptedRecords;
|
options.wal_recovery_mode = WALRecoveryMode::kSkipAnyCorruptedRecords;
|
||||||
|
@ -1219,10 +1246,7 @@ TEST_F(DBWALTest, kSkipAnyCorruptedRecords) {
|
||||||
ASSERT_LT(recovered_row_count, row_count);
|
ASSERT_LT(recovered_row_count, row_count);
|
||||||
|
|
||||||
if (!trunc) {
|
if (!trunc) {
|
||||||
ASSERT_TRUE(i != 0 || recovered_row_count > 0);
|
ASSERT_TRUE(corrupt_offset != 0 || recovered_row_count > 0);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,9 +1425,8 @@ TEST_F(DBWALTest, RecoverWithoutFlushMultipleCF) {
|
||||||
// 2. Open with avoid_flush_during_recovery = true;
|
// 2. Open with avoid_flush_during_recovery = true;
|
||||||
// 3. Append more data without flushing, which creates new WAL log.
|
// 3. Append more data without flushing, which creates new WAL log.
|
||||||
// 4. Open again. See if it can correctly handle previous corruption.
|
// 4. Open again. See if it can correctly handle previous corruption.
|
||||||
TEST_F(DBWALTest, RecoverFromCorruptedWALWithoutFlush) {
|
TEST_P(DBWALTestWithParamsVaryingRecoveryMode,
|
||||||
const int jstart = RecoveryTestHelper::kWALFileOffset;
|
RecoverFromCorruptedWALWithoutFlush) {
|
||||||
const int jend = jstart + RecoveryTestHelper::kWALFilesCount;
|
|
||||||
const int kAppendKeys = 100;
|
const int kAppendKeys = 100;
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
options.avoid_flush_during_recovery = true;
|
options.avoid_flush_during_recovery = true;
|
||||||
|
@ -1422,26 +1445,25 @@ TEST_F(DBWALTest, RecoverFromCorruptedWALWithoutFlush) {
|
||||||
delete iter;
|
delete iter;
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
for (auto& mode : {WALRecoveryMode::kTolerateCorruptedTailRecords,
|
|
||||||
WALRecoveryMode::kAbsoluteConsistency,
|
bool trunc = std::get<0>(GetParam()); // Corruption style
|
||||||
WALRecoveryMode::kPointInTimeRecovery,
|
// Corruption offset position
|
||||||
WALRecoveryMode::kSkipAnyCorruptedRecords}) {
|
int corrupt_offset = std::get<1>(GetParam());
|
||||||
options.wal_recovery_mode = mode;
|
int wal_file_id = std::get<2>(GetParam()); // WAL file
|
||||||
for (auto trunc : {true, false}) {
|
WALRecoveryMode recovery_mode = std::get<3>(GetParam());
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
for (int j = jstart; j < jend; j++) {
|
options.wal_recovery_mode = recovery_mode;
|
||||||
// Create corrupted WAL
|
// Create corrupted WAL
|
||||||
RecoveryTestHelper::FillData(this, &options);
|
RecoveryTestHelper::FillData(this, &options);
|
||||||
RecoveryTestHelper::CorruptWAL(this, options, /*off=*/i * .3,
|
RecoveryTestHelper::CorruptWAL(this, options, corrupt_offset * .3,
|
||||||
/*len%=*/.1, /*wal=*/j, trunc);
|
/*len%=*/.1, wal_file_id, trunc);
|
||||||
// Skip the test if DB won't open.
|
// Skip the test if DB won't open.
|
||||||
if (!TryReopen(options).ok()) {
|
if (!TryReopen(options).ok()) {
|
||||||
ASSERT_TRUE(options.wal_recovery_mode ==
|
ASSERT_TRUE(options.wal_recovery_mode ==
|
||||||
WALRecoveryMode::kAbsoluteConsistency ||
|
WALRecoveryMode::kAbsoluteConsistency ||
|
||||||
(!trunc &&
|
(!trunc && options.wal_recovery_mode ==
|
||||||
options.wal_recovery_mode ==
|
|
||||||
WALRecoveryMode::kTolerateCorruptedTailRecords));
|
WALRecoveryMode::kTolerateCorruptedTailRecords));
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT_OK(TryReopen(options));
|
ASSERT_OK(TryReopen(options));
|
||||||
// Append some more data.
|
// Append some more data.
|
||||||
|
@ -1456,10 +1478,6 @@ TEST_F(DBWALTest, RecoverFromCorruptedWALWithoutFlush) {
|
||||||
ASSERT_OK(TryReopen(options));
|
ASSERT_OK(TryReopen(options));
|
||||||
auto actual_data = getAll();
|
auto actual_data = getAll();
|
||||||
ASSERT_EQ(data, actual_data);
|
ASSERT_EQ(data, actual_data);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that total log size is recovered if we set
|
// Tests that total log size is recovered if we set
|
||||||
|
|
Loading…
Reference in New Issue