mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-13 16:46:55 +00:00
test(ecstore): deflake multipart listing tests under plain cargo test (#5730)
Multipart upload ids embed the process-global deployment id at both create time and list time. Under plain cargo test (thread-parallel, shared process globals) a concurrently running test that re-initializes a store can swap the global between the two reads, making full-upload-id equality assertions fail spuriously (observed: core::sets::tests::list_multipart_uploads_merges_all_sets_without_pagination_loss failing when run concurrently with bucket::quota tests, passing in isolation). Add a test-only upload_uuid_suffix helper next to deployment_upload_id and make the affected assertions compare only the decoded <uuid>x<timestamp> suffix. Where suffix normalization changes within-key ordering (base64 alphabet order is not byte order), both sides are sorted before comparison. nextest/CI is unaffected (process-per-test); this only hardens local plain cargo test runs.
This commit is contained in:
@@ -246,6 +246,22 @@ pub fn deployment_id() -> Option<String> {
|
||||
get_global_deployment_id()
|
||||
}
|
||||
|
||||
/// Test-only inverse of [`deployment_upload_id`]: returns the raw
|
||||
/// `<uuid>x<timestamp>` suffix without the deployment-id prefix. Under plain
|
||||
/// `cargo test` (thread-parallel, shared process globals) a concurrently
|
||||
/// running test that re-initializes a store can swap the global deployment id
|
||||
/// between create time and list time, so assertions must compare only this
|
||||
/// suffix, never the full encoded upload id.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn upload_uuid_suffix(upload_id: &str) -> String {
|
||||
base64_simd::URL_SAFE_NO_PAD
|
||||
.decode_to_vec(upload_id.as_bytes())
|
||||
.ok()
|
||||
.and_then(|decoded| String::from_utf8(decoded).ok())
|
||||
.and_then(|decoded| decoded.split_once('.').map(|(_, suffix)| suffix.to_owned()))
|
||||
.unwrap_or_else(|| upload_id.to_owned())
|
||||
}
|
||||
|
||||
pub(crate) fn replication_pool() -> Option<Arc<DynReplicationPool>> {
|
||||
crate::runtime::global::current_ctx().replication_pool()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user