Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ stability_scope!(BETA {
/// Remove a blob from a given partition.
///
/// If no `name` is provided, the entire partition is removed.
/// If a `name` is provided, existing [Blob] handles for that blob must remain readable
/// until they are dropped, but the blob must be removed from future namespace lookups.
///
/// An Ok result indicates the blob is durably removed.
fn remove(
Comment on lines 707 to 712
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test to confirm this behavior that should run on all storage backends.

Expand Down
20 changes: 20 additions & 0 deletions runtime/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ pub(crate) mod tests {
test_read_at_buf_returns_same_buffer(&storage).await;
test_read_at_buf_insufficient_capacity(&storage).await;
test_read_at_buf_larger_capacity(&storage).await;
test_read_after_remove(&storage).await;
}

/// Test opening a blob, writing to it, and reading back the data.
Expand Down Expand Up @@ -342,6 +343,25 @@ pub(crate) mod tests {
assert!(blobs.is_empty(), "Blob was not removed as expected");
}

/// Test that existing blob handles remain readable after the blob is removed from storage.
async fn test_read_after_remove<S>(storage: &S)
where
S: Storage + Send + Sync,
S::Blob: Send + Sync,
{
let (blob, _) = storage.open("read_after_remove", b"blob").await.unwrap();
blob.write_at(0, b"still here").await.unwrap();
blob.sync().await.unwrap();

storage
.remove("read_after_remove", Some(b"blob"))
.await
.unwrap();

let read = blob.read_at(0, 10).await.unwrap();
assert_eq!(read.coalesce(), b"still here");
}

/// Test scanning a partition for blobs.
async fn test_scan<S>(storage: &S)
where
Expand Down
1 change: 1 addition & 0 deletions storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ commonware-math.workspace = true
commonware-runtime = { workspace = true, features = ["test-utils"] }
commonware-storage = { path = ".", features = ["std"] }
criterion.workspace = true
governor.workspace = true
rand.workspace = true
rstest.workspace = true
tracing-subscriber.workspace = true
Expand Down
Loading
Loading