Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phd: automatically fetch crucible-downstairs from Buildomat #604

Merged
merged 9 commits into from
Jan 17, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Jan 16, 2024

Currently, in order to run the phd tests that involve Crucible disks,
the path to a local crucible-downstairs binary must be provided via a
command-line argument. When no crucible-downstairs binary path is
provided, the tests that use Crucible are skipped. This means that the
tests which use Crucible disks are not currently able to run on CI, as
no crucible-downstairs binary is present.

This branch extends the phd-framework crate's artifact store to
support automatically fetch a crucible-downstairs binary from
Buildomat when configured via the command line. This PR adds a new
--crucible-downstairs-commit CLI argument to phd-runner. If present,
this argument configures PHD to fetch a crucible-downstairs binary
from Buildomat.

The --crucible-downstairs-commit argument can either be the string
auto, or a 40-character Git hash. When auto is passed, Git revision
to fetch from Buildomat is determined automatically based on the
propolis workspace's Git dependency on the crucible crate, to ensure
that the downstairs binary matches the version of the upstairs library
that Propolis was built against. Otherwise, if a Git hash is provided,
the artifact for that commit hash is fetched from Buildomat, instead.

The behavior of the existing --crucible-downstairs-cmd is unchanged,
so a local crucible-downstairs binary can still be used rather than
downloading it from Buildomat. This way, users can still run phd tests
against a local Crucible build, if necessary. The new
--crucible-downstairs-commit argument conflicts with
--crucible-downstairs-cmd, so if both are provided, phd-runner will
print an error. If neither argument is provided, tests that require
Crucible are skipped, maintaining the default behavior of not
downloading anything unless explicitly configured to.

The Buildomat job for Crucible publishes the entire Illumos Crucible
zone as a tarball, rather than separate files for each artifact.
Therefore, it was necessary to extend the phd-framework artifact store
to support a configuration for extracting an individual file from within
a tarball. The SHA256 used for the artifact is the SHA of the entire
tarball, since Crucible's Buildomat job publishes the tarball's SHA, but
once the tarball is downloaded, the crucible-downstairs binary is
extracted from the tarball into the object store.

hawkw added 5 commits January 12, 2024 16:45
apparently when running PHD on CI, the `phd-runner` binary isn't
in the Propolis workspace, so we need to determine the Git rev at build
time, instead.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 255 files.

Valid Invalid Ignored Fixed
190 1 64 0
Click to see the invalid file list
  • phd-tests/runner/build.rs

phd-tests/runner/build.rs Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@hawkw hawkw marked this pull request as ready for review January 16, 2024 17:50
@hawkw hawkw requested a review from gjcolombo January 16, 2024 17:50
@hawkw hawkw added the testing Related to testing and/or the PHD test framework. label Jan 16, 2024
phd-tests/runner/src/config.rs Outdated Show resolved Hide resolved
phd-tests/runner/src/main.rs Outdated Show resolved Hide resolved
phd-tests/framework/src/artifacts/mod.rs Outdated Show resolved Hide resolved
phd-tests/framework/src/artifacts/store.rs Show resolved Hide resolved
phd-tests/framework/src/artifacts/store.rs Outdated Show resolved Hide resolved
@hawkw hawkw requested a review from gjcolombo January 17, 2024 20:28
Copy link
Contributor

@gjcolombo gjcolombo left a comment

Choose a reason for hiding this comment

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

Looks great--thanks for working on all this!

@hawkw hawkw merged commit ed21e45 into master Jan 17, 2024
10 checks passed
@hawkw hawkw deleted the eliza/phd-crucible branch January 17, 2024 22:59
hawkw added a commit that referenced this pull request Jan 21, 2024
In order to ensure that changes to `propolis` don't break instance
migration from previous versions, we would like to add automated testing
of migrating an instance from the current `master` branch of `propolis`
to run on PR branches. This PR adds an implementation of such a test to
`phd`.

To implement this, I've built on top of my change from PR #604 and
modified the `phd` artifact store to introduce a notion of a "base"
Propolis server artifact. This artifact can then be used to test
migration from the "base" Propolis version to the revision under
test. I've added a new test case in `migrate.rs` that creates a source
VM using the "base" Propolis artifact and attempts to migrate that
instance to a target VM running on the "default" Propolis artifact (the
revision being tested). In order to add the new test, I've factored out
test code from the existing `migrate::smoke_test` test.

How `phd` should acquire a "base" Propolis artifact is configured by
several new command-line arguments. `--base-propolis-branch` takes
the name of a Git branch on the `propolis` repo. If this argument is
provided, PHD will download the Propolis debug artifact from the HEAD
commit of that branch from Buildomat. Alternatively, the
`--base-propolis-commit` argument accepts a Git commit hash to
download from Buildomat. Finally, the `--base-propolis-cmd` argument
takes a local path to a binary to use as the "base" Propolis. All
these arguments are mutually exclusive, and if none of them are
provided, the migration-from-base tests are skipped.

When the "base" Propolis artifact is configured from a Git branch
name (i.e. the `--base-propolis-branch` CLI argument is passed), we
use the Buildomat `/public/branch/{repo}/{branch-name}` endpoint, which
returns the Git hash of the HEAD commit to that branch. Then, we attempt
to download an artifact from Buildomat for that commit hash. An issue
here is that Buildomat's branch endpoint will return the latest commit
hash for that branch as soon as it sees a commit, but the artifact for
that commit may not have been published yet, so downloading it will
fail. Ideally, we could resolve this sort of issue by configuring the
`phd-run` job for PRs to depend on the `phd-build` job for `master`, so
that the branch's test run isn't started until any commits that just
merged to `master` have published artifacts. However, this isn't
basely possible in Buildomat (see oxidecomputer/buildomat#46). As a
temporary workaround, I've added code to the PHD artifact store to retry
downloading Buildomat artifacts with an exponential backoff, for up to a
configurable duration (defaulting to 20 minutes). This allows us to wait
for an in-progress build to complete, with a limit on how long we'll
wait for.

Depends on #604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Related to testing and/or the PHD test framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants