Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b2a2ba1
[sagas] Make a macro to simplify declaring saga actions
smklein Dec 16, 2022
f399ff7
ignore rustdoc
smklein Dec 16, 2022
66cf0c0
[nexus] Instance Deletion is now a saga
smklein Dec 16, 2022
828ed21
[nexus] Project and VPC creation are now sagas
smklein Dec 19, 2022
2e0a199
Merge branch 'main' into saga-macro
smklein Dec 19, 2022
533ee76
Merge branch 'main' into saga-macro
smklein Dec 19, 2022
6abce08
Move some lazy_static to once_cell
smklein Dec 20, 2022
169ed10
Merge branch 'main' into saga-macro
smklein Dec 20, 2022
29a3ab5
Extend docs
smklein Dec 20, 2022
3b62a6a
Merge branch 'main' into saga-macro
smklein Dec 20, 2022
05cbd9d
Merge branch 'saga-macro' into more-sagas
smklein Dec 20, 2022
f7f5fbe
Merge branch 'more-sagas' into project-creation-saga
smklein Dec 20, 2022
2f89973
[vpc_create] Add undo actions
smklein Dec 21, 2022
b9fef96
[vpc_create] Add tests for idempotency, fix things
smklein Dec 21, 2022
d68c763
[nexus] Make project creation unwind safe, add tests
smklein Dec 21, 2022
9a8504b
fix project lookup
smklein Dec 21, 2022
79271d2
Lookup project when deleting to avoid rcgen issue during unwind
smklein Dec 21, 2022
23801dd
[nexus] Make snapshot deletion a saga
smklein Dec 22, 2022
80932d8
[nexus] Add basic test for snapshot create
smklein Dec 23, 2022
bfc6048
Merge branch 'main' into project-creation-saga
smklein Dec 23, 2022
f9c635a
Merge branch 'project-creation-saga' into vpc-creation-saga-idempotent
smklein Dec 23, 2022
8c01fcd
Merge branch 'vpc-creation-saga-idempotent' into project-creation-sag…
smklein Dec 23, 2022
3f37a48
Merge branch 'project-creation-saga-idempotent' into snapshot-delete-…
smklein Dec 23, 2022
e1a5e5c
Merge branch 'snapshot-delete-saga' into snapshot-create-saga-idempotent
smklein Dec 23, 2022
163d9c5
fix node names
smklein Dec 23, 2022
fedfbb8
Merge branch 'snapshot-delete-saga' into snapshot-create-saga-idempotent
smklein Dec 23, 2022
ffdc483
Verify clean slate in snapshot test, add volume check to disk test
smklein Dec 23, 2022
839fac6
Passing snapshot unwind test
smklein Dec 26, 2022
e4190e8
More state validation
smklein Dec 26, 2022
c4b16ce
fmt
smklein Dec 26, 2022
9008dce
Don't record sled_id; not needed yet
smklein Dec 26, 2022
666bf64
Merge branch 'main' into project-creation-saga-idempotent
smklein Dec 27, 2022
af15ed0
Merge branch 'project-creation-saga-idempotent' into snapshot-delete-…
smklein Dec 27, 2022
ee2519e
Merge branch 'snapshot-delete-saga' into snapshot-create-saga-idempotent
smklein Dec 27, 2022
1d68f03
Merge branch 'main' into project-creation-saga-idempotent
smklein Dec 28, 2022
344df7a
Merge branch 'project-creation-saga-idempotent' into snapshot-delete-…
smklein Dec 28, 2022
de1213e
Merge branch 'snapshot-delete-saga' into snapshot-create-saga-idempotent
smklein Dec 28, 2022
d59ef33
Merge branch 'main' into project-creation-saga-idempotent
smklein Dec 29, 2022
805ee99
Merge branch 'project-creation-saga-idempotent' into snapshot-delete-…
smklein Dec 29, 2022
61d9d5c
Merge branch 'snapshot-delete-saga' into snapshot-create-saga-idempotent
smklein Dec 29, 2022
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
38 changes: 29 additions & 9 deletions nexus/src/app/sagas/disk_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ fn randomize_volume_construction_request_ids(
}

#[cfg(test)]
mod test {
pub(crate) mod test {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm mostly modifying this so I can re-use some of the test functions which validates "disk creation doesn't leave detritus".

Most of these checks are identical for snapshot creation.

use crate::{
app::saga::create_saga_dag, app::sagas::disk_create::Params,
app::sagas::disk_create::SagaDiskCreate, authn::saga::Serialized,
Expand Down Expand Up @@ -677,6 +677,20 @@ mod test {
.is_none()
}

async fn no_volume_records_exist(datastore: &DataStore) -> bool {
use crate::db::model::Volume;
use crate::db::schema::volume::dsl;

dsl::volume
.filter(dsl::time_deleted.is_null())
.select(Volume::as_select())
.first_async::<Volume>(datastore.pool_for_tests().await.unwrap())
.await
.optional()
.unwrap()
.is_none()
}

async fn no_region_allocations_exist(
datastore: &DataStore,
test: &DiskTest,
Expand Down Expand Up @@ -712,6 +726,19 @@ mod test {
true
}

pub(crate) async fn verify_clean_slate(
cptestctx: &ControlPlaneTestContext,
test: &DiskTest,
) {
let sled_agent = &cptestctx.sled_agent.sled_agent;
let datastore = cptestctx.server.apictx.nexus.datastore();

assert!(no_disk_records_exist(datastore).await);
assert!(no_volume_records_exist(datastore).await);
assert!(no_region_allocations_exist(datastore, &test).await);
assert!(no_regions_ensured(&sled_agent, &test).await);
}

#[nexus_test(server = crate::Server)]
async fn test_action_failure_can_unwind(
cptestctx: &ControlPlaneTestContext,
Expand Down Expand Up @@ -753,15 +780,8 @@ mod test {
.await
.expect_err("Saga should have failed");

let datastore = nexus.datastore();

// Check that no partial artifacts of disk creation exist:
assert!(no_disk_records_exist(datastore).await);
assert!(no_region_allocations_exist(datastore, &test).await);
assert!(
no_regions_ensured(&cptestctx.sled_agent.sled_agent, &test)
.await
);
verify_clean_slate(&cptestctx, &test).await;
}
}

Expand Down
Loading