diff --git a/nexus/db-queries/src/db/datastore/physical_disk.rs b/nexus/db-queries/src/db/datastore/physical_disk.rs index 0e1fd56881..f8d0282117 100644 --- a/nexus/db-queries/src/db/datastore/physical_disk.rs +++ b/nexus/db-queries/src/db/datastore/physical_disk.rs @@ -242,12 +242,10 @@ mod test { } // Only checking some fields: - // - The UUID of the disk may actually not be the same as the upserted one; - // the "vendor/serial/model" value is the more critical unique identifier. - // NOTE: Could we derive a UUID from the VSM values? // - The 'time' field precision can be modified slightly when inserted into // the DB. - fn assert_disks_equal_ignore_uuid(lhs: &PhysicalDisk, rhs: &PhysicalDisk) { + fn assert_disks_equal_ignore_time(lhs: &PhysicalDisk, rhs: &PhysicalDisk) { + assert_eq!(lhs.uuid(), rhs.uuid()); assert_eq!(lhs.time_deleted().is_some(), rhs.time_deleted().is_some()); assert_eq!(lhs.vendor, rhs.vendor); assert_eq!(lhs.serial, rhs.serial); @@ -257,9 +255,9 @@ mod test { } #[tokio::test] - async fn physical_disk_upsert_different_uuid_idempotent() { + async fn physical_disk_upsert_uuid_generation_deterministic() { let logctx = dev::test_setup_log( - "physical_disk_upsert_different_uuid_idempotent", + "physical_disk_upsert_uuid_generation_deterministic", ); let mut db = test_setup_database(&logctx.log).await; let (opctx, datastore) = datastore_test(&logctx, &db).await; @@ -280,7 +278,7 @@ mod test { .await .expect("Failed first attempt at upserting disk"); assert_eq!(disk.uuid(), first_observed_disk.uuid()); - assert_disks_equal_ignore_uuid(&disk, &first_observed_disk); + assert_disks_equal_ignore_time(&disk, &first_observed_disk); // Observe the inserted disk let pagparams = list_disk_params(); @@ -290,9 +288,12 @@ mod test { .expect("Failed to list physical disks"); assert_eq!(disks.len(), 1); assert_eq!(disk.uuid(), disks[0].uuid()); - assert_disks_equal_ignore_uuid(&disk, &disks[0]); + assert_disks_equal_ignore_time(&disk, &disks[0]); - // Insert the same disk, with a different UUID primary key + // Insert the same disk, but don't re-state the UUID. + // + // The rest of this test relies on the UUID derivation being + // deterministic. let disk_again = PhysicalDisk::new( String::from("Oxide"), String::from("123"), @@ -300,15 +301,14 @@ mod test { PhysicalDiskKind::U2, sled_id, ); + // With the same input parameters, the UUID should be deterministic. + assert_eq!(disk.uuid(), disk_again.uuid()); + let second_observed_disk = datastore .physical_disk_upsert(&opctx, disk_again.clone()) .await .expect("Failed second upsert of physical disk"); - // This check is pretty important - note that we return the original - // UUID, not the new one. - assert_ne!(disk_again.uuid(), second_observed_disk.uuid()); - assert_eq!(disk_again.id(), second_observed_disk.id()); - assert_disks_equal_ignore_uuid(&disk_again, &second_observed_disk); + assert_disks_equal_ignore_time(&disk_again, &second_observed_disk); assert!( first_observed_disk.time_modified() <= second_observed_disk.time_modified() @@ -318,13 +318,9 @@ mod test { .sled_list_physical_disks(&opctx, sled_id, &pagparams) .await .expect("Failed to re-list physical disks"); - - // We'll use the old primary key assert_eq!(disks.len(), 1); - assert_eq!(disk.uuid(), disks[0].uuid()); - assert_ne!(disk_again.uuid(), disks[0].uuid()); - assert_disks_equal_ignore_uuid(&disk, &disks[0]); - assert_disks_equal_ignore_uuid(&disk_again, &disks[0]); + assert_disks_equal_ignore_time(&disk, &disks[0]); + assert_disks_equal_ignore_time(&disk_again, &disks[0]); db.cleanup().await.unwrap(); logctx.cleanup_successful(); @@ -364,7 +360,7 @@ mod test { first_observed_disk.time_modified() <= second_observed_disk.time_modified() ); - assert_disks_equal_ignore_uuid( + assert_disks_equal_ignore_time( &first_observed_disk, &second_observed_disk, ); diff --git a/nexus/preprocessed_configs/config.xml b/nexus/preprocessed_configs/config.xml new file mode 100644 index 0000000000..9b13f12aea --- /dev/null +++ b/nexus/preprocessed_configs/config.xml @@ -0,0 +1,41 @@ + + + + + trace + true + + + 8123 + 9000 + 9004 + + ./ + + true + + + + + + + ::/0 + + + default + default + 1 + + + + + + + + + + + \ No newline at end of file