-
Notifications
You must be signed in to change notification settings - Fork 40
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
[crdb-seed] use a tarball, fix omicron-dev run-all #4208
[crdb-seed] use a tarball, fix omicron-dev run-all #4208
Conversation
Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
I tried migrating the function to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, leaving this as a single artifact seems simpler to manage.
Seems like we'd still be at-risk of a /tmp
cleaner deleting this directory, say, "after nextest setup begins, but before the test executes", but I'm not sure we can ever deal with that problem while still using /tmp
.
test-utils/src/dev/mod.rs
Outdated
} | ||
|
||
// TODO: switch to anyhow entirely -- this function is currently a mishmash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, this appears to already be using an anyhow::Result
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is currently a mishmash of anyhow::Result
and unwrap
/expect
. I've expanded the comment to make this clearer.
Created using spr 1.3.4
Created using spr 1.3.4
I also added a way to invalidate the cache with |
Created using spr 1.3.4
A help message for the |
Hmm, any thoughts on checking that Maybe we could also add a README. |
Created using spr 1.3.4
Created using spr 1.3.4
Requesting review again because I added a bunch of new stuff to the PR. |
Created using spr 1.3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, mod one comment clarifying mtimes!
test-utils/src/dev/seed.rs
Outdated
/// This method should _not_ be used by tests. Instead, rely on the `crdb-seed` | ||
/// setup script. | ||
pub async fn ensure_seed_tarball_exists( | ||
log: &Logger, | ||
why_invalidate: Option<&str>, | ||
) -> Result<(Utf8PathBuf, SeedTarballStatus)> { | ||
// If the CRDB_SEED_TAR_ENV variable is set, return an error. | ||
if let Ok(val) = std::env::var(CRDB_SEED_TAR_ENV) { | ||
anyhow::bail!( | ||
"{CRDB_SEED_TAR_ENV} is set to `{val}` -- implying that a test called \ | ||
ensure_seed_tarball_exists. Instead, tests should rely on the `crdb-seed` \ | ||
setup script." | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a bit of a proxy for #[ifcfg(not(test))]
-- is that too extreme of a conditional qualifier to put on this method?
It does seem like it would make crdb-seed
, the binary, untestable, but I think it would enforce more accurately what the comments are describing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dependency (not a leaf node) so I don't think cfg(not(test))
would work? And if I try gating it behind a feature flag, the issue would be that omicron-dev
needs this function and so feature unification would mean this gets included in test binaries if you're doing a top-level cargo test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I ended up both preserving this check and gating it behind a feature flag. So we're triply sure this module isn't used by code other than omicron-dev and crdb-seed.
test-utils/src/dev/seed.rs
Outdated
std::fs::OpenOptions::new() | ||
.append(true) | ||
.open(&desired_seed_tar) | ||
.context("failed to touch seed tarball")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sufficient to update mtime, if the file exists? If the file already exists, but nothing is written, I would have suspected that this does not update the underlying timestamp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really really good catch, thank you. I think I may end up using the filetime crate as in https://github.com/uutils/coreutils/blob/a596cda51612e72b5245ccb8c2fa6c05a89569a7/src/uu/touch/src/touch.rs#L205-L207.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, the filetime crate works great.
test-utils/src/dev/seed.rs
Outdated
// The tarball didn't exist when we started, so try to create it. | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the tarball no longer exists
If why_invalidated
is Some, it might have existed, but been removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanded this comment:
// At this point the tarball does not exist (either because it didn't exist
// in the first place or because it was deleted above), so try to create it.
Created using spr 1.3.4
Created using spr 1.3.4
Several changes:
crdb-seed
more robust to missing files #4193, @david-crespo observed some missing files in the crdb-seed generated directory. My suspicion is that that is due to the/tmp
cleaner that runs on macOS. @davepacheco suggested using a tarball to get atomicity (either the file exists or it doesn't), and it ended up being pretty simple to do that at the end.omicron-dev run-all
and anything else that uses nexus-test-utils (and avoiding a dependency on the environment).crdb-seed
todev-tools
(thanks Dave for pointing it out!)CRDB_SEED_INVALIDATE=1
in the environment.crdb-seed
.Fixes #4206.
Hopefully addresses #4193.