Skip to content

Commit

Permalink
UUID test, comment
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Dec 18, 2024
1 parent cc17582 commit f1bb19a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,8 @@ impl SledAgent {
//
// This means that:
// - If the dataset exists and has a UUID, this will be a no-op
// - If the dataset doesn't exist, it'll be created
// - If the dataset doesn't exist, it'll be created without its
// oxide:uuid zfs property set
// - If a subsequent call to "datasets_ensure" tries to set a UUID,
// it should be able to get set (once).
self.inner.storage.upsert_filesystem(None, dataset_name).await?;
Expand Down
53 changes: 53 additions & 0 deletions sled-storage/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,59 @@ mod tests {
logctx.cleanup_successful();
}

#[tokio::test]
async fn upsert_filesystem_no_uuid() {
illumos_utils::USE_MOCKS.store(false, Ordering::SeqCst);
let logctx = test_setup_log("upsert_filesystem");
let mut harness = StorageManagerTestHarness::new(&logctx.log).await;

// Test setup: Add a U.2 and M.2, adopt them into the "control plane"
// for usage.
harness.handle().key_manager_ready().await;
let raw_disks =
harness.add_vdevs(&["u2_under_test.vdev", "m2_helping.vdev"]).await;
let config = harness.make_config(1, &raw_disks);
let result = harness
.handle()
.omicron_physical_disks_ensure(config.clone())
.await
.expect("Ensuring disks should work after key manager is ready");
assert!(!result.has_error(), "{:?}", result);

// Create a filesystem on the newly formatted U.2, without a UUID
let zpool_name = ZpoolName::new_external(config.disks[0].pool_id);
let dataset_name =
DatasetName::new(zpool_name.clone(), DatasetKind::Crucible);
harness
.handle()
.upsert_filesystem(None, dataset_name.clone())
.await
.unwrap();
let observed_dataset = &Zfs::get_dataset_properties(
&[dataset_name.full_name()],
WhichDatasets::SelfOnly,
)
.unwrap()[0];
assert_eq!(observed_dataset.id, None);

// Later, we can set the UUID to a specific value
let dataset_id = DatasetUuid::new_v4();
harness
.handle()
.upsert_filesystem(Some(dataset_id), dataset_name.clone())
.await
.unwrap();
let observed_dataset = &Zfs::get_dataset_properties(
&[dataset_name.full_name()],
WhichDatasets::SelfOnly,
)
.unwrap()[0];
assert_eq!(observed_dataset.id, Some(dataset_id));

harness.cleanup().await;
logctx.cleanup_successful();
}

#[tokio::test]
async fn ensure_datasets() {
illumos_utils::USE_MOCKS.store(false, Ordering::SeqCst);
Expand Down

0 comments on commit f1bb19a

Please sign in to comment.