Skip to content

Commit

Permalink
at least make the crucible tests find backend names again
Browse files Browse the repository at this point in the history
this is not ideal! but newtyping BackendName and DeviceName stretches through into propolis-api-types and is just more than i want to change here
  • Loading branch information
iximeow committed Sep 27, 2024
1 parent 22b5a08 commit 59b6bfc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions phd-tests/framework/src/test_vm/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'dr> VmConfig<'dr> {
// name. It then derives a backend name from the disk name. Match
// that name derivation here so PHD tests match the API as used by
// Nexus.
let backend_name = format!("{}-backend", device_name);
let backend_name = device_name_to_backend_name(device_name);
let device_spec = match req.interface {
DiskInterface::Virtio => {
StorageDeviceV0::VirtioDisk(VirtioDisk {
Expand Down Expand Up @@ -333,23 +333,29 @@ impl<'dr> VmConfig<'dr> {
}
}

fn device_name_to_backend_name(device_name: &str) -> String {
format!("{}-backend", device_name)
}

async fn make_disk<'req>(
name: String,
device_name: String,
framework: &Framework,
req: &DiskRequest<'req>,
) -> anyhow::Result<Arc<dyn DiskConfig>> {
let backend_name = device_name_to_backend_name(&device_name);

Ok(match req.backend {
DiskBackend::File => framework
.disk_factory
.create_file_backed_disk(name, &req.source)
.create_file_backed_disk(backend_name, &req.source)
.await
.with_context(|| {
format!("creating new file-backed disk from {:?}", req.source,)
})? as Arc<dyn DiskConfig>,
DiskBackend::Crucible { min_disk_size_gib, block_size } => framework
.disk_factory
.create_crucible_disk(
name,
backend_name,
&req.source,
min_disk_size_gib,
block_size,
Expand All @@ -364,7 +370,7 @@ async fn make_disk<'req>(
as Arc<dyn DiskConfig>,
DiskBackend::InMemory { readonly } => framework
.disk_factory
.create_in_memory_disk(name, &req.source, readonly)
.create_in_memory_disk(backend_name, &req.source, readonly)
.await
.with_context(|| {
format!("creating new in-memory disk from {:?}", req.source)
Expand Down

0 comments on commit 59b6bfc

Please sign in to comment.