Skip to content

phd: add smoke test for VCR replacement#872

Merged
gjcolombo merged 4 commits into
masterfrom
gjcolombo/phd-vcr-smoke-test
Feb 27, 2025
Merged

phd: add smoke test for VCR replacement#872
gjcolombo merged 4 commits into
masterfrom
gjcolombo/phd-vcr-smoke-test

Conversation

@gjcolombo

Copy link
Copy Markdown
Contributor

Add a smoke test for Crucible VCR replacement:

  • Add a CrucibleDisk function to get a disk's current VCR.
  • Add a TestVm framework to send a VCR replacement request.
  • Fix a couple of bugs in Crucible disk setup:
    • The id field in the VCR's CrucibleOpts needs to be the same in the old and new VCRs, so use the disk ID for it instead of calling Uuid::new_v4() every time the VCR is generated.
    • When using a Blank disk source, properly account for the fact that the disk source size is given in bytes, not gibibytes.

Also add a couple of bells and whistles to allow this test to be transformed into a test of VCR replacement during VM startup:

  • Make PHD's VmSpec type a public type and amend Framework to allow tests to create a VM from a spec. This gives tests a way to access a config's Crucible disks before actually launching a VM (and sending an instance spec to Propolis).
  • Reorganize the CrucibleDisk types to wrap the disk innards in a Mutex, allowing them to be mutated through the Arc references that tests get. This will eventually be used to allow tests to override the downstairs addresses in a disk's VCRs before launching a VM that uses that disk, which will be used to test fixes for want Crucible VCR replacement to be able to proceed before a VM has fully started #841. In the meantime, use the mutex to protect the VCR generation number, which no longer needs to be an AtomicU64.

@gjcolombo gjcolombo requested review from iximeow and leftwo February 24, 2025 23:03

@hawkw hawkw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is pretty straightforward! i had a couple teensy nitpicks.

Comment thread phd-tests/framework/src/test_vm/mod.rs
Comment thread phd-tests/tests/src/crucible/smoke.rs Outdated
Comment thread phd-tests/framework/src/disk/crucible.rs Outdated

@iximeow iximeow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 to Eliza's comments, plus maybe bonus wrinkle in the new test?

Comment thread phd-tests/tests/src/crucible/smoke.rs Outdated
@gjcolombo

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews! I'll rebase and merge this later today; should have a PR with a fix for #841 up shortly after.

Add a smoke test for Crucible VCR replacement:

- Add a `CrucibleDisk` function to get a disk's current VCR.
- Add a `TestVm` framework to send a VCR replacement request.
- Fix a couple of bugs in Crucible disk setup:
  - The `id` field in the VCR's `CrucibleOpts` needs to be the same in
    the old and new VCRs, so use the disk ID for it instead of
    calling `Uuid::new_v4()` every time the VCR is generated.
  - When using a `Blank` disk source, properly account for the fact
    that the disk source size is given in bytes, not gibibytes.

Also add a couple of bells and whistles to allow this test to be
transformed into a test of VCR replacement during VM startup:

- Make PHD's `VmSpec` type a public type and amend `Framework` to allow
  tests to create a VM from a spec. This gives tests a way to access
  a config's Crucible disks before actually launching a VM (and sending
  an instance spec to Propolis).
- Reorganize the `CrucibleDisk` types to wrap the disk innards in a
  `Mutex`, allowing them to be mutated through the `Arc` references that
  tests get. This will eventually be used to allow tests to override the
  downstairs addresses in a disk's VCRs before launching a VM that uses
  that disk, which will be used to test #841. In the meantime, use the
  mutex to protect the VCR generation number, which no longer needs to
  be an `AtomicU64`.

@leftwo leftwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think any questions I have are more applicable to #873, so I'll go review that now :)

read_only: false,
},
gen,
r#gen: self.generation,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is what I wanted to see!


// Create a blank data disk on which to perform VCR replacement. This is
// necessary because Crucible doesn't permit VCR replacements for volumes
// whose read-only parents are local files (which is true for artifact-based

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should update that. Crucible does support replacement of read only parents now, so perhaps we need to update the file based backend?

Though, testing on a data disk is also needed, so not like this is bad or wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're tracking this with oxidecomputer/crucible#1658.

@gjcolombo gjcolombo merged commit 42b8735 into master Feb 27, 2025
@gjcolombo gjcolombo deleted the gjcolombo/phd-vcr-smoke-test branch February 27, 2025 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants