|
|
|
@ -8,6 +8,7 @@ |
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
|
|
|
|
|
#include "db/version_edit.h" |
|
|
|
|
#include "util/coding.h" |
|
|
|
|
#include "util/sync_point.h" |
|
|
|
|
#include "util/testharness.h" |
|
|
|
|
|
|
|
|
@ -197,6 +198,47 @@ TEST_F(VersionEditTest, AtomicGroupTest) { |
|
|
|
|
TestEncodeDecode(edit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(VersionEditTest, IgnorableField) { |
|
|
|
|
VersionEdit ve; |
|
|
|
|
std::string encoded; |
|
|
|
|
|
|
|
|
|
// Size of ignorable field is too large
|
|
|
|
|
PutVarint32Varint64(&encoded, 2 /* kLogNumber */, 66); |
|
|
|
|
// This is a customized ignorable tag
|
|
|
|
|
PutVarint32Varint64(&encoded, |
|
|
|
|
0x2710 /* A field with kTagSafeIgnoreMask set */, |
|
|
|
|
5 /* fieldlength 5 */); |
|
|
|
|
encoded += "abc"; // Only fills 3 bytes,
|
|
|
|
|
ASSERT_NOK(ve.DecodeFrom(encoded)); |
|
|
|
|
|
|
|
|
|
encoded.clear(); |
|
|
|
|
// Error when seeing unidentified tag that is not ignorable
|
|
|
|
|
PutVarint32Varint64(&encoded, 2 /* kLogNumber */, 66); |
|
|
|
|
// This is a customized ignorable tag
|
|
|
|
|
PutVarint32Varint64(&encoded, 666 /* A field with kTagSafeIgnoreMask unset */, |
|
|
|
|
3 /* fieldlength 3 */); |
|
|
|
|
encoded += "abc"; // Fill 3 bytes
|
|
|
|
|
PutVarint32Varint64(&encoded, 3 /* next file number */, 88); |
|
|
|
|
ASSERT_NOK(ve.DecodeFrom(encoded)); |
|
|
|
|
|
|
|
|
|
// Safely ignore an identified but safely ignorable entry
|
|
|
|
|
encoded.clear(); |
|
|
|
|
PutVarint32Varint64(&encoded, 2 /* kLogNumber */, 66); |
|
|
|
|
// This is a customized ignorable tag
|
|
|
|
|
PutVarint32Varint64(&encoded, |
|
|
|
|
0x2710 /* A field with kTagSafeIgnoreMask set */, |
|
|
|
|
3 /* fieldlength 3 */); |
|
|
|
|
encoded += "abc"; // Fill 3 bytes
|
|
|
|
|
PutVarint32Varint64(&encoded, 3 /* kNextFileNumber */, 88); |
|
|
|
|
|
|
|
|
|
ASSERT_OK(ve.DecodeFrom(encoded)); |
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(ve.has_log_number()); |
|
|
|
|
ASSERT_TRUE(ve.has_next_file_number()); |
|
|
|
|
ASSERT_EQ(66, ve.log_number()); |
|
|
|
|
ASSERT_EQ(88, ve.next_file_number()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
|