mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
f05a69d51b
* test(utils): add rustfs-test-utils crate, absorb heal/iam ECStore bootstrap
backlog#1153 infra-1. The ~50-line "build a real temp-disk ECStore"
bootstrap was copy-pasted (and drifting) across the heal and iam
integration tests. This adds crates/test-utils (rustfs-test-utils, a
dev-dependency-only crate) owning that bootstrap and converts the four
copies into thin wrappers:
- TestECStoreEnvBuilder: disk_count (default 4), prefix (uuid-suffixed
/tmp dir), base_dir (caller-owned dir, e.g. tempfile::TempDir),
init_bucket_metadata (default true; the iam bootstrap test opts out
to preserve its historical semantics). TestECStoreEnv exposes
temp_root/disk_paths/ecstore plus a versioned-bucket helper, and
init_tracing() replaces the per-file Once blocks.
- All rustfs_ecstore imports stay behind src/ecstore_test_compat.rs,
the sanctioned test-compat boundary pattern (mirrors
crates/iam/tests/ecstore_test_compat).
- heal: heal_integration_test / heal_b5_versioned_regression_test /
heal_b920_subquorum_union_test drop their setup_test_env{,_n} copies
for heal_env{,_n} wrappers; the tests/storage_api.rs integration
surface shrinks to what test bodies still touch.
- iam: iam_bootstrap_no_lock_test drops build_local_ecstore; its
ecstore_test_compat fixture shrinks to SetupType +
update_erasure_type.
rg 'async fn setup_test_env' crates/heal crates/iam now returns 0.
Scanner's lifecycle tests are deliberately NOT absorbed (gated on
ilm-1; 14 of 15 are #[ignore]d today). Net -230 lines.
* fix(heal): drop tokio::fs import orphaned by the b920 bootstrap move
* fix(heal): drop tokio::fs import orphaned by the b5 bootstrap move
57 lines
2.4 KiB
Markdown
57 lines
2.4 KiB
Markdown
# rustfs-test-utils
|
|
|
|
Shared bootstrap helpers for RustFS integration tests (backlog#1153 infra-1).
|
|
Owns the "build a real temp-disk `ECStore`" setup that used to be copy-pasted
|
|
across the heal/iam/scanner integration tests and had already drifted.
|
|
|
|
## Usage
|
|
|
|
```rust
|
|
// [dev-dependencies] rustfs-test-utils = { workspace = true }
|
|
use rustfs_test_utils::TestECStoreEnv;
|
|
|
|
let env = TestECStoreEnv::builder()
|
|
.prefix("rustfs_myfeature_test") // /tmp/<prefix>_<uuid>
|
|
.disk_count(4) // single pool, single set
|
|
.build()
|
|
.await;
|
|
|
|
env.make_bucket("my-bucket", /* versioned = */ true).await;
|
|
// env.ecstore : Arc<ECStore> — bootstrapped store
|
|
// env.disk_paths : Vec<PathBuf> — disk1..diskN for fault injection
|
|
// env.temp_root : PathBuf — root dir (leaked by design, see below)
|
|
```
|
|
|
|
Builder knobs:
|
|
|
|
- `disk_count(n)` — disks in the single erasure set (default 4).
|
|
- `prefix(&str)` — temp-dir prefix; a uuid suffix keeps parallel nextest
|
|
processes isolated.
|
|
- `base_dir(path)` — use a caller-owned directory (e.g. `tempfile::TempDir`)
|
|
instead; the caller keeps cleanup ownership.
|
|
- `init_bucket_metadata(bool)` — run `init_bucket_metadata_sys` after boot
|
|
(default `true`; the IAM bootstrap test opts out).
|
|
|
|
`init_tracing()` is exposed separately and is called by `build()`.
|
|
|
|
The environment does **not** delete `temp_root` on drop: a failed test's
|
|
on-disk state stays inspectable, and heal tests keep manipulating
|
|
`disk_paths` after setup. Own the directory via `base_dir` if you want
|
|
automatic cleanup.
|
|
|
|
## Constraints
|
|
|
|
- **dev-dependency only.** No crate may list `rustfs-test-utils` under
|
|
`[dependencies]` — test scaffolding must never reach production binaries.
|
|
- **Single-process integration scope.** Multi-node / chaos harnesses are out
|
|
of scope (backlog#1100). Scanner's lifecycle tests are absorbed only after
|
|
ilm-1 activates them (they are `#[ignore]`d today).
|
|
- All `rustfs_ecstore` imports stay behind `src/ecstore_test_compat.rs` — the
|
|
sanctioned test-compat boundary pattern enforced by
|
|
`scripts/check_architecture_migration_rules.sh`. Extend that module, never
|
|
import the facade directly from other files.
|
|
- Tests using this env bind `127.0.0.1:0` (random port) and unique temp dirs,
|
|
so they stay parallel-safe under nextest's process-per-test model — do not
|
|
add fixed ports or shared paths here. See `docs/testing/README.md` for the
|
|
serial/nextest rules.
|