|
|
@ -14,6 +14,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
mod util; |
|
|
|
mod util; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use pretty_assertions::assert_eq; |
|
|
|
|
|
|
|
|
|
|
|
use rocksdb::{checkpoint::Checkpoint, Options, DB}; |
|
|
|
use rocksdb::{checkpoint::Checkpoint, Options, DB}; |
|
|
|
use util::DBPath; |
|
|
|
use util::DBPath; |
|
|
|
|
|
|
|
|
|
|
@ -41,10 +43,10 @@ pub fn test_single_checkpoint() { |
|
|
|
// Verify checkpoint
|
|
|
|
// Verify checkpoint
|
|
|
|
let cp = DB::open_default(&cp1_path).unwrap(); |
|
|
|
let cp = DB::open_default(&cp1_path).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"v1"); |
|
|
|
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"v1"); |
|
|
|
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"v2"); |
|
|
|
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"v2"); |
|
|
|
assert_eq!(*cp.get(b"k3").unwrap().unwrap(), *b"v3"); |
|
|
|
assert_eq!(cp.get(b"k3").unwrap().unwrap(), b"v3"); |
|
|
|
assert_eq!(*cp.get(b"k4").unwrap().unwrap(), *b"v4"); |
|
|
|
assert_eq!(cp.get(b"k4").unwrap().unwrap(), b"v4"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
@ -71,10 +73,10 @@ pub fn test_multi_checkpoints() { |
|
|
|
// Verify checkpoint
|
|
|
|
// Verify checkpoint
|
|
|
|
let cp = DB::open_default(&cp1_path).unwrap(); |
|
|
|
let cp = DB::open_default(&cp1_path).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"v1"); |
|
|
|
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"v1"); |
|
|
|
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"v2"); |
|
|
|
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"v2"); |
|
|
|
assert_eq!(*cp.get(b"k3").unwrap().unwrap(), *b"v3"); |
|
|
|
assert_eq!(cp.get(b"k3").unwrap().unwrap(), b"v3"); |
|
|
|
assert_eq!(*cp.get(b"k4").unwrap().unwrap(), *b"v4"); |
|
|
|
assert_eq!(cp.get(b"k4").unwrap().unwrap(), b"v4"); |
|
|
|
|
|
|
|
|
|
|
|
// Change some existing keys
|
|
|
|
// Change some existing keys
|
|
|
|
db.put(b"k1", b"modified").unwrap(); |
|
|
|
db.put(b"k1", b"modified").unwrap(); |
|
|
@ -92,8 +94,8 @@ pub fn test_multi_checkpoints() { |
|
|
|
// Verify second checkpoint
|
|
|
|
// Verify second checkpoint
|
|
|
|
let cp = DB::open_default(&cp2_path).unwrap(); |
|
|
|
let cp = DB::open_default(&cp2_path).unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(*cp.get(b"k1").unwrap().unwrap(), *b"modified"); |
|
|
|
assert_eq!(cp.get(b"k1").unwrap().unwrap(), b"modified"); |
|
|
|
assert_eq!(*cp.get(b"k2").unwrap().unwrap(), *b"changed"); |
|
|
|
assert_eq!(cp.get(b"k2").unwrap().unwrap(), b"changed"); |
|
|
|
assert_eq!(*cp.get(b"k5").unwrap().unwrap(), *b"v5"); |
|
|
|
assert_eq!(cp.get(b"k5").unwrap().unwrap(), b"v5"); |
|
|
|
assert_eq!(*cp.get(b"k6").unwrap().unwrap(), *b"v6"); |
|
|
|
assert_eq!(cp.get(b"k6").unwrap().unwrap(), b"v6"); |
|
|
|
} |
|
|
|
} |
|
|
|