aboutsummaryrefslogtreecommitdiff
path: root/tests/rand_fail.rs
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-06-10 14:40:36 -0400
committerDeterminant <[email protected]>2020-06-10 14:40:36 -0400
commit415578aa48a12cac01d763b7c08384dbcd46911b (patch)
treec01d7e28e38caac6662215469a172dd99f576654 /tests/rand_fail.rs
parent81eb9ce9299b2e31471db3f00457ff3c1a41fb60 (diff)
WIP: random failure test (with emulated storage)
Diffstat (limited to 'tests/rand_fail.rs')
-rw-r--r--tests/rand_fail.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/rand_fail.rs b/tests/rand_fail.rs
new file mode 100644
index 0000000..988da05
--- /dev/null
+++ b/tests/rand_fail.rs
@@ -0,0 +1,25 @@
+#[cfg(test)]
+
+extern crate growthring;
+use growthring::wal::{WALLoader, WALWriter, WALRingId, WALBytes};
+
+mod common;
+
+fn test(records: Vec<String>, wal: &mut WALWriter<common::WALStoreEmul>) -> Box<[WALRingId]> {
+ let records: Vec<WALBytes> = records.into_iter().map(|s| s.into_bytes().into_boxed_slice()).collect();
+ let ret = wal.grow(&records);
+ for ring_id in ret.iter() {
+ println!("got ring id: {:?}", ring_id);
+ }
+ ret
+}
+
+#[test]
+fn test_rand_fail() {
+ let mut state = common::WALStoreEmulState::new();
+ let mut wal = WALLoader::new(common::WALStoreEmul::new(&mut state), 9, 8, 1000).recover();
+ for _ in 0..3 {
+ test(["hi", "hello", "lol"].iter().map(|s| s.to_string()).collect::<Vec<String>>(), &mut wal);
+ }
+ let mut wal = WALLoader::new(common::WALStoreEmul::new(&mut state), 9, 8, 1000).recover();
+}