pub struct SimFilesystem { /* private fields */ }Expand description
A filesystem in memory that records what was done to it.
Cloning one gives another handle on the same filesystem, not a copy of it, which is what makes it usable in the places a real one would be shared.
Implementations§
Source§impl SimFilesystem
impl SimFilesystem
Sourcepub fn op_count(&self) -> usize
pub fn op_count(&self) -> usize
How many operations have been recorded.
This is the count the failure point enumeration in section 16.5 runs over: record a workload, then rerun it once per index with the failure injected there.
Sourcepub fn clear_log(&self)
pub fn clear_log(&self)
Forgets the recorded operations, keeping the contents.
For a test that has to set up a database and only wants to enumerate failure points over what comes after the setup.
Sourcepub fn fail_at(&self, index: usize)
pub fn fail_at(&self, index: usize)
Makes the operation at index fail once.
This is error path testing and it is a different mechanism from Self::crash, on purpose.
An EIO on one write is a thing the caller has to handle and keep running from. A crash is
a thing the caller does not get to handle at all, and the question there is what the next
process to open the file sees. Conflating them produces a test that proves neither.
Sourcepub fn clear_failure(&self)
pub fn clear_failure(&self)
Cancels an injected failure that has not fired.
Sourcepub fn reads_served(&self) -> u64
pub fn reads_served(&self) -> u64
How many reads have been served since this filesystem was made.
This is the number the read faults below are addressed by, and it is also the byte counting hook’s coarser sibling: a reader that reads a row group it should have pruned makes more reads than one that does not, and the count says so whatever the answer was.
Sourcepub fn short_read_at(&self, read: u64, len: usize)
pub fn short_read_at(&self, read: u64, len: usize)
Makes read number read come back with len bytes rather than the length asked for.
A short read is not an error, it is a short read, and the reason it is worth injecting is that a decoder which treats a returned buffer as full reads whatever was in the buffer before, which is a wrong answer and not a crash.
Sourcepub fn fail_read_at(&self, read: u64)
pub fn fail_read_at(&self, read: u64)
Makes read number read fail.
Once, like Self::fail_at, and for the same reason: the interesting question is whether
the caller survives one failure, not whether it survives a disk that is gone.
Sourcepub fn complete(&self, order: Completions)
pub fn complete(&self, order: Completions)
Sets the order a batch handed to submit comes back in.
Sourcepub fn clear_read_faults(&self)
pub fn clear_read_faults(&self)
Cancels every injected read fault and puts completions back in submission order.
Sourcepub fn pending(&self) -> Vec<(u64, PathBuf)>
pub fn pending(&self) -> Vec<(u64, PathBuf)>
The writes that have been issued and not made durable, as sequence numbers with their file.
These are the numbers Crash::Keeping takes. The order is the order they were issued in,
across all files, because two writes to different files race with each other exactly the way
two writes to one file do.
Sourcepub fn crash(&self, crash: &Crash) -> Self
pub fn crash(&self, crash: &Crash) -> Self
The filesystem a process would find after a crash.
The durable image, plus whichever pending writes crash says survived, applied in the order
they were issued. The result is a fresh filesystem with an empty log, because the log
belongs to the process that died.
Trait Implementations§
Source§impl Clone for SimFilesystem
impl Clone for SimFilesystem
Source§fn clone(&self) -> SimFilesystem
fn clone(&self) -> SimFilesystem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more