keep sftp e2e tests buildable (#2897)

This commit is contained in:
houseme
2026-05-10 19:52:15 +08:00
committed by GitHub
parent 65c62ab2ea
commit 53ec1b95d8
10 changed files with 47 additions and 125 deletions
-1
View File
@@ -30,7 +30,6 @@ rustfs-targets = { workspace = true }
rustfs-config = { workspace = true, features = ["audit", "constants"] }
rustfs-ecstore = { workspace = true }
rustfs-s3-common = { workspace = true }
async-trait = { workspace = true }
chrono = { workspace = true }
const-str = { workspace = true }
futures = { workspace = true }
+1 -1
View File
@@ -29,7 +29,7 @@ ftps = []
sftp = []
[dependencies]
rustfs-config.workspace = true
rustfs-config = { workspace = true, features = ["constants"] }
rustfs-ecstore.workspace = true
rustfs-common.workspace = true
rustfs-rio.workspace = true
@@ -300,7 +300,7 @@ async fn seed_large_via_multipart(s3: &S3Client, bucket: &str, key: &str, size_b
let mut offset: u64 = 0;
let mut part_number: i32 = 1;
while offset < size_bytes {
let chunk = ((part_size as u64).min(size_bytes - offset)) as usize;
let chunk = (part_size as u64).min(size_bytes - offset) as usize;
let mut body = vec![0u8; chunk];
for (i, b) in body.iter_mut().enumerate() {
*b = ((offset + i as u64) as u8).wrapping_mul(THRASH_PATTERN_MULTIPLIER);
@@ -342,7 +342,7 @@ fn calculate_pattern_sha256(size_bytes: u64, multiplier: u8) -> [u8; 32] {
let mut buf = vec![0u8; chunk];
let mut written: u64 = 0;
while written < size_bytes {
let n = ((chunk as u64).min(size_bytes - written)) as usize;
let n = (chunk as u64).min(size_bytes - written) as usize;
for (i, b) in buf[..n].iter_mut().enumerate() {
*b = ((written + i as u64) as u8).wrapping_mul(multiplier);
}
@@ -406,8 +406,8 @@ fn capture_server_stdout(child: &mut Child) -> Arc<tokio::sync::Mutex<Vec<String
/// or "SFTP session task panicked" log emits a finish. The session-
/// lifecycle cases (CMPTST-24, CMPTST-25, CMPTST-26) read both fields
/// to assert the watchdog killed silent sessions on the expected path.
#[cfg(target_os = "linux")]
#[derive(Default)]
#[cfg(target_os = "linux")]
struct SessionCounters {
entered: AtomicUsize,
finished: AtomicUsize,
@@ -1497,7 +1497,7 @@ pub(crate) mod cmptst_24 {
// TCP connection so the loop iterates once and the JoinSet
// drain emits the "SFTP session task finished" log for
// every session that the per-session deadline has already
// cancelled. Without this, the counters under-report on a
// canceled. Without this, the counters under-report on a
// quiet server.
for _ in 0..3 {
if let Ok(stream) = TcpStream::connect(HALF_CLOSE_SFTP_ADDRESS).await {
@@ -2032,7 +2032,7 @@ pub(crate) mod cmptst_25 {
// Tickle the accept loop so JoinSet::try_join_next emits
// the "SFTP session task finished" log lines for any
// session the watchdog has cancelled. Same mechanism the
// session the watchdog has canceled. Same mechanism the
// half-close case uses. Mirrors the accept-loop drain
// pattern in server.rs.
for _ in 0..3 {
@@ -3115,7 +3115,7 @@ pub(crate) mod cmptst_31 {
// Read continuation must complete inside the resume
// deadline. If it does not, the server-side flush did not
// unwedge after the SSH window was replenished.
let resume_outcome = tokio::time::timeout(Duration::from_secs(PAUSE31_RESUME_DEADLINE_SECS), read_handle).await;
let resume_outcome = timeout(Duration::from_secs(PAUSE31_RESUME_DEADLINE_SECS), read_handle).await;
let (final_total, observed_sha) = match resume_outcome {
Ok(join_result) => match join_result {
Ok(Ok(p)) => p,
@@ -3154,7 +3154,7 @@ pub(crate) mod cmptst_31 {
eprintln!("--- end rustfs stdout dump ---");
}
let _ = tokio::time::timeout(Duration::from_secs(PAUSE31_OVERALL_DEADLINE_SECS), async {
let _ = timeout(Duration::from_secs(PAUSE31_OVERALL_DEADLINE_SECS), async {
server_process.kill_and_wait().await;
})
.await;
@@ -3207,7 +3207,7 @@ pub(crate) mod cmptst_32 {
eprintln!("--- end rustfs stdout dump ---");
}
let _ = tokio::time::timeout(Duration::from_secs(READ_CACHE_DEADLINE_SECS), async {
let _ = timeout(Duration::from_secs(READ_CACHE_DEADLINE_SECS), async {
server_process.kill_and_wait().await;
})
.await;
@@ -3260,7 +3260,7 @@ pub(crate) mod cmptst_33 {
eprintln!("--- end rustfs stdout dump ---");
}
let _ = tokio::time::timeout(Duration::from_secs(READ_CACHE_DEADLINE_SECS), async {
let _ = timeout(Duration::from_secs(READ_CACHE_DEADLINE_SECS), async {
server_process.kill_and_wait().await;
})
.await;
-1
View File
@@ -34,7 +34,6 @@ rustfs-utils = { workspace = true }
arc-swap = { workspace = true }
async-trait = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
futures = { workspace = true }
form_urlencoded = { workspace = true }
hashbrown = { workspace = true }
rayon = { workspace = true }
+1 -1
View File
@@ -13,7 +13,7 @@
// limitations under the License.
//! SftpError type and the helpers that convert backend errors and
//! authorisation failures into SftpError, plus the success Status
//! authorization failures into SftpError, plus the success Status
//! payload constructor.
use super::constants::{http_error_codes, s3_error_codes};
+2 -2
View File
@@ -51,7 +51,7 @@
//! per-session watchdog that observes the SFTP-handler activity stamp
//! and the kernel TCP state for the connection. Sessions that fall
//! silent at the SFTP layer while the kernel reports CLOSE_WAIT are
//! cancelled on a bounded schedule. The watchdog backstops resource
//! canceled on a bounded schedule. The watchdog backstops resource
//! accumulation regardless of which layer stalled. On Linux the
//! detection latency is on the order of 45 seconds; on non-Linux
//! targets the watchdog falls back to an inactivity ceiling on the
@@ -63,7 +63,7 @@
//! the rest. Subsequent reads inside that window are served from
//! memory. Total cache memory across every live handle is bounded by
//! a shared atomic accumulator enforced against the process-wide
//! ceiling. On ceiling breach the populate is skipped and the read
//! ceiling. On ceiling breach the population is skipped and the read
//! serves correctly via a single backend call without storing the
//! bytes for re-use.
//!
+4 -4
View File
@@ -21,7 +21,7 @@ use rustfs_utils::path;
/// Prefix the input with "/" if it is empty or relative. SFTP paths are
/// addressed as absolute against the server root. Clients may submit a
/// relative form (e.g. "." or "foo/bar"). Both forms normalise to the
/// relative form (e.g. "." or "foo/bar"). Both forms normalize to the
/// same absolute starting point before any cleaning or splitting runs.
pub(super) fn ensure_absolute(path: &str) -> String {
if path.is_empty() || !path.starts_with('/') {
@@ -44,7 +44,7 @@ pub(super) fn last_path_component(s: &str) -> Option<&str> {
/// Extract the single filename component of full_key relative to prefix.
/// Returns None when full_key does not start with prefix, when the
/// residual is empty (key equalled prefix exactly), or when the residual
/// residual is empty (key equaled prefix exactly), or when the residual
/// contains a slash (entry belongs under a sub-prefix and should have
/// appeared via common_prefixes under delimiter="/").
pub(super) fn relative_filename<'a>(full_key: &'a str, prefix: &str) -> Option<&'a str> {
@@ -55,7 +55,7 @@ pub(super) fn relative_filename<'a>(full_key: &'a str, prefix: &str) -> Option<&
Some(residual)
}
/// Canonicalise an incoming SFTP path and split it into an optional bucket
/// Canonicalize an incoming SFTP path and split it into an optional bucket
/// and object key.
///
/// An empty input is treated as root ("/"). An input that does not start
@@ -75,7 +75,7 @@ pub(super) fn relative_filename<'a>(full_key: &'a str, prefix: &str) -> Option<&
/// rejected at this boundary so a path emitted on a tracing field
/// cannot inject a line into the operator log; downstream warn paths
/// (skip-abort, stat fallback, REMOVE refusal) emit the bucket and key
/// without further sanitisation.
/// without further sanitization.
pub(super) fn parse_s3_path(input: &str) -> Result<(String, Option<String>), SftpError> {
if input.contains(['\0', '\r', '\n']) {
return Err(SftpError::code(StatusCode::BadMessage));
+1 -1
View File
@@ -15,7 +15,7 @@
//! Write-side state machine: open_write, commit_write, the
//! write_dispatch chain that flushes a part once part_buffer reaches
//! part_size, abort_upload_with_auth, close_streaming, and
//! multipart_copy. Also the cancellation-safety primitives
//! multipart_copy. Also, the cancellation-safety primitives
//! (build_write_tombstone, should_abort_on_drop) that the Drop impl
//! in driver.rs consumes.