mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-01 13:44:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abef536caa |
@@ -1841,16 +1841,19 @@ where
|
||||
}
|
||||
RemoteScannerFrameResult::DurableProgress(receipt) => {
|
||||
let actual = receipt.identity.tier_registry_generation;
|
||||
let expected_identity = crate::DataUsageScanIdentity {
|
||||
tier_registry_generation: expected.tier_registry_generation,
|
||||
..receipt.identity
|
||||
};
|
||||
if !(expected.supports_durable_progress || expected.supports_complete_observation)
|
||||
|| (!expected.supports_durable_progress && receipt.advanced)
|
||||
|| (!expected.supports_complete_observation && receipt.observation.is_some())
|
||||
|| frame.phase != RemoteScannerPhase::Persisting
|
||||
|| receipt.source != expected.source
|
||||
|| Some(expected_identity) != expected.checkpoint_identity
|
||||
|| expected.checkpoint_identity.is_none_or(|identity| {
|
||||
// The worker fences persistence with its own process-local epoch.
|
||||
crate::DataUsageScanIdentity {
|
||||
publication_epoch: identity.publication_epoch,
|
||||
tier_registry_generation: expected.tier_registry_generation,
|
||||
..receipt.identity
|
||||
} != identity
|
||||
})
|
||||
|| receipt.scan_plan_digest != expected.scan_plan_digest
|
||||
|| receipt.checkpoint_plan_digest != expected.checkpoint_plan_digest
|
||||
|| receipt.leader_epoch != expected.leader_epoch
|
||||
|
||||
@@ -43,13 +43,20 @@ fn durable_receipt() -> RemoteScannerDurableProgress {
|
||||
|
||||
#[tokio::test]
|
||||
async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
let leader_publication_epoch = 3;
|
||||
assert_ne!(progress_identity().publication_epoch, leader_publication_epoch);
|
||||
for case in [
|
||||
"valid",
|
||||
"progress_only",
|
||||
"generation",
|
||||
"after_preflight",
|
||||
"legacy",
|
||||
"source",
|
||||
"identity",
|
||||
"layout",
|
||||
"mode",
|
||||
"missing_identity",
|
||||
"observation_epoch",
|
||||
"epoch",
|
||||
"plan",
|
||||
"future_observation",
|
||||
@@ -61,16 +68,13 @@ async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
let writer_auth = FrameAuthenticator::for_test(request_id);
|
||||
let reader_auth = FrameAuthenticator::for_test(if case == "mac" { Uuid::new_v4() } else { request_id });
|
||||
let mut receipt = durable_receipt();
|
||||
if case != "valid" {
|
||||
receipt.identity.tier_registry_generation = 1;
|
||||
receipt.observation.as_mut().expect("fixture observation").identity = receipt.identity;
|
||||
}
|
||||
match case {
|
||||
"generation" | "after_preflight" => receipt.identity.tier_registry_generation = 1,
|
||||
"progress_only" => receipt.observation = None,
|
||||
"source" => receipt.source = DataUsageCacheSource::new(99, 99),
|
||||
"identity" => {
|
||||
receipt.identity.bucket_incarnation = Uuid::from_u128(99);
|
||||
receipt.observation.as_mut().expect("fixture observation").identity = receipt.identity;
|
||||
}
|
||||
"identity" => receipt.identity.bucket_incarnation = Uuid::from_u128(99),
|
||||
"layout" => receipt.identity.set_layout = DataUsageScanPlanDigest([99; 32]),
|
||||
"mode" => receipt.identity.scan_mode = HealScanMode::Deep,
|
||||
"epoch" => receipt.leader_epoch += 1,
|
||||
"plan" => receipt.checkpoint_plan_digest = DataUsageScanPlanDigest([99; 32]),
|
||||
"future_observation" => receipt.observation.as_mut().expect("fixture observation").completed_cycle += 1,
|
||||
@@ -81,6 +85,12 @@ async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some(observation) = receipt.observation.as_mut() {
|
||||
observation.identity = receipt.identity;
|
||||
if case == "observation_epoch" {
|
||||
observation.identity.publication_epoch += 1;
|
||||
}
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
write_frame(
|
||||
&mut bytes,
|
||||
@@ -113,13 +123,16 @@ async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
tier_registry_generation: 0,
|
||||
supports_durable_progress: case != "legacy",
|
||||
supports_complete_observation: case != "legacy",
|
||||
checkpoint_identity: Some(progress_identity()),
|
||||
checkpoint_identity: (case != "missing_identity").then(|| crate::DataUsageScanIdentity {
|
||||
publication_epoch: leader_publication_epoch,
|
||||
..progress_identity()
|
||||
}),
|
||||
},
|
||||
reader_auth,
|
||||
Instant::now() + Duration::from_secs(5),
|
||||
)
|
||||
.await;
|
||||
if case == "valid" {
|
||||
if matches!(case, "valid" | "progress_only") {
|
||||
let RemoteScannerOutcome::DurableProgress {
|
||||
advanced, observation, ..
|
||||
} = result.expect("validated progress")
|
||||
@@ -127,7 +140,13 @@ async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
panic!("progress cannot become Complete")
|
||||
};
|
||||
assert!(advanced);
|
||||
assert_eq!(observation.expect("preserved companion").entry.objects, 5);
|
||||
if case == "valid" {
|
||||
let observation = observation.expect("preserved companion");
|
||||
assert_eq!(observation.identity, progress_identity());
|
||||
assert_eq!(observation.entry.objects, 5);
|
||||
} else {
|
||||
assert!(observation.is_none());
|
||||
}
|
||||
} else if case == "generation" {
|
||||
assert!(matches!(
|
||||
result,
|
||||
@@ -137,6 +156,20 @@ async fn durable_progress_requires_negotiation_exact_scope_mac_and_eof() {
|
||||
assert!(result.is_err(), "invalid progress case {case}");
|
||||
}
|
||||
}
|
||||
println!(
|
||||
"usage_assertion: {}",
|
||||
serde_json::json!({
|
||||
"case_id": "USAGE-23", "assertion_id": "USAGE-23-A01", "status": "PASS",
|
||||
"evidence": {
|
||||
"worker_publication_epoch": progress_identity().publication_epoch,
|
||||
"leader_publication_epoch": leader_publication_epoch,
|
||||
"outcome": "durable_progress",
|
||||
"companion_identity_preserved": true,
|
||||
"mismatched_companion_rejected": true,
|
||||
}
|
||||
}),
|
||||
);
|
||||
println!("usage_cleanup: {}", serde_json::json!({"case_id": "USAGE-23", "status": "PASS"}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user