mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-03 14:49:29 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21419611e8 |
@@ -76,6 +76,7 @@ rustfs-webdav.code-workspace
|
||||
*.bak
|
||||
# Local test/benchmark artifacts
|
||||
benchmarks.logs
|
||||
tests/dst/results/
|
||||
tmp/
|
||||
crates/*/docs
|
||||
fuzz/target
|
||||
|
||||
Generated
+9
@@ -9812,6 +9812,15 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustfs-dst"
|
||||
version = "1.0.7"
|
||||
dependencies = [
|
||||
"rustfs-ecstore",
|
||||
"rustfs-filemeta",
|
||||
"rustfs-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustfs-ecstore"
|
||||
version = "1.0.7"
|
||||
|
||||
@@ -25,6 +25,7 @@ members = [
|
||||
"crates/crypto", # Cryptography and security features
|
||||
"crates/ecstore", # Erasure coding storage implementation
|
||||
"crates/e2e_test", # End-to-end test suite
|
||||
"tests/dst", # Deterministic simulation harness (publish = false)
|
||||
"crates/filemeta", # File metadata management
|
||||
"crates/heal", # Erasure set and object healing
|
||||
"crates/heal-contracts", # Heal request/response channel contracts
|
||||
|
||||
@@ -117,6 +117,9 @@ hotpath-cpu = [
|
||||
# injection, xl.meta transition assertions) via `api::tier::test_util`.
|
||||
# Enable only from `[dev-dependencies]` (rustfs/backlog#1148 ilm-6).
|
||||
test-util = []
|
||||
# Re-exports durability primitives for the deterministic simulation harness.
|
||||
# Absent from production binaries. Enabling it does not change storage behavior.
|
||||
dst = []
|
||||
# Observes real startup CAS only in the dedicated E2E binary.
|
||||
e2e-test-hooks = []
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Test-only surface for deterministic simulation.
|
||||
//!
|
||||
//! Compiled only with `--features dst`. The types below wrap private
|
||||
//! durability code so the harness can call it without widening the
|
||||
//! production API. Production binaries do not enable the feature.
|
||||
|
||||
pub use rustfs_lock::{exclusive_lock_quorum, shared_lock_quorum};
|
||||
|
||||
use crate::disk::error::DiskError;
|
||||
use crate::disk::error_reduce::{OBJECT_OP_IGNORED_ERRS, reduce_read_quorum_errs, reduce_write_quorum_errs};
|
||||
use crate::erasure::coding::Erasure;
|
||||
use crate::layout::disks_layout::DisksLayout;
|
||||
use std::io;
|
||||
|
||||
/// One erasure codec. `encode` / `decode` call `Erasure::encode_data` and `Erasure::decode_data`.
|
||||
pub struct SimCodec {
|
||||
inner: Erasure,
|
||||
}
|
||||
|
||||
impl SimCodec {
|
||||
/// # Errors
|
||||
/// Returns the production constructor error when the geometry is rejected.
|
||||
pub fn try_new(data_shards: usize, parity_shards: usize, block_size: usize) -> Result<Self, String> {
|
||||
Erasure::try_new(data_shards, parity_shards, block_size)
|
||||
.map(|inner| Self { inner })
|
||||
.map_err(|error| format!("{error}"))
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
/// Returns the production encode error.
|
||||
pub fn encode(&self, data: &[u8]) -> Result<Vec<Vec<u8>>, String> {
|
||||
self.inner
|
||||
.encode_data(data)
|
||||
.map(|shards| shards.into_iter().map(|shard| shard.to_vec()).collect())
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
/// Reconstructs missing shards in place.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns the production decode error.
|
||||
pub fn decode(&self, shards: &mut [Option<Vec<u8>>]) -> Result<(), String> {
|
||||
self.inner.decode_data(shards).map_err(|error| error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// Drive outcomes the production quorum reducer understands.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum SimDiskFault {
|
||||
DiskNotFound,
|
||||
FaultyDisk,
|
||||
FileNotFound,
|
||||
FileCorrupt,
|
||||
}
|
||||
|
||||
pub fn default_parity_count(drive_count: usize) -> usize {
|
||||
crate::config::storageclass::default_parity_count(drive_count)
|
||||
}
|
||||
|
||||
pub fn read_quorum(drive_count: usize, parity: usize) -> usize {
|
||||
crate::set_disk::quorum_math::read_quorum(drive_count, parity)
|
||||
}
|
||||
|
||||
pub fn write_quorum(drive_count: usize, parity: usize) -> usize {
|
||||
crate::set_disk::quorum_math::write_quorum(drive_count, parity)
|
||||
}
|
||||
|
||||
/// `Ok(true)` when `reduce_write_quorum_errs` reports success.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns when that reducer disagrees with a success count that has no
|
||||
/// non-ignored errors. That disagreement is a production bug.
|
||||
pub fn write_quorum_met(faults: &[Option<SimDiskFault>], quorum: usize) -> Result<bool, String> {
|
||||
quorum_met(faults, quorum, true)
|
||||
}
|
||||
|
||||
/// `Ok(true)` when `reduce_read_quorum_errs` reports success.
|
||||
///
|
||||
/// # Errors
|
||||
/// Same contract as [`write_quorum_met`].
|
||||
pub fn read_quorum_met(faults: &[Option<SimDiskFault>], quorum: usize) -> Result<bool, String> {
|
||||
quorum_met(faults, quorum, false)
|
||||
}
|
||||
|
||||
/// Expand one volume argument with the default set-width selector.
|
||||
///
|
||||
/// `set_drive_count` is `0`, which is what production uses when
|
||||
/// `RUSTFS_ERASURE_SET_DRIVE_COUNT` is unset. Each inner vector is one set,
|
||||
/// in endpoint order.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns the layout parser error.
|
||||
pub fn layout_sets(volume: &str) -> io::Result<Vec<Vec<String>>> {
|
||||
let layout = DisksLayout::from_volumes_with_set_drive_count(&[volume], 0)?;
|
||||
let Some(pool) = layout.pools.first() else {
|
||||
return Err(io::Error::other("erasure layout did not produce a pool"));
|
||||
};
|
||||
Ok(pool.iter().cloned().collect())
|
||||
}
|
||||
|
||||
fn quorum_met(faults: &[Option<SimDiskFault>], quorum: usize, write: bool) -> Result<bool, String> {
|
||||
let errors: Vec<Option<DiskError>> = faults.iter().map(|fault| fault.as_ref().map(to_disk_error)).collect();
|
||||
let decision = if write {
|
||||
reduce_write_quorum_errs(&errors, OBJECT_OP_IGNORED_ERRS, quorum)
|
||||
} else {
|
||||
reduce_read_quorum_errs(&errors, OBJECT_OP_IGNORED_ERRS, quorum)
|
||||
};
|
||||
let successes = errors.iter().filter(|error| error.is_none()).count();
|
||||
let non_ignored = errors
|
||||
.iter()
|
||||
.flatten()
|
||||
.filter(|error| !OBJECT_OP_IGNORED_ERRS.iter().any(|ignored| ignored == *error))
|
||||
.count();
|
||||
if successes >= quorum && non_ignored == 0 && decision.is_some() {
|
||||
return Err(format!("reducer rejected {successes} successes >= quorum {quorum}"));
|
||||
}
|
||||
if successes < quorum && non_ignored == 0 && decision.is_none() {
|
||||
return Err(format!("reducer accepted {successes} successes < quorum {quorum}"));
|
||||
}
|
||||
Ok(decision.is_none())
|
||||
}
|
||||
|
||||
fn to_disk_error(fault: &SimDiskFault) -> DiskError {
|
||||
match fault {
|
||||
SimDiskFault::DiskNotFound => DiskError::DiskNotFound,
|
||||
SimDiskFault::FaultyDisk => DiskError::FaultyDisk,
|
||||
SimDiskFault::FileNotFound => DiskError::FileNotFound,
|
||||
SimDiskFault::FileCorrupt => DiskError::FileCorrupt,
|
||||
}
|
||||
}
|
||||
@@ -117,17 +117,25 @@ pub struct DisksLayout {
|
||||
|
||||
impl DisksLayout {
|
||||
pub fn from_volumes<T: AsRef<str>>(args: &[T]) -> Result<Self> {
|
||||
if args.is_empty() {
|
||||
return Err(Error::other("Invalid argument"));
|
||||
}
|
||||
|
||||
let is_ellipses = args.iter().any(|v| has_ellipses(&[v]));
|
||||
|
||||
let set_drive_count_env = env::var(ENV_RUSTFS_ERASURE_SET_DRIVE_COUNT).unwrap_or_else(|err| {
|
||||
debug!("{} not set use default:0, {:?}", ENV_RUSTFS_ERASURE_SET_DRIVE_COUNT, err);
|
||||
"0".to_string()
|
||||
});
|
||||
let set_drive_count: usize = set_drive_count_env.parse().map_err(Error::other)?;
|
||||
Self::from_volumes_with_set_drive_count(args, set_drive_count)
|
||||
}
|
||||
|
||||
/// Same selector as [`Self::from_volumes`] with an explicit set width.
|
||||
///
|
||||
/// `set_drive_count == 0` selects the default symmetric width. Callers that
|
||||
/// need the production default regardless of `RUSTFS_ERASURE_SET_DRIVE_COUNT`
|
||||
/// pass `0` here.
|
||||
pub(crate) fn from_volumes_with_set_drive_count<T: AsRef<str>>(args: &[T], set_drive_count: usize) -> Result<Self> {
|
||||
if args.is_empty() {
|
||||
return Err(Error::other("Invalid argument"));
|
||||
}
|
||||
|
||||
let is_ellipses = args.iter().any(|v| has_ellipses(&[v]));
|
||||
|
||||
// None of the args have ellipses use the old style.
|
||||
if !is_ellipses {
|
||||
|
||||
@@ -36,14 +36,16 @@ pub mod api;
|
||||
mod bucket;
|
||||
mod cache_value;
|
||||
mod cluster;
|
||||
mod config;
|
||||
pub(crate) mod config;
|
||||
mod core;
|
||||
mod crash_inject;
|
||||
mod data_movement;
|
||||
mod data_usage;
|
||||
mod diagnostics;
|
||||
mod disk;
|
||||
mod erasure;
|
||||
pub(crate) mod disk;
|
||||
#[cfg(feature = "dst")]
|
||||
pub mod dst_seam;
|
||||
pub(crate) mod erasure;
|
||||
mod error;
|
||||
mod io_support;
|
||||
pub(crate) mod layout;
|
||||
@@ -51,7 +53,7 @@ mod multipart_listing;
|
||||
mod object_api;
|
||||
mod runtime;
|
||||
mod services;
|
||||
mod set_disk;
|
||||
pub(crate) mod set_disk;
|
||||
mod storage_api_contracts;
|
||||
mod store;
|
||||
|
||||
|
||||
@@ -3756,16 +3756,11 @@ where
|
||||
|
||||
impl SetDisks {
|
||||
pub(in crate::set_disk) fn default_read_quorum(&self) -> usize {
|
||||
self.set_drive_count - self.default_parity_count
|
||||
super::quorum_math::read_quorum(self.set_drive_count, self.default_parity_count)
|
||||
}
|
||||
|
||||
pub(crate) fn default_write_quorum(&self) -> usize {
|
||||
let mut data_count = self.set_drive_count - self.default_parity_count;
|
||||
if data_count == self.default_parity_count {
|
||||
data_count += 1
|
||||
}
|
||||
|
||||
data_count
|
||||
super::quorum_math::write_quorum(self.set_drive_count, self.default_parity_count)
|
||||
}
|
||||
|
||||
pub(in crate::set_disk) async fn prepare_quota_mutation_fences(
|
||||
|
||||
@@ -21,3 +21,4 @@ pub(crate) mod io_primitives;
|
||||
pub(in crate::set_disk) mod metadata_quorum;
|
||||
pub(in crate::set_disk) mod metadata_read;
|
||||
pub(in crate::set_disk) mod multipart_source;
|
||||
pub(crate) mod quorum_math;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Erasure read/write quorum derived from a set's drive count and parity.
|
||||
//!
|
||||
//! `SetDisks::default_read_quorum` and `SetDisks::default_write_quorum` are
|
||||
//! thin wrappers over these functions. The per-object metadata reducer in
|
||||
//! `set_disk/metadata.rs` repeats the same arithmetic on `i32` values it has
|
||||
//! already validated; that path also rejects negative parity before the
|
||||
//! arithmetic, so it is intentionally left in place.
|
||||
|
||||
/// Drives that must agree for a read. Equal to the data-block count.
|
||||
pub(crate) fn read_quorum(drive_count: usize, parity: usize) -> usize {
|
||||
drive_count - parity
|
||||
}
|
||||
|
||||
/// Drives that must acknowledge a write.
|
||||
///
|
||||
/// This is the data-block count, plus one when data and parity are equal, so
|
||||
/// a symmetric layout cannot commit on a bare data quorum.
|
||||
pub(crate) fn write_quorum(drive_count: usize, parity: usize) -> usize {
|
||||
let mut data_count = drive_count - parity;
|
||||
if data_count == parity {
|
||||
data_count += 1;
|
||||
}
|
||||
data_count
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{read_quorum, write_quorum};
|
||||
|
||||
#[test]
|
||||
fn official_dst_set_widths_match_default_parity_quorum() {
|
||||
// 4 nodes x 4 disks -> one 16-drive set, default parity 4.
|
||||
assert_eq!(read_quorum(16, 4), 12);
|
||||
assert_eq!(write_quorum(16, 4), 12);
|
||||
// 3 nodes x 2 disks -> one 6-drive set, default parity 3.
|
||||
// Data equals parity, so the write quorum is bumped.
|
||||
assert_eq!(read_quorum(6, 3), 3);
|
||||
assert_eq!(write_quorum(6, 3), 4);
|
||||
}
|
||||
}
|
||||
@@ -901,6 +901,8 @@ mod core;
|
||||
pub(crate) use core::io_primitives::disk_call_counters;
|
||||
#[cfg(test)]
|
||||
pub(crate) use core::io_primitives::{ENV_RUSTFS_PUT_RENAME_EARLY_ACK_ENABLE, rename_fanout_barrier};
|
||||
#[cfg(feature = "dst")]
|
||||
pub(crate) use core::quorum_math;
|
||||
mod ctx;
|
||||
mod metadata;
|
||||
mod ops;
|
||||
@@ -6426,11 +6428,7 @@ impl SetDisks {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let write_quorum = if self.lockers.len() > 1 {
|
||||
(self.lockers.len() / 2) + 1
|
||||
} else {
|
||||
1
|
||||
};
|
||||
let write_quorum = rustfs_lock::exclusive_lock_quorum(self.lockers.len());
|
||||
|
||||
let mut lock_ids_by_object: Vec<Vec<(usize, rustfs_lock::LockId)>> = vec![Vec::new(); requests.len()];
|
||||
let mut errors_by_object: Vec<Option<String>> = vec![None; requests.len()];
|
||||
|
||||
@@ -77,7 +77,7 @@ impl SetDisks {
|
||||
};
|
||||
// Calculate quorum from the exact client domain used by this lock.
|
||||
let lockers_count = lockers.len();
|
||||
let write_quorum = if lockers_count > 1 { (lockers_count / 2) + 1 } else { 1 };
|
||||
let write_quorum = rustfs_lock::exclusive_lock_quorum(lockers_count);
|
||||
NamespaceLock::with_clients_and_quorum_shared(self.set_lock_namespace.clone(), lockers, write_quorum)
|
||||
} else {
|
||||
NamespaceLock::with_local_manager_shared(self.set_lock_namespace.clone(), self.local_lock_manager.clone())
|
||||
|
||||
@@ -634,12 +634,7 @@ impl DistributedLock {
|
||||
}
|
||||
|
||||
fn read_quorum(&self) -> usize {
|
||||
let client_count = self.clients.len();
|
||||
if client_count <= 1 {
|
||||
1
|
||||
} else {
|
||||
client_count - (client_count / 2)
|
||||
}
|
||||
crate::quorum::shared_lock_quorum(self.clients.len())
|
||||
}
|
||||
|
||||
fn required_quorum(&self, lock_type: LockType) -> usize {
|
||||
|
||||
@@ -29,8 +29,11 @@ pub mod fast_lock;
|
||||
|
||||
// Core Modules
|
||||
pub mod error;
|
||||
pub mod quorum;
|
||||
pub mod types;
|
||||
|
||||
pub use quorum::{exclusive_lock_quorum, shared_lock_quorum};
|
||||
|
||||
// ============================================================================
|
||||
// Public API Exports
|
||||
// ============================================================================
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Namespace-lock quorum sizes.
|
||||
//!
|
||||
//! Exclusive locks use a strict majority of the lock clients in the set.
|
||||
//! Shared locks use `client_count - client_count / 2`. Callers pass the
|
||||
//! client domain they actually vote with (one client per distinct node).
|
||||
|
||||
/// Shared / read-lock quorum for `client_count` lock clients.
|
||||
pub fn shared_lock_quorum(client_count: usize) -> usize {
|
||||
if client_count <= 1 {
|
||||
1
|
||||
} else {
|
||||
client_count - (client_count / 2)
|
||||
}
|
||||
}
|
||||
|
||||
/// Exclusive / write-lock quorum for `client_count` lock clients.
|
||||
pub fn exclusive_lock_quorum(client_count: usize) -> usize {
|
||||
if client_count > 1 { (client_count / 2) + 1 } else { 1 }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{exclusive_lock_quorum, shared_lock_quorum};
|
||||
|
||||
#[test]
|
||||
fn official_dst_node_counts_match_lock_quorum() {
|
||||
assert_eq!(exclusive_lock_quorum(4), 3);
|
||||
assert_eq!(shared_lock_quorum(4), 2);
|
||||
assert_eq!(exclusive_lock_quorum(3), 2);
|
||||
assert_eq!(shared_lock_quorum(3), 2);
|
||||
assert_eq!(exclusive_lock_quorum(1), 1);
|
||||
assert_eq!(shared_lock_quorum(1), 1);
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ Out of scope:
|
||||
|
||||
## Current Branch Snapshot
|
||||
|
||||
On this branch, `cargo metadata --format-version 1 --no-deps` reports 51 workspace members. None of the workspace package manifests set `publish = false`, so every member is eligible from Cargo's manifest perspective.
|
||||
On this branch, `cargo metadata --format-version 1 --no-deps` reports 52 workspace members. `tests/dst` (`rustfs-dst`) sets `publish = false`. Every other member is eligible from Cargo's manifest perspective.
|
||||
|
||||
The script always filters out the test-only `e2e_test` package, leaving 50 packages in the default publish plan. If another test-only or internal crate should not be published, set `publish = false` in that crate's manifest before publication. The script also supports `--exclude <package>`, but it will fail if any selected publishable crate still depends on the excluded package.
|
||||
The script always filters out the test-only `e2e_test` package and skips `publish = false`, leaving 50 packages in the default publish plan. If another test-only or internal crate should not be published, set `publish = false` in that crate's manifest before publication. The script also supports `--exclude <package>`, but it will fail if any selected publishable crate still depends on the excluded package.
|
||||
|
||||
The publish order below is the current topological order of workspace path dependencies:
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ Pick the lowest layer that can prove the change; add a higher-layer test only wh
|
||||
| s3s-e2e conformance | External S3 conformance tool against a live server | `./scripts/e2e-run.sh ./target/debug/rustfs <data-dir>` | Non-documentation PRs, required through `Test and Lint` (second half of the `End-to-End Tests` job) |
|
||||
| S3 compatibility | `ceph/s3-tests` (boto3; allow-list `scripts/s3-tests/implemented_tests.txt`) and MinIO `mint` | `scripts/s3-tests/run.sh`; mint via `.github/workflows/mint.yml` | Non-documentation PRs: implemented and lifecycle S3 lanes required through `Test and Lint`; the separate s3-tests workflow provides additional PR reporting and a weekly full sweep; mint: weekly, report-only |
|
||||
| Chaos / fault-injection | Single-node disk fault injection (`crates/e2e_test/src/chaos.rs`, `crates/e2e_test/src/fault_proxy.rs`) plus the 4-node kill/fresh-drive/blackhole cases in `crates/e2e_test/src/distributed/chaos_test.rs` | Part of the e2e crate (`e2e-reliability` and `e2e-distributed`) | Reliability cases with `e2e-full`; 4-node chaos nightly via `e2e-distributed` |
|
||||
| Deterministic simulation | Seeded scheduler over the 1.0.7 layout, erasure codec, bitrot hash, quorum reducer, and lock quorum for the 4×4 and 3×2 topologies, run sequentially | `cargo test -p rustfs-dst -- --test-threads=1`; official campaign: [`tests/dst/README.md`](../../tests/dst/README.md) | Local and the Mac mini runbook. Not a CI nightly. The in-crate smoke is part of `cargo test -p rustfs-dst` |
|
||||
| Fuzz | `cargo-fuzz` targets over untrusted parsing surfaces; isolated sub-workspace under `fuzz/` | `./scripts/fuzz/run.sh` (see [`fuzz/README.md`](../../fuzz/README.md)) | PR smoke on the paths listed in `.github/workflows/fuzz.yml`, plus nightly corpus |
|
||||
| Benchmarks | Criterion benches under each crate's `benches/` | `cargo bench -p <crate>` | On demand; never a gate |
|
||||
| Conditional reads | Paired ordinary/hit/miss GET latency, throughput and read-lock measurements | `scripts/run_conditional_read_abba.py` | Local conditional-read acceptance; [guide and scope](conditional-read-benchmark.md) |
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright 2024 RustFS Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[package]
|
||||
name = "rustfs-dst"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
homepage.workspace = true
|
||||
publish = false
|
||||
description = "Deterministic simulation harness for RustFS 1.0.7 erasure-set durability."
|
||||
keywords = ["rustfs", "simulation", "erasure-coding", "testing"]
|
||||
categories = ["development-tools", "filesystem"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
rustfs-ecstore = { workspace = true, features = ["dst"] }
|
||||
rustfs-filemeta = { workspace = true }
|
||||
rustfs-utils = { workspace = true }
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[[bin]]
|
||||
name = "dst-campaign"
|
||||
path = "src/bin/dst-campaign.rs"
|
||||
@@ -0,0 +1,176 @@
|
||||
# Deterministic simulation (RustFS 1.0.7)
|
||||
|
||||
This harness is a single-threaded, seeded simulator for two official cluster shapes. It calls RustFS 1.0.7 code for layout, Reed-Solomon encode/decode, HighwayHash256S framing, read/write quorum reduction, object-to-set SipHash, shard distribution, and namespace-lock quorum sizes. It does not boot the HTTP server, tonic, or the on-disk `LocalDisk` path.
|
||||
|
||||
The official campaign host is an Apple Mac mini (M5 Pro, 24 GB unified memory, hostname `bogon`, Tailscale name `kevins-mac-mini`). A cloud VM smoke is not that campaign.
|
||||
|
||||
## Why this shape
|
||||
|
||||
`turmoil`, `madsim`, and `shuttle` are not in this tree. RustFS 1.0.7 keeps internode I/O on `tokio::net` and `tonic`, and drive I/O on the real filesystem (`openat2`, dedicated fsync lanes, `spawn_blocking`). Putting the whole server under madsim or turmoil would mean replacing the runtime and the disk stack. This harness instead drives the durability primitives those paths already call, under a virtual clock and an explicit fault schedule.
|
||||
|
||||
## Topologies
|
||||
|
||||
Both use one pool and the default set-width selector (`RUSTFS_ERASURE_SET_DRIVE_COUNT` is forced to `0` inside the harness, even if the shell has it set). Confirmed against `DisksLayout` on 1.0.7:
|
||||
|
||||
| Name | Volume argument | Nodes | Disks / node | Sets | Drives / set | Default parity | Read quorum | Write quorum | Exclusive lock | Shared lock |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| `4x4` | `http://node{1...4}:9000/data{1...4}` | 4 | 4 | 1 | 16 | 4 | 12 | 12 | 3 of 4 nodes | 2 of 4 nodes |
|
||||
| `3x2` | `http://node{1...3}:9000/data{1...2}` | 3 | 2 | 1 | 6 | 3 | 3 | 4 | 2 of 3 nodes | 2 of 3 nodes |
|
||||
|
||||
Parity is `default_parity_count`. Write quorum is the data-block count, plus one when data and parity are equal (the 6-drive set). Exclusive lock quorum is `(clients / 2) + 1` with one lock client per node. Shared lock quorum is `clients - clients / 2`.
|
||||
|
||||
The campaign runs `4x4` to completion, then `3x2`, in one process. Do not start a second campaign next to it.
|
||||
|
||||
## Faults
|
||||
|
||||
Every choice comes from xoshiro256** expanded from the seed with splitmix64.
|
||||
|
||||
| Fault | Official rate | Effect |
|
||||
|---|---|---|
|
||||
| Message drop | 3% | The completion never happens. The client counts `DiskNotFound` at the deadline. |
|
||||
| Message duplicate | 2% | A second completion. Same generation and bytes are idempotent. An older generation cannot roll forward. |
|
||||
| Reorder | independent delays | Completions carry their own delay. |
|
||||
| Delay | uniform `0..=120_000` virtual µs | The client deadline is `100_000` virtual µs, so some completions miss it. |
|
||||
| Drive I/O error | 2% | `FaultyDisk`, ignored by the production quorum reducer, and the bytes are not applied. |
|
||||
| Clock jump | 8% of operations | Virtual time jumps by at least the operation timeout. Late completions are not counted. |
|
||||
| Node crash | 10% of operations, plus a campaign action | The node process stops. In-flight I/O for its drives is dropped. Durable bytes stay. |
|
||||
| Node restart | campaign action | The process returns. Disk contents are whatever survived. |
|
||||
| Isolate / heal partition | campaign action | Messages to and from that node are dropped until isolation is cleared. |
|
||||
| Bitrot | campaign action | One stored byte is flipped. `HighwayHash256S` must reject it. |
|
||||
| Disk wipe | campaign action | One drive's objects are removed. |
|
||||
| Heal | campaign action | If the object is still readable, missing reachable drives are rewritten from `Erasure::encode_data`. |
|
||||
|
||||
A put or delete runs only when the exclusive lock quorum of reachable nodes is met. A get or list runs only when the shared lock quorum is met. Disk success and failure then go through `reduce_write_quorum_errs` / `reduce_read_quorum_errs`.
|
||||
|
||||
## Invariants
|
||||
|
||||
Checked after every campaign step, against drive media (a crashed process does not erase a drive):
|
||||
|
||||
- A client read that returns bytes matches the last committed payload.
|
||||
- A readable object was committed. A failed quorum does not publish it.
|
||||
- If at least `read_quorum` replicas still verify, the object reads back as those bytes.
|
||||
- Below that count the read fails. It does not return different bytes.
|
||||
- List entries are committed keys.
|
||||
- The quorum reducer must not accept fewer than `quorum` successes when every other error is in `OBJECT_OP_IGNORED_ERRS`, and must not reject a full ignored-error success.
|
||||
|
||||
A minimum-success delete on these two shapes leaves fewer than `read_quorum` replicas (`drives - write_quorum < read_quorum`). A node crash keeps media, so a fully written object stays readable: 16−4 = 12 on `4x4`, and 6−2 = 4 which is still above the 3-disk read quorum on `3x2`. A minimum 12-of-16 or 4-of-6 write does not promise that a later node loss is still readable; the checker uses the surviving verified replicas.
|
||||
|
||||
## What this does not model
|
||||
|
||||
- The streaming multi-block encode pipeline, `xl.meta` bytes, or multipart completion. Payloads are at most 4 KiB and go through `Erasure::encode_data` / `decode_data` (one block, under the 1 MiB `BLOCK_SIZE_V2`).
|
||||
- Splitting fsync from the ack. The drive applies the bytes and acknowledges them in one scheduler event. A dropped message is dropped before that point.
|
||||
- Lock leases, refresh, and fencing. Only the quorum gate is enforced.
|
||||
- Storage-class parity overrides. New objects use the default parity for the set width.
|
||||
- Donor-frame swaps. Independent shard commitments are off by default in 1.0.7; random bit flips are the corruption the default hash is required to catch.
|
||||
- A second client. One coordinator issues the operations.
|
||||
|
||||
## Mac mini runbook
|
||||
|
||||
Machine: Apple M5 Pro, 24 GB unified memory, macOS, `aarch64-apple-darwin`. OrbStack's Docker VM is about 14 GB if it is left running. UTM guests, if powered on, take more. The simulator itself stays under about 512 MB. The memory risk is `rustc` while it builds `rustfs-ecstore`.
|
||||
|
||||
1. Stop extra guests before compiling. If OrbStack stays up at ~14 GB, set `CARGO_BUILD_JOBS=1`. If Docker, OrbStack, and UTM are stopped, `CARGO_BUILD_JOBS=2` fits. Do not use a higher job count, and do not compile the rest of the workspace in parallel.
|
||||
2. Do not start the real 16-drive or 6-drive process cluster in the same window as this compile. Run the simulator first, or compile first and then start the cluster.
|
||||
3. Check out the commit this PR builds, which is 1.0.7 (`03c8a1733d57a6ffc3095f63f765d396f5d04a3a`) plus the harness. `git rev-parse HEAD` must be the commit you pass to `--commit`.
|
||||
4. Unset `RUSTFS_ERASURE_SET_DRIVE_COUNT` for any real process you start beside this. The simulator forces set width `0` (the production default). A different width is a different layout.
|
||||
5. Real-process endpoint arguments, if you bring a cluster up for a separate run, are the volume strings in the table above. One `rustfs` process per node. Do not run those processes in parallel with `dst-campaign`.
|
||||
|
||||
Smoke (after the ecstore build; the tests themselves are short):
|
||||
|
||||
```bash
|
||||
cd /path/to/rustfs
|
||||
export CARGO_BUILD_JOBS=1
|
||||
git rev-parse HEAD
|
||||
cargo test -p rustfs-dst -- --test-threads=1
|
||||
```
|
||||
|
||||
Official campaign. One process, `4x4` then `3x2`, seeds 1 through 24, 400 steps each, 30 minute wall clock cap. Expect the run itself to finish well inside the cap; the cap is there so a hung seed cannot sit forever. Virtual time is not wall time.
|
||||
|
||||
```bash
|
||||
mkdir -p "$HOME/rustfs-dst-results"
|
||||
COMMIT=$(git rev-parse HEAD)
|
||||
export CARGO_BUILD_JOBS=1
|
||||
cargo run -p rustfs-dst --bin dst-campaign -- \
|
||||
--seeds 1-24 \
|
||||
--steps 400 \
|
||||
--budget-secs 1800 \
|
||||
--max-payload 4096 \
|
||||
--max-objects 8 \
|
||||
--commit "$COMMIT" \
|
||||
--report "$HOME/rustfs-dst-results/dst-1.0.7.md" \
|
||||
--checkpoint "$HOME/rustfs-dst-results/dst-1.0.7.checkpoint"
|
||||
echo "exit=$?"
|
||||
```
|
||||
|
||||
Exit 0 means every seed passed and the budget was not exhausted. Exit 1 means a failing seed or an early stop. The report lists each seed. Failing seeds include the first failing step, the minimized step, the invariant name, and the traced schedule.
|
||||
|
||||
Resume after a stop or a reboot. The checkpoint skips seeds already recorded as `ok` or `fail` for either topology, then continues. Do not delete the checkpoint if you want the failure log kept.
|
||||
|
||||
```bash
|
||||
cargo run -p rustfs-dst --bin dst-campaign -- \
|
||||
--seeds 1-24 \
|
||||
--steps 400 \
|
||||
--budget-secs 1800 \
|
||||
--commit "$(git rev-parse HEAD)" \
|
||||
--report "$HOME/rustfs-dst-results/dst-1.0.7.md" \
|
||||
--checkpoint "$HOME/rustfs-dst-results/dst-1.0.7.checkpoint"
|
||||
```
|
||||
|
||||
Reproduce one seed:
|
||||
|
||||
```bash
|
||||
cargo run -p rustfs-dst --bin dst-campaign -- \
|
||||
--seeds 17 \
|
||||
--steps 400 \
|
||||
--budget-secs 300 \
|
||||
--commit "$(git rev-parse HEAD)" \
|
||||
--report "$HOME/rustfs-dst-results/seed-17.md"
|
||||
```
|
||||
|
||||
To stop at the minimized step from the report, pass that step count as `--steps`. Add `--no-minimize` only when you already have the minimal step and want a faster replay.
|
||||
|
||||
Optional longer pass, still sequential, still one process:
|
||||
|
||||
```bash
|
||||
cargo run -p rustfs-dst --bin dst-campaign -- \
|
||||
--seeds 1-48 \
|
||||
--steps 800 \
|
||||
--budget-secs 3600 \
|
||||
--commit "$(git rev-parse HEAD)" \
|
||||
--report "$HOME/rustfs-dst-results/dst-1.0.7-extended.md" \
|
||||
--checkpoint "$HOME/rustfs-dst-results/dst-1.0.7-extended.checkpoint"
|
||||
```
|
||||
|
||||
Do not pass `--release` while OrbStack is using ~14 GB. A debug campaign is the intended run. If you have stopped every VM and still want a release binary, use `CARGO_BUILD_JOBS=1 cargo run -p rustfs-dst --release --bin dst-campaign -- …`.
|
||||
|
||||
## Resource limits
|
||||
|
||||
| Limit | Value |
|
||||
|---|---|
|
||||
| Host RAM | 24 GB unified |
|
||||
| Leave for OrbStack if it stays up | ~14 GB |
|
||||
| `CARGO_BUILD_JOBS` with OrbStack up | 1 |
|
||||
| `CARGO_BUILD_JOBS` with Docker/OrbStack/UTM stopped | 2 |
|
||||
| Campaign processes | 1 |
|
||||
| Topologies | sequential, never two at once |
|
||||
| Payload cap | 4096 bytes |
|
||||
| Objects per seed | 8 |
|
||||
| Official seeds | 1–24 per topology |
|
||||
| Steps per seed | 400 |
|
||||
| Wall budget | 1800 seconds for both topologies |
|
||||
| Expected simulator RSS | under 512 MB |
|
||||
|
||||
## Cloud VM smoke
|
||||
|
||||
The cloud VM that added this harness is not the official host. This smoke ran on Linux x86_64 against the 1.0.7 tree plus this harness, before the Mac mini campaign. It is not a substitute for the runbook above.
|
||||
|
||||
```bash
|
||||
cargo run -p rustfs-dst --bin dst-campaign -- \
|
||||
--seeds 1-4 \
|
||||
--steps 50 \
|
||||
--budget-secs 120 \
|
||||
--max-payload 4096 \
|
||||
--max-objects 8 \
|
||||
--commit 03c8a1733d57a6ffc3095f63f765d396f5d04a3a
|
||||
```
|
||||
|
||||
Result: exit 0. 8 of 8 passed, in order: `4x4` seeds 1–4, then `3x2` seeds 1–4. No failing seed. Layout resolved to one 16-drive set (read/write quorum 12, exclusive lock 3) and one 6-drive set (read quorum 3, write quorum 4, exclusive lock 2). `cargo test -p rustfs-dst -- --test-threads=1` passed 7 tests. `cargo clippy -p rustfs-dst --all-targets -- -D warnings` passed.
|
||||
@@ -0,0 +1,191 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Official DST campaign. Runs 4x4, then 3x2, in this process.
|
||||
|
||||
use rustfs_dst::{CampaignConfig, Topology, render_report, run_topologies};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::process::ExitCode;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let mut config = CampaignConfig::default();
|
||||
let mut commit = None;
|
||||
let mut report_path = None;
|
||||
let mut checkpoint = None;
|
||||
let mut args = env::args().skip(1);
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
"--seeds" => {
|
||||
let Some(value) = args.next() else {
|
||||
eprintln!("--seeds needs START-END or a comma list");
|
||||
return ExitCode::from(2);
|
||||
};
|
||||
match parse_seeds(&value) {
|
||||
Ok(seeds) => config.seeds = seeds,
|
||||
Err(error) => {
|
||||
eprintln!("{error}");
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
"--steps" => config.steps = parse_next(&mut args, "--steps"),
|
||||
"--budget-secs" => {
|
||||
let secs = u64::from(parse_next(&mut args, "--budget-secs"));
|
||||
config.budget = Some(Duration::from_secs(secs));
|
||||
}
|
||||
"--max-payload" => config.max_payload = parse_next(&mut args, "--max-payload") as usize,
|
||||
"--max-objects" => config.max_objects = parse_next(&mut args, "--max-objects") as usize,
|
||||
"--commit" => commit = args.next(),
|
||||
"--report" => report_path = args.next(),
|
||||
"--checkpoint" => checkpoint = args.next(),
|
||||
"--no-minimize" => config.minimize = false,
|
||||
"--help" | "-h" => {
|
||||
print_help();
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
other => {
|
||||
eprintln!("unknown argument {other}");
|
||||
print_help();
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let topologies = match Topology::official() {
|
||||
Ok(topologies) => topologies,
|
||||
Err(error) => {
|
||||
eprintln!("layout: {error}");
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
};
|
||||
let existing = checkpoint
|
||||
.as_ref()
|
||||
.and_then(|path| fs::read_to_string(path).ok())
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut report = rustfs_dst::CampaignReport {
|
||||
entries: Vec::new(),
|
||||
stopped_early: false,
|
||||
next_topology: None,
|
||||
next_seed: None,
|
||||
};
|
||||
for topology in &topologies {
|
||||
let mut topology_config = config.clone();
|
||||
topology_config
|
||||
.seeds
|
||||
.retain(|seed| !checkpoint_has(&existing, &topology.name, *seed));
|
||||
if topology_config.seeds.is_empty() {
|
||||
continue;
|
||||
}
|
||||
match run_topologies(std::slice::from_ref(topology), &topology_config) {
|
||||
Ok(partial) => {
|
||||
let stopped = partial.stopped_early;
|
||||
report.stopped_early = stopped;
|
||||
report.next_topology = partial.next_topology;
|
||||
report.next_seed = partial.next_seed;
|
||||
report.entries.extend(partial.entries);
|
||||
if stopped {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("campaign: {error}");
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
let rendered = render_report(&report, commit.as_deref(), &topologies);
|
||||
print!("{rendered}");
|
||||
if let Some(path) = &report_path
|
||||
&& let Err(error) = fs::write(path, &rendered)
|
||||
{
|
||||
eprintln!("report: {error}");
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
if let Some(path) = &checkpoint {
|
||||
let mut lines = String::new();
|
||||
if let Some(commit) = &commit {
|
||||
lines.push_str(&format!("commit {commit}\n"));
|
||||
}
|
||||
for line in existing
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("ok ") || line.starts_with("fail "))
|
||||
{
|
||||
lines.push_str(line);
|
||||
lines.push('\n');
|
||||
}
|
||||
for entry in &report.entries {
|
||||
if entry.passed {
|
||||
lines.push_str(&format!("ok {} {}\n", entry.topology, entry.seed));
|
||||
} else if let Some(failure) = &entry.failure {
|
||||
lines.push_str(&format!(
|
||||
"fail {} {} step={} minimal={} invariant={}\n",
|
||||
failure.topology, failure.seed, failure.step, failure.minimal_step, failure.invariant
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Err(error) = fs::write(path, lines) {
|
||||
eprintln!("checkpoint: {error}");
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
}
|
||||
if report.entries.iter().any(|entry| !entry.passed) || report.stopped_early {
|
||||
ExitCode::from(1)
|
||||
} else {
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_next(args: &mut impl Iterator<Item = String>, flag: &str) -> u32 {
|
||||
args.next().and_then(|value| value.parse().ok()).unwrap_or_else(|| {
|
||||
eprintln!("{flag} needs a number");
|
||||
std::process::exit(2);
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_seeds(value: &str) -> Result<Vec<u64>, String> {
|
||||
if let Some((start, end)) = value.split_once('-') {
|
||||
let start: u64 = start.parse().map_err(|_| format!("bad seed {start}"))?;
|
||||
let end: u64 = end.parse().map_err(|_| format!("bad seed {end}"))?;
|
||||
if end < start {
|
||||
return Err(format!("seed range {value} is inverted"));
|
||||
}
|
||||
return Ok((start..=end).collect());
|
||||
}
|
||||
value
|
||||
.split(',')
|
||||
.filter(|part| !part.is_empty())
|
||||
.map(|part| part.parse::<u64>().map_err(|_| format!("bad seed {part}")))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn checkpoint_has(text: &str, topology: &str, seed: u64) -> bool {
|
||||
text.lines().any(|line| {
|
||||
let mut parts = line.split_whitespace();
|
||||
let kind = parts.next();
|
||||
let recorded_topology = parts.next();
|
||||
let recorded = parts.next().and_then(|value| value.parse::<u64>().ok());
|
||||
matches!(kind, Some("ok" | "fail")) && recorded_topology == Some(topology) && recorded == Some(seed)
|
||||
})
|
||||
}
|
||||
|
||||
fn print_help() {
|
||||
eprintln!(
|
||||
"dst-campaign [--seeds 1-24] [--steps 400] [--budget-secs 1800] \
|
||||
[--max-payload 4096] [--max-objects 8] [--commit SHA] \
|
||||
[--report path] [--checkpoint path] [--no-minimize]"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Single-block HighwayHash256S framing.
|
||||
//!
|
||||
//! This is the on-disk `[hash][data]` prefix that `BitrotWriter` writes for
|
||||
//! `HashAlgorithm::HighwayHash256S`. The async reader is not used here; the
|
||||
//! hash function is the production one.
|
||||
|
||||
use rustfs_utils::HashAlgorithm;
|
||||
|
||||
const HASH_LEN: usize = 32;
|
||||
|
||||
pub fn frame_shard(shard: &[u8]) -> Vec<u8> {
|
||||
let digest = HashAlgorithm::HighwayHash256S.hash_encode(shard);
|
||||
let mut framed = Vec::with_capacity(HASH_LEN + shard.len());
|
||||
framed.extend_from_slice(digest.as_ref());
|
||||
framed.extend_from_slice(shard);
|
||||
framed
|
||||
}
|
||||
|
||||
pub fn unframe_shard(framed: &[u8]) -> Option<Vec<u8>> {
|
||||
if framed.len() < HASH_LEN {
|
||||
return None;
|
||||
}
|
||||
let (digest, shard) = framed.split_at(HASH_LEN);
|
||||
let actual = HashAlgorithm::HighwayHash256S.hash_encode(shard);
|
||||
if actual.as_ref() != digest {
|
||||
return None;
|
||||
}
|
||||
Some(shard.to_vec())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{frame_shard, unframe_shard};
|
||||
|
||||
#[test]
|
||||
fn roundtrip_and_single_byte_corruption_fail_closed() {
|
||||
let framed = frame_shard(b"shard-bytes");
|
||||
assert_eq!(unframe_shard(&framed).as_deref(), Some(b"shard-bytes".as_slice()));
|
||||
let mut corrupt = framed;
|
||||
let last = corrupt.len() - 1;
|
||||
corrupt[last] ^= 0xff;
|
||||
assert!(unframe_shard(&corrupt).is_none());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Sequential campaign runner.
|
||||
//!
|
||||
//! Official topologies run one after another in a single thread. A failing
|
||||
//! seed is recorded and minimized; the campaign continues with the next seed.
|
||||
|
||||
use crate::topology::Topology;
|
||||
use crate::world::{FaultRates, Violation, World, WorldConfig};
|
||||
use std::time::Instant;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CampaignConfig {
|
||||
pub seeds: Vec<u64>,
|
||||
pub steps: u32,
|
||||
pub rates: FaultRates,
|
||||
pub op_timeout_us: u64,
|
||||
pub max_objects: usize,
|
||||
pub max_payload: usize,
|
||||
pub minimize: bool,
|
||||
pub budget: Option<std::time::Duration>,
|
||||
}
|
||||
|
||||
impl Default for CampaignConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
seeds: (1..=24).collect(),
|
||||
steps: 400,
|
||||
rates: FaultRates::default(),
|
||||
op_timeout_us: 100_000,
|
||||
max_objects: 8,
|
||||
max_payload: 4096,
|
||||
minimize: true,
|
||||
budget: Some(std::time::Duration::from_secs(1800)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SeedFailure {
|
||||
pub topology: String,
|
||||
pub seed: u64,
|
||||
pub step: u32,
|
||||
pub minimal_step: u32,
|
||||
pub invariant: String,
|
||||
pub detail: String,
|
||||
pub trace: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SeedReport {
|
||||
pub topology: String,
|
||||
pub seed: u64,
|
||||
pub steps: u32,
|
||||
pub passed: bool,
|
||||
pub elapsed_ms: u128,
|
||||
pub failure: Option<SeedFailure>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CampaignReport {
|
||||
pub entries: Vec<SeedReport>,
|
||||
pub stopped_early: bool,
|
||||
pub next_topology: Option<String>,
|
||||
pub next_seed: Option<u64>,
|
||||
}
|
||||
|
||||
pub fn run_official(config: &CampaignConfig) -> Result<CampaignReport, String> {
|
||||
let topologies = Topology::official().map_err(|error| error.to_string())?;
|
||||
run_topologies(&topologies, config)
|
||||
}
|
||||
|
||||
pub fn run_topologies(topologies: &[Topology], config: &CampaignConfig) -> Result<CampaignReport, String> {
|
||||
let started = Instant::now();
|
||||
let mut entries = Vec::new();
|
||||
for topology in topologies {
|
||||
for &seed in &config.seeds {
|
||||
if config.budget.is_some_and(|budget| started.elapsed() >= budget) {
|
||||
return Ok(CampaignReport {
|
||||
entries,
|
||||
stopped_early: true,
|
||||
next_topology: Some(topology.name.clone()),
|
||||
next_seed: Some(seed),
|
||||
});
|
||||
}
|
||||
let seed_started = Instant::now();
|
||||
match run_seed(topology, seed, config, false) {
|
||||
Ok(()) => entries.push(SeedReport {
|
||||
topology: topology.name.clone(),
|
||||
seed,
|
||||
steps: config.steps,
|
||||
passed: true,
|
||||
elapsed_ms: seed_started.elapsed().as_millis(),
|
||||
failure: None,
|
||||
}),
|
||||
Err(violation) => {
|
||||
let (minimal_step, trace) = if config.minimize {
|
||||
minimize(topology, seed, violation.step, config)
|
||||
} else {
|
||||
(violation.step, Vec::new())
|
||||
};
|
||||
entries.push(SeedReport {
|
||||
topology: topology.name.clone(),
|
||||
seed,
|
||||
steps: config.steps,
|
||||
passed: false,
|
||||
elapsed_ms: seed_started.elapsed().as_millis(),
|
||||
failure: Some(SeedFailure {
|
||||
topology: topology.name.clone(),
|
||||
seed,
|
||||
step: violation.step,
|
||||
minimal_step,
|
||||
invariant: violation.invariant,
|
||||
detail: violation.detail,
|
||||
trace,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(CampaignReport {
|
||||
entries,
|
||||
stopped_early: false,
|
||||
next_topology: None,
|
||||
next_seed: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn run_seed(topology: &Topology, seed: u64, config: &CampaignConfig, trace: bool) -> Result<(), Violation> {
|
||||
let mut world = World::new(
|
||||
topology.clone(),
|
||||
seed,
|
||||
WorldConfig {
|
||||
rates: config.rates.clone(),
|
||||
op_timeout_us: config.op_timeout_us,
|
||||
max_objects: config.max_objects,
|
||||
max_payload: config.max_payload,
|
||||
trace,
|
||||
},
|
||||
)
|
||||
.map_err(|detail| Violation {
|
||||
step: 0,
|
||||
invariant: "setup".to_string(),
|
||||
detail,
|
||||
})?;
|
||||
for _ in 0..config.steps {
|
||||
world.step()?;
|
||||
}
|
||||
world.check()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn minimize(topology: &Topology, seed: u64, failed_step: u32, config: &CampaignConfig) -> (u32, Vec<String>) {
|
||||
let mut low = 1_u32;
|
||||
let mut high = failed_step.max(1);
|
||||
while low < high {
|
||||
let mid = low + (high - low) / 2;
|
||||
let mut probe = config.clone();
|
||||
probe.steps = mid;
|
||||
probe.minimize = false;
|
||||
if run_seed(topology, seed, &probe, false).is_err() {
|
||||
high = mid;
|
||||
} else {
|
||||
low = mid + 1;
|
||||
}
|
||||
}
|
||||
let mut traced = config.clone();
|
||||
traced.steps = low;
|
||||
traced.minimize = false;
|
||||
let Ok(mut world) = World::new(
|
||||
topology.clone(),
|
||||
seed,
|
||||
WorldConfig {
|
||||
rates: config.rates.clone(),
|
||||
op_timeout_us: config.op_timeout_us,
|
||||
max_objects: config.max_objects,
|
||||
max_payload: config.max_payload,
|
||||
trace: true,
|
||||
},
|
||||
) else {
|
||||
return (low, Vec::new());
|
||||
};
|
||||
let mut failed = None;
|
||||
for _ in 0..low {
|
||||
if let Err(violation) = world.step() {
|
||||
failed = Some(violation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let trace = world.trace;
|
||||
let step = failed.map(|violation| violation.step).unwrap_or(low);
|
||||
(step, trace)
|
||||
}
|
||||
|
||||
pub fn render_report(report: &CampaignReport, commit: Option<&str>, topologies: &[Topology]) -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str("# RustFS 1.0.7 DST campaign\n\n");
|
||||
if let Some(commit) = commit {
|
||||
out.push_str(&format!("Source commit: `{commit}`\n\n"));
|
||||
}
|
||||
out.push_str("Topologies ran sequentially in one process, in the order below.\n\n");
|
||||
for topology in topologies {
|
||||
let set = topology.sets.first();
|
||||
out.push_str(&format!("- `{}` volume `{}`\n", topology.name, topology.volume));
|
||||
if let Some(set) = set {
|
||||
out.push_str(&format!(
|
||||
" nodes={} sets={} drives={} data={} parity={} read_quorum={} write_quorum={} exclusive_lock={} shared_lock={}\n",
|
||||
topology.nodes.len(),
|
||||
topology.sets.len(),
|
||||
set.drives.len(),
|
||||
set.data_blocks,
|
||||
set.parity_blocks,
|
||||
set.read_quorum,
|
||||
set.write_quorum,
|
||||
set.exclusive_lock_quorum,
|
||||
set.shared_lock_quorum
|
||||
));
|
||||
}
|
||||
}
|
||||
out.push('\n');
|
||||
let passed = report.entries.iter().filter(|entry| entry.passed).count();
|
||||
let failed = report.entries.len().saturating_sub(passed);
|
||||
out.push_str(&format!("Passed {passed}, failed {failed}.\n"));
|
||||
if report.stopped_early {
|
||||
out.push_str(&format!(
|
||||
"Stopped early. Resume at topology {:?} seed {:?}.\n",
|
||||
report.next_topology, report.next_seed
|
||||
));
|
||||
}
|
||||
out.push('\n');
|
||||
for entry in &report.entries {
|
||||
if entry.passed {
|
||||
out.push_str(&format!(
|
||||
"- {} seed {} passed steps {} in {} ms\n",
|
||||
entry.topology, entry.seed, entry.steps, entry.elapsed_ms
|
||||
));
|
||||
} else if let Some(failure) = &entry.failure {
|
||||
out.push_str(&format!(
|
||||
"- {} seed {} FAILED step {} minimal {} invariant `{}`: {}\n",
|
||||
failure.topology, failure.seed, failure.step, failure.minimal_step, failure.invariant, failure.detail
|
||||
));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Deterministic simulation of RustFS 1.0.7 erasure sets.
|
||||
//!
|
||||
//! The harness drives the production layout selector, erasure codec, bitrot
|
||||
//! hash, quorum reducer, and lock-quorum sizes. It does not boot the HTTP
|
||||
//! server. See `tests/dst/README.md`.
|
||||
|
||||
pub mod bitrot;
|
||||
pub mod campaign;
|
||||
pub mod rng;
|
||||
pub mod topology;
|
||||
pub mod world;
|
||||
|
||||
pub use campaign::{
|
||||
CampaignConfig, CampaignReport, SeedFailure, SeedReport, render_report, run_official, run_seed, run_topologies,
|
||||
};
|
||||
pub use topology::{OFFICIAL_VOLUMES, Topology};
|
||||
pub use world::{FaultRates, World, WorldConfig};
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Seeded xoshiro256** used for every campaign choice.
|
||||
//!
|
||||
//! The 64-bit seed is expanded with splitmix64. The same seed always yields
|
||||
//! the same schedule on every platform.
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Rng {
|
||||
state: [u64; 4],
|
||||
}
|
||||
|
||||
impl Rng {
|
||||
pub fn from_seed(seed: u64) -> Self {
|
||||
let mut mixer = seed;
|
||||
let mut state = [0; 4];
|
||||
for word in &mut state {
|
||||
*word = splitmix64(&mut mixer);
|
||||
}
|
||||
Self { state }
|
||||
}
|
||||
|
||||
pub fn next_u64(&mut self) -> u64 {
|
||||
let s = &mut self.state;
|
||||
let result = s[1].wrapping_mul(5).rotate_left(7).wrapping_mul(9);
|
||||
let t = s[1] << 17;
|
||||
s[2] ^= s[0];
|
||||
s[3] ^= s[1];
|
||||
s[1] ^= s[2];
|
||||
s[0] ^= s[3];
|
||||
s[2] ^= t;
|
||||
s[3] = s[3].rotate_left(45);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn gen_range(&mut self, exclusive_end: u64) -> u64 {
|
||||
if exclusive_end == 0 {
|
||||
return 0;
|
||||
}
|
||||
self.next_u64() % exclusive_end
|
||||
}
|
||||
|
||||
pub fn chance(&mut self, numer: u32, denom: u32) -> bool {
|
||||
if denom == 0 || numer == 0 {
|
||||
return false;
|
||||
}
|
||||
(self.next_u64() % u64::from(denom)) < u64::from(numer)
|
||||
}
|
||||
}
|
||||
|
||||
fn splitmix64(state: &mut u64) -> u64 {
|
||||
*state = state.wrapping_add(0x9E37_79B9_7F4A_7C15);
|
||||
let mut mixed = *state;
|
||||
mixed = (mixed ^ (mixed >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9);
|
||||
mixed = (mixed ^ (mixed >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB);
|
||||
mixed ^ (mixed >> 31)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Rng;
|
||||
|
||||
#[test]
|
||||
fn seed_one_matches_xoshiro256starstar_vector() {
|
||||
let mut rng = Rng::from_seed(1);
|
||||
let observed = [rng.next_u64(), rng.next_u64(), rng.next_u64(), rng.next_u64()];
|
||||
assert_eq!(
|
||||
observed,
|
||||
[
|
||||
0xb3f2_af6d_0fc7_10c5,
|
||||
0x853b_5596_4736_4cea,
|
||||
0x92f8_9756_082a_4514,
|
||||
0x642e_1c7b_c266_a3a7,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn distinct_seeds_diverge() {
|
||||
let mut left = Rng::from_seed(1);
|
||||
let mut right = Rng::from_seed(2);
|
||||
assert_ne!(left.next_u64(), right.next_u64());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Official cluster shapes, expanded by RustFS 1.0.7's layout selector.
|
||||
//!
|
||||
//! Both campaigns use one pool and `set_drive_count = 0` (the default when
|
||||
//! `RUSTFS_ERASURE_SET_DRIVE_COUNT` is unset). Parity is `default_parity_count`
|
||||
//! for that set width. Lock clients are the distinct node hosts in the set.
|
||||
|
||||
use rustfs_ecstore::dst_seam::{
|
||||
default_parity_count, exclusive_lock_quorum, layout_sets, read_quorum, shared_lock_quorum, write_quorum,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
use std::io;
|
||||
|
||||
/// Stable SipHash key for set selection. One-set layouts ignore it.
|
||||
pub const FORMAT_ID: [u8; 16] = *b"rustfs-dst-1.0.7";
|
||||
|
||||
pub const DST_BUCKET: &str = "dst-bucket";
|
||||
|
||||
/// 4 nodes x 4 disks, then 3 nodes x 2 disks. Campaigns run in this order.
|
||||
pub const OFFICIAL_VOLUMES: [(&str, &str); 2] = [
|
||||
("4x4", "http://node{1...4}:9000/data{1...4}"),
|
||||
("3x2", "http://node{1...3}:9000/data{1...2}"),
|
||||
];
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Topology {
|
||||
pub name: String,
|
||||
pub volume: String,
|
||||
pub nodes: Vec<String>,
|
||||
pub sets: Vec<SetPlan>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct SetPlan {
|
||||
pub drives: Vec<DrivePlan>,
|
||||
pub data_blocks: usize,
|
||||
pub parity_blocks: usize,
|
||||
pub read_quorum: usize,
|
||||
pub write_quorum: usize,
|
||||
pub exclusive_lock_quorum: usize,
|
||||
pub shared_lock_quorum: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct DrivePlan {
|
||||
pub node_index: usize,
|
||||
pub endpoint: String,
|
||||
}
|
||||
|
||||
impl Topology {
|
||||
pub fn load(name: &str, volume: &str) -> io::Result<Self> {
|
||||
let sets = layout_sets(volume)?;
|
||||
if sets.is_empty() {
|
||||
return Err(io::Error::other(format!("{volume} produced no erasure sets")));
|
||||
}
|
||||
let mut hosts = BTreeSet::new();
|
||||
for set in &sets {
|
||||
for endpoint in set {
|
||||
let host = host_of(endpoint).ok_or_else(|| io::Error::other(format!("cannot parse host in {endpoint}")))?;
|
||||
hosts.insert(host.to_string());
|
||||
}
|
||||
}
|
||||
let nodes: Vec<String> = hosts.into_iter().collect();
|
||||
let mut plans = Vec::with_capacity(sets.len());
|
||||
for set in sets {
|
||||
let mut drives = Vec::with_capacity(set.len());
|
||||
for endpoint in set {
|
||||
let host = host_of(&endpoint).ok_or_else(|| io::Error::other(format!("cannot parse host in {endpoint}")))?;
|
||||
let node_index = nodes
|
||||
.iter()
|
||||
.position(|name| name == host)
|
||||
.ok_or_else(|| io::Error::other(format!("host {host} missing from node list")))?;
|
||||
drives.push(DrivePlan { node_index, endpoint });
|
||||
}
|
||||
let drive_count = drives.len();
|
||||
let parity = default_parity_count(drive_count);
|
||||
if parity > drive_count {
|
||||
return Err(io::Error::other(format!("parity {parity} exceeds drives {drive_count}")));
|
||||
}
|
||||
let lock_clients = drives.iter().map(|drive| drive.node_index).collect::<BTreeSet<_>>().len();
|
||||
plans.push(SetPlan {
|
||||
drives,
|
||||
data_blocks: drive_count - parity,
|
||||
parity_blocks: parity,
|
||||
read_quorum: read_quorum(drive_count, parity),
|
||||
write_quorum: write_quorum(drive_count, parity),
|
||||
exclusive_lock_quorum: exclusive_lock_quorum(lock_clients),
|
||||
shared_lock_quorum: shared_lock_quorum(lock_clients),
|
||||
});
|
||||
}
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
volume: volume.to_string(),
|
||||
nodes,
|
||||
sets: plans,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn official() -> io::Result<Vec<Self>> {
|
||||
OFFICIAL_VOLUMES
|
||||
.iter()
|
||||
.map(|(name, volume)| Self::load(name, volume))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn host_of(endpoint: &str) -> Option<&str> {
|
||||
let rest = endpoint.split("://").nth(1)?;
|
||||
let host = rest.split('/').next()?;
|
||||
if host.is_empty() { None } else { Some(host) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Topology;
|
||||
|
||||
#[test]
|
||||
fn official_layouts_follow_default_set_selection() {
|
||||
let topologies = Topology::official().expect("official volumes should parse");
|
||||
assert_eq!(topologies.len(), 2);
|
||||
|
||||
let four = &topologies[0];
|
||||
assert_eq!(four.name, "4x4");
|
||||
assert_eq!(four.nodes.len(), 4);
|
||||
assert_eq!(four.sets.len(), 1);
|
||||
assert_eq!(four.sets[0].drives.len(), 16);
|
||||
assert_eq!(four.sets[0].parity_blocks, 4);
|
||||
assert_eq!(four.sets[0].read_quorum, 12);
|
||||
assert_eq!(four.sets[0].write_quorum, 12);
|
||||
assert_eq!(four.sets[0].exclusive_lock_quorum, 3);
|
||||
assert_eq!(four.sets[0].shared_lock_quorum, 2);
|
||||
assert!(four.sets[0].write_quorum >= four.sets[0].read_quorum);
|
||||
assert!(four.sets[0].drives.len() - four.sets[0].write_quorum < four.sets[0].read_quorum);
|
||||
for node in 0..4 {
|
||||
assert_eq!(four.sets[0].drives.iter().filter(|drive| drive.node_index == node).count(), 4);
|
||||
}
|
||||
|
||||
let three = &topologies[1];
|
||||
assert_eq!(three.name, "3x2");
|
||||
assert_eq!(three.nodes.len(), 3);
|
||||
assert_eq!(three.sets.len(), 1);
|
||||
assert_eq!(three.sets[0].drives.len(), 6);
|
||||
assert_eq!(three.sets[0].parity_blocks, 3);
|
||||
assert_eq!(three.sets[0].data_blocks, 3);
|
||||
assert_eq!(three.sets[0].read_quorum, 3);
|
||||
assert_eq!(three.sets[0].write_quorum, 4);
|
||||
assert_eq!(three.sets[0].exclusive_lock_quorum, 2);
|
||||
assert_eq!(three.sets[0].shared_lock_quorum, 2);
|
||||
assert!(three.sets[0].write_quorum >= three.sets[0].read_quorum);
|
||||
assert!(three.sets[0].drives.len() - three.sets[0].write_quorum < three.sets[0].read_quorum);
|
||||
for node in 0..3 {
|
||||
assert_eq!(three.sets[0].drives.iter().filter(|drive| drive.node_index == node).count(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use rustfs_dst::{CampaignConfig, FaultRates, Topology, World, WorldConfig, run_topologies};
|
||||
use std::time::Duration;
|
||||
|
||||
fn quiet(topology_name: &str) -> (Topology, World) {
|
||||
let topology = Topology::official()
|
||||
.expect("layouts")
|
||||
.into_iter()
|
||||
.find(|topology| topology.name == topology_name)
|
||||
.expect(topology_name);
|
||||
let world = World::new(
|
||||
topology.clone(),
|
||||
7,
|
||||
WorldConfig {
|
||||
rates: FaultRates::none(),
|
||||
..WorldConfig::default()
|
||||
},
|
||||
)
|
||||
.expect("world");
|
||||
(topology, world)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn both_topologies_roundtrip_without_faults() {
|
||||
for name in ["4x4", "3x2"] {
|
||||
let (_topology, mut world) = quiet(name);
|
||||
let payload = b"read-after-write".to_vec();
|
||||
world.put_quiet("obj-0", &payload).expect("put");
|
||||
world
|
||||
.check()
|
||||
.unwrap_or_else(|violation| panic!("{name}: {}", violation.detail));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn node_crash_keeps_bytes_when_media_remains() {
|
||||
for name in ["4x4", "3x2"] {
|
||||
let (_topology, mut world) = quiet(name);
|
||||
world.put_quiet("obj-0", b"durable").expect("put");
|
||||
world.crash_every_node();
|
||||
world
|
||||
.check()
|
||||
.unwrap_or_else(|violation| panic!("{name}: {}", violation.detail));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_campaign_runs_4x4_then_3x2() {
|
||||
let config = CampaignConfig {
|
||||
seeds: vec![1, 2],
|
||||
steps: 20,
|
||||
rates: FaultRates::default(),
|
||||
minimize: false,
|
||||
budget: Some(Duration::from_secs(120)),
|
||||
..CampaignConfig::default()
|
||||
};
|
||||
let report = run_topologies(&Topology::official().expect("layouts"), &config).expect("campaign");
|
||||
let order: Vec<_> = report.entries.iter().map(|entry| entry.topology.as_str()).collect();
|
||||
assert_eq!(order, ["4x4", "4x4", "3x2", "3x2"]);
|
||||
assert!(!report.stopped_early);
|
||||
for entry in &report.entries {
|
||||
if let Some(failure) = &entry.failure {
|
||||
panic!(
|
||||
"{} seed {} step {} {}: {}",
|
||||
failure.topology, failure.seed, failure.step, failure.invariant, failure.detail
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user