Expose typed Prepared Lower failures
This commit is contained in:
parent
ee9201b057
commit
30cd36dcdd
3 changed files with 694 additions and 249 deletions
|
|
@ -15,7 +15,7 @@ use lazaret_core::identity::{
|
|||
use lazaret_core::records::{PrepareOperation, PrepareStageState};
|
||||
use lazaret_prepared_lower::{
|
||||
IdMap, IdMapRange, PrepareRecovery, PrepareRequest, PreparedDestination,
|
||||
PreparedDestinationKind, PreparedLowerStore, ReclaimOutcome,
|
||||
PreparedDestinationKind, PreparedLowerError, PreparedLowerStore, ReclaimOutcome,
|
||||
};
|
||||
use lazaret_storage_catalog::{Catalog, CatalogError};
|
||||
use serde_json::json;
|
||||
|
|
@ -81,7 +81,10 @@ fn preexisting_fixed_children_require_exact_private_mode() {
|
|||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
PreparedLowerStore::initialize(&fixture.root, fixture.catalog.clone()).is_err(),
|
||||
matches!(
|
||||
PreparedLowerStore::initialize(&fixture.root, fixture.catalog.clone()),
|
||||
Err(PreparedLowerError::Confinement { .. })
|
||||
),
|
||||
"accepted wrong mode for {name}"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,10 @@ fn recovery_deletes_only_exact_owned_stage_and_preserves_foreign_stage() {
|
|||
fixture.catalog.record_prepare(&intent).unwrap();
|
||||
std::fs::create_dir(fixture.root.join(&stage)).unwrap();
|
||||
std::fs::write(fixture.root.join(&stage).join("foreign"), b"keep").unwrap();
|
||||
assert!(fixture.store.recover_prepare(&intent).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.recover_prepare(&intent),
|
||||
Err(PreparedLowerError::Recovery { .. })
|
||||
));
|
||||
assert!(fixture.root.join(&stage).join("foreign").exists());
|
||||
std::fs::remove_dir_all(fixture.root.join(&stage)).unwrap();
|
||||
assert_eq!(
|
||||
|
|
@ -337,7 +340,7 @@ fn reclaim_refuses_forged_identity_and_leases() {
|
|||
fixture.catalog.acquire_lease(&lease).unwrap();
|
||||
assert!(matches!(
|
||||
fixture.store.reclaim(&artifact),
|
||||
Err(error)
|
||||
Err(error @ PreparedLowerError::Catalog { .. })
|
||||
if matches!(error.downcast_ref::<CatalogError>(), Some(CatalogError::LeasesPresent))
|
||||
));
|
||||
fixture.catalog.release_lease(&lease).unwrap();
|
||||
|
|
@ -367,7 +370,10 @@ fn selected_gc_is_idempotent_only_at_the_durable_reclaim_boundary() {
|
|||
))
|
||||
.unwrap();
|
||||
let id = artifact.prepared_artifact_id;
|
||||
assert!(fixture.store.gc_artifacts(&[id, id]).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.gc_artifacts(&[id, id]),
|
||||
Err(PreparedLowerError::Reclaim { .. })
|
||||
));
|
||||
|
||||
let lease = lazaret_core::records::ArtifactLease {
|
||||
prepared_artifact_id: id,
|
||||
|
|
|
|||
|
|
@ -69,7 +69,10 @@ fn request_manifest_identity_must_match_verified_layout_manifest() {
|
|||
let mut request = fixture.request(3, &[(bytes, OCI_TAR)]);
|
||||
request.selected_manifest_digest = [0xff; 32];
|
||||
|
||||
assert!(fixture.store.prepare(&request).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.prepare(&request),
|
||||
Err(PreparedLowerError::ManifestSelection { .. })
|
||||
));
|
||||
let snapshot = fixture.catalog.snapshot().unwrap();
|
||||
assert!(snapshot.prepared_artifacts.is_empty());
|
||||
assert!(snapshot.prepare_operations.is_empty());
|
||||
|
|
@ -191,7 +194,10 @@ fn unmapped_nonzero_owners_refuse_before_publication() {
|
|||
}],
|
||||
};
|
||||
|
||||
assert!(fixture.store.prepare(&request).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.prepare(&request),
|
||||
Err(PreparedLowerError::Materialization { .. })
|
||||
));
|
||||
assert!(
|
||||
fixture
|
||||
.catalog
|
||||
|
|
@ -258,7 +264,10 @@ fn hostile_and_corrupt_layers_refuse_without_publication() {
|
|||
for (index, bytes) in cases.into_iter().enumerate() {
|
||||
let fixture = Fixture::new();
|
||||
let request = fixture.request(u8::try_from(index).unwrap() + 10, &[(bytes, OCI_TAR)]);
|
||||
assert!(fixture.store.prepare(&request).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.prepare(&request),
|
||||
Err(PreparedLowerError::Materialization { .. })
|
||||
));
|
||||
let snapshot = fixture.catalog.snapshot().unwrap();
|
||||
assert!(snapshot.prepared_artifacts.is_empty());
|
||||
assert!(snapshot.prepare_operations.is_empty());
|
||||
|
|
@ -291,7 +300,10 @@ fn hostile_and_corrupt_layers_refuse_without_publication() {
|
|||
.find(|path| std::fs::metadata(path).unwrap().len() > 1024)
|
||||
.unwrap();
|
||||
OpenOptionsExt::append_byte(&blob);
|
||||
assert!(fixture.store.prepare(&request).is_err());
|
||||
assert!(matches!(
|
||||
fixture.store.prepare(&request),
|
||||
Err(PreparedLowerError::LayerValidation { .. })
|
||||
));
|
||||
assert!(
|
||||
fixture
|
||||
.catalog
|
||||
|
|
|
|||
Loading…
Reference in a new issue