Skip to content

Commit

Permalink
test-utils: use a per-user temp crdb seed dir (#4300)
Browse files Browse the repository at this point in the history
Make crdb seed generation for tests more amenable to running in shared environments.
  • Loading branch information
luqmana authored Oct 19, 2023
1 parent 58c8c6e commit 1beda0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/buildomat/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ptime -m timeout 1h cargo test --doc --locked --verbose --no-fail-fast
# We expect the seed CRDB to be placed here, so we explicitly remove it so the
# rmdir check below doesn't get triggered. Nextest doesn't have support for
# teardown scripts so this is the best we've got.
rm -rf "$TEST_TMPDIR/crdb-base"
rm -rf "$TEST_TMPDIR/crdb-base"*

#
# Make sure that we have left nothing around in $TEST_TMPDIR. The easiest way
Expand Down
10 changes: 6 additions & 4 deletions test-utils/src/dev/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ pub async fn ensure_seed_tarball_exists(
);
}

// XXX: we aren't considering cross-user permissions for this file. Might be
// worth setting more restrictive permissions on it, or using a per-user
// cache dir.
// If possible, try for a per-user folder in the temp dir
// to avoid clashes on shared build environments.
let crdb_base = std::env::var("USER")
.map(|user| format!("crdb-base-{user}"))
.unwrap_or("crdb-base".into());
let base_seed_dir = Utf8PathBuf::from_path_buf(std::env::temp_dir())
.expect("Not a UTF-8 path")
.join("crdb-base");
.join(crdb_base);
std::fs::create_dir_all(&base_seed_dir).unwrap();
let mut desired_seed_tar = base_seed_dir.join(digest_unique_to_schema());
desired_seed_tar.set_extension("tar");
Expand Down

0 comments on commit 1beda0b

Please sign in to comment.