backup_test.go
backup_test.go - Overview
This file contains tests for the backup and restore functionality of the BadgerDB. It includes tests for full backups, incremental backups, and verification of data integrity after restore.
Detailed Documentation
TestBackupRestore1
- Purpose: Tests a basic backup and restore scenario with two entries.
- Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
TestBackupRestore2
- Purpose: Tests backup and restore with a larger number of keys.
- Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
TestBackup
- Purpose: Tests the backup functionality for both disk and in-memory modes.
- Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
createEntries
- Purpose: Creates a slice of
*pb.KV
entries for testing purposes. - Parameters:
n
(int): The number of entries to create.
- Returns:
[]*pb.KV
: A slice of*pb.KV
entries.
populateEntries
- Purpose: Populates the database with the provided entries.
- Parameters:
db
(*DB): The database to populate.entries
([]*pb.KV): The entries to add to the database.
- Returns: error: An error if any of the
SetEntry
operations fail, nil otherwise.
TestBackupRestore3
- Purpose: Tests a full backup and restore scenario with 1000 entries, verifying data integrity and
nextTs
value. - Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
TestBackupLoadIncremental
- Purpose: Tests incremental backups and restores, including deletes, expires, and discards.
- Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
TestBackupBitClear
- Purpose: Tests if bits are cleared correctly after backup and restore.
- Parameters:
t
(*testing.T): Testing object for running test assertions.
- Returns: None.
Code Examples
None.