manifest_test.go
manifest_test.go - Overview
This file contains tests for the manifest functionality in BadgerDB, including basic operations, corruption handling, rewriting, and concurrent compaction.
Detailed Documentation
TestManifestBasic
- Purpose: Tests basic manifest operations like opening, writing data, closing, and reopening the database.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
helpTestManifestFileCorruption
- Purpose: Helper function to test manifest file corruption scenarios. It opens a manifest file, introduces corruption at a specific offset, and checks if opening the database results in the expected error.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.off
:int64
- Offset in the manifest file where corruption should be introduced.errorContent
:string
- Expected error message when opening the corrupted database.
- Returns: None
TestManifestMagic
- Purpose: Tests manifest corruption by modifying the magic number in the manifest file.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
TestManifestVersion
- Purpose: Tests manifest corruption by modifying the version number in the manifest file.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
TestManifestChecksum
- Purpose: Tests manifest corruption by modifying the checksum in the manifest file.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
key
- Purpose: Helper function to generate keys with a given prefix and index.
- Parameters:
prefix
:string
- Prefix for the key.i
:int
- Index to be included in the key.
- Returns:
string
- Generated key.
buildTable
- Purpose: Builds a table (SSTable) from key-value pairs.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.keyValues
:[][]string
- Slice of key-value pairs (each pair is a slice of two strings).bopts
:table.Options
- Options for building the table.
- Returns:
*table.Table
- The created table.
TestOverlappingKeyRangeError
- Purpose: This test is skipped.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
TestManifestRewrite
- Purpose: Tests the manifest rewriting functionality when the number of deletions exceeds a threshold.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None
TestConcurrentManifestCompaction
- Purpose: Tests concurrent manifest compaction by simulating multiple compaction threads writing to the manifest file simultaneously.
- Parameters:
t
:*testing.T
- Testing object for running test assertions.
- Returns: None