mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 00:17:11 +00:00
8ddbf05924
* test(targets): ship a builder MockTarget testkit and retire the in-crate Target mocks Adds crates/targets/src/testkit.rs with a builder-style MockTarget implementing Target<E> for every E: PluginEvent, with orthogonal off-by-default knobs: disabled/active override, health delay plus health-started signal plus a drop-guard counter proving a cancelled probe future was dropped, an init failure budget (usize::MAX = always fail) plus blocking init plus an init counter, a close counter/signal/semaphore gate with a runtime block toggle, a save counter plus save failure budget, caller-supplied store and failed-store handles, and a shared final-failure counter. Clones and clone_dyn share all counters, so an observer clone keeps watching a target after it is boxed into a runtime. The module is gated as #[cfg(any(test, feature = "test-support"))]: in-crate unit tests get it via cfg(test), and downstream test suites opt in through the new off-by-default test-support cargo feature (test-support = [], activating no dependencies). Migrates the five in-crate duplicate mocks onto it: the plugin.rs registry-factory TestTarget, the runtime/adapter.rs lifecycle TestTarget (init/close/store knobs), the runtime/mod.rs TestTarget plus HealthDropGuard (close gating and health-probe tests), the target/mod.rs MoveTestTarget (folded into the test_support helper constructors used by the NATS JetStream failed-store tests), and the target/mod.rs StoreBackedTarget (the default send_from_store purge test; the mock deliberately does not override send_from_store or handle_terminal_failure). The forced init failure now uses TargetError::Initialization instead of the old adapter mock's Configuration; the adapter derives its redacted failure summary from the target id alone, so the migrated assertions are unchanged. Leak guard: testkit unit tests assert the crate manifest still declares default = [] and that test-support = [] stays a pure cfg gate, complementing the compile-level cfg gate that keeps the mock out of production builds. Part of rustfs/backlog#1846 (cluster 3, step 1). * test(notify,audit): migrate the Target mocks onto the shared testkit Retires the hand-written Target mocks in crates/notify and crates/audit in favor of rustfs_targets::testkit::MockTarget: notify's notifier.rs TestTarget/DeferredTestTarget/ClosableTestTarget, lifecycle.rs BlockingInitTarget/RetryInitTarget (rebuilt as observed MockTarget templates cloned by their plugin-descriptor factories, sharing the init signal, close counter, and single-failure init budget across generations), runtime_view.rs TestTarget, runtime_facade.rs TestTarget, and audit's pipeline.rs MockTarget, system.rs TestTarget, registry.rs CloseTestTarget, plus TestTarget and FailingTarget in audit/tests/pipeline_layer_test.rs. Removing the two integration-test mocks also removes their respelled PluginEvent bound (E: Send + Sync + 'static + Clone + Serialize + DeserializeOwned), which the plugin-contract rules require to be spelled only via PluginEvent. lifecycle.rs ReplayTarget stays bespoke on purpose: its generation tags, mpsc observation channels, gated send_raw delivery, and ObservedQueueStore model the replay pipeline itself and would contort a general-purpose mock. The other bespoke mocks named out of scope in PR-3a (ProgrammedTarget, ClassifyingTarget, the ReloadableTargetTls fakes) are likewise untouched. New testkit knobs, each defaulted off and unit-tested: with_id (rename a clone while keeping the shared counters, for factory templates), with_first_save_gate (the first save notifies entered and waits on release; several mocks may share one pair), with_health_gate (is_active waits on a release handle after notifying health_started), with_delivery_snapshot (fixed snapshot overriding the store-derived default), with_close_failures (close-failure budget, default TargetError::Storage) with with_close_failure_error to shape the variant (audit's registry test pins TargetError::Unknown), and an always-on is_enabled call counter exposed as enabled_call_count (notifier's generation tests count dispatcher selections through it). Both crates enable the testkit through a dev-dependency on rustfs-targets with the test-support feature; the feature stays out of default and activates no dependencies, so production builds are unchanged. Part of rustfs/backlog#1846 (cluster 3, step 2).
112 lines
4.6 KiB
TOML
112 lines
4.6 KiB
TOML
[package]
|
|
name = "rustfs-targets"
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
rust-version.workspace = true
|
|
version.workspace = true
|
|
homepage.workspace = true
|
|
description = "Notification target abstraction and implementations for RustFS"
|
|
keywords = ["file-system", "notification", "target", "rustfs", "Minio"]
|
|
categories = ["web-programming", "development-tools", "filesystem"]
|
|
documentation = "https://docs.rs/rustfs-targets/latest/rustfs_targets/"
|
|
|
|
[features]
|
|
default = []
|
|
# Exposes the builder-style `testkit::MockTarget` to downstream test suites. Never enable this
|
|
# from a production `[dependencies]` entry; in-crate unit tests get the module via cfg(test).
|
|
test-support = []
|
|
hotpath = [
|
|
"hotpath/hotpath",
|
|
"hotpath/tokio",
|
|
"hotpath/futures",
|
|
"hotpath/parking_lot",
|
|
"hotpath/reqwest-0-13",
|
|
"rustfs-config/hotpath",
|
|
"rustfs-extension-schema/hotpath",
|
|
"rustfs-s3-types/hotpath",
|
|
"rustfs-tls-runtime/hotpath",
|
|
"rustfs-utils/hotpath",
|
|
]
|
|
hotpath-alloc = [
|
|
"hotpath",
|
|
"hotpath/hotpath-alloc",
|
|
"rustfs-config/hotpath-alloc",
|
|
"rustfs-extension-schema/hotpath-alloc",
|
|
"rustfs-s3-types/hotpath-alloc",
|
|
"rustfs-tls-runtime/hotpath-alloc",
|
|
"rustfs-utils/hotpath-alloc",
|
|
]
|
|
hotpath-cpu = [
|
|
"hotpath",
|
|
"hotpath/hotpath-cpu",
|
|
"rustfs-config/hotpath-cpu",
|
|
"rustfs-extension-schema/hotpath-cpu",
|
|
"rustfs-s3-types/hotpath-cpu",
|
|
"rustfs-tls-runtime/hotpath-cpu",
|
|
"rustfs-utils/hotpath-cpu",
|
|
]
|
|
|
|
[dependencies]
|
|
hotpath.workspace = true
|
|
rustfs-config = { workspace = true, features = ["notify", "audit", "server-config-model"] }
|
|
rustfs-extension-schema = { workspace = true }
|
|
rustfs-tls-runtime = { workspace = true }
|
|
rustfs-s3-types = { workspace = true }
|
|
rustfs-utils = { workspace = true, features = ["egress"] }
|
|
async-trait = { workspace = true }
|
|
futures-util = { workspace = true }
|
|
async-nats = { workspace = true, features = ["server_2_10", "server_2_11", "server_2_12", "server_2_14", "service", "aws-lc-rs", "nkeys", "object-store", "kv", "websockets", "nuid"] }
|
|
deadpool-postgres = { workspace = true }
|
|
hyper = { workspace = true, features = ["http2", "http1", "server"] }
|
|
hyper-rustls = { workspace = true, default-features = false, features = ["native-tokio", "tls12", "logging", "aws-lc-rs"] }
|
|
lapin = { workspace = true, default-features = false, features = ["tokio", "rustls", "rustls--aws_lc_rs"] }
|
|
libc = { workspace = true }
|
|
# pulsar regenerates its protobuf bindings from `PulsarApi.proto` in build.rs on every
|
|
# build, which needs `protoc`. Keep this dependency lean and install a system
|
|
# protobuf compiler on platforms where it is not provided by the base image.
|
|
# See https://github.com/rustfs/rustfs/issues/3195.
|
|
pulsar = { workspace = true, default-features = false, features = ["tokio-rustls-runtime", "telemetry"] }
|
|
regex = { workspace = true }
|
|
rayon = { workspace = true }
|
|
reqwest = { workspace = true }
|
|
rumqttc = { workspace = true, features = ["websocket"] }
|
|
redis = { workspace = true, features = ["connection-manager", "tokio-rustls-comp", "tls-rustls-insecure"] }
|
|
rustls = { workspace = true, default-features = false, features = ["aws-lc-rs", "logging", "tls12", "prefer-post-quantum", "std"] }
|
|
rustls-native-certs = { workspace = true }
|
|
s3s = { workspace = true, features = ["minio"] }
|
|
serde = { workspace = true, features = ["derive"] }
|
|
serde_json = { workspace = true, features = ["raw_value"] }
|
|
sha2 = { workspace = true }
|
|
snap = { workspace = true }
|
|
thiserror = { workspace = true }
|
|
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "sync", "time"] }
|
|
tokio-util = { workspace = true }
|
|
tokio-postgres = { workspace = true, default-features = false, features = ["runtime", "with-serde_json-1"] }
|
|
tokio-postgres-rustls = { workspace = true }
|
|
tracing = { workspace = true }
|
|
url = { workspace = true }
|
|
urlencoding = { workspace = true }
|
|
uuid = { workspace = true, features = ["v4", "v7", "serde", "fast-rng", "macro-diagnostics"] }
|
|
sysinfo = { workspace = true, features = ["multithread"] }
|
|
rustfs-kafka-async = { workspace = true }
|
|
mysql_async = { workspace = true, default-features = false, features = ["default-rustls", "tracing"] }
|
|
jiff = { workspace = true }
|
|
parking_lot = { workspace = true }
|
|
hashbrown = { workspace = true, features = ["serde", "rayon"] }
|
|
arc-swap = { workspace = true }
|
|
metrics = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
criterion = { workspace = true, features = ["html_reports"] }
|
|
tempfile = { workspace = true }
|
|
rcgen = { workspace = true }
|
|
tracing-subscriber = { workspace = true, features = ["env-filter", "time"] }
|
|
|
|
[[bench]]
|
|
name = "queue_store_benchmark"
|
|
harness = false
|
|
|
|
[lints]
|
|
workspace = true
|