From e26b4f6860f821c1bf5b66df4004b202e649f09e Mon Sep 17 00:00:00 2001 From: Xiaoyang Han Date: Thu, 8 Oct 2026 01:09:57 +0800 Subject: [PATCH] test(mst2): repair OBJECT error and storage-route fixtures Repair five observed regressions in exact #67 native run37647717995 (2374 passed/6 failed/2 ignored). Three OBJECT expectations now use the existing formal EXPECTED_DIGEST_MISMATCH wire code. The half-lease fixture reaches actual failed COMMIT with its completeness trigger enabled and deferred, avoiding PostgreSQL pending-event ALTER; failed commit must restore all trigger modes and route/source/root inventories. The temp-shadow fixture uses legal CASE syntax for its exact identity assertion. Production guards, all integrity assertions and the #70 CHUNK lifetime repair remain unchanged. The sixth old FK expectation was repaired by #68. Repaired native validation remains pending. --- .../router/snapshot_objects_bounded_tests.rs | 6 ++-- .../router/snapshot_storage_route_fixture.rs | 32 ++++++++++++++----- .../router/snapshot_storage_route_tests.rs | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/api/router/snapshot_objects_bounded_tests.rs b/src/api/router/snapshot_objects_bounded_tests.rs index 6475c53a..d001de12 100644 --- a/src/api/router/snapshot_objects_bounded_tests.rs +++ b/src/api/router/snapshot_objects_bounded_tests.rs @@ -264,7 +264,7 @@ async fn every_alias_is_admitted_and_exact_oid_body_is_loaded_once() { .send("POST", "objects", Body::from(request.to_string())) .await, 409, - "DIGEST_MISMATCH", + "EXPECTED_DIGEST_MISMATCH", false, ) .await; @@ -314,7 +314,7 @@ async fn conflicting_sizes_reject_before_io_and_distinct_oids_still_verify_each_ .send("POST", "objects", Body::from(request.to_string())) .await, 409, - "DIGEST_MISMATCH", + "EXPECTED_DIGEST_MISMATCH", false, ) .await; @@ -388,7 +388,7 @@ async fn truncated_wrong_sha_and_late_stream_error_never_produce_200() { ( FaultKind::Parts(vec![Bytes::from(vec![0; 8192])]), 409, - "DIGEST_MISMATCH", + "EXPECTED_DIGEST_MISMATCH", 8192, ), ( diff --git a/src/api/router/snapshot_storage_route_fixture.rs b/src/api/router/snapshot_storage_route_fixture.rs index 751502b1..abc3aa48 100644 --- a/src/api/router/snapshot_storage_route_fixture.rs +++ b/src/api/router/snapshot_storage_route_fixture.rs @@ -65,8 +65,8 @@ pub(super) async fn reject_half_lease_commit_for_test( .await .unwrap(); // Simulate an omitted derived write; all statement, identity and deferred - // completeness guards remain active, and the deriving trigger is restored - // before the actual commit attempt. + // completeness guards remain active. Failed commit rolls back the trigger + // change; pending deferred events forbid ALTER TABLE before commit. txn.execute_unprepared( "ALTER TABLE mst2_snapshot_lease DISABLE TRIGGER mst2_route_lease_insert", ) @@ -91,12 +91,28 @@ pub(super) async fn reject_half_lease_commit_for_test( .unwrap(); assert_eq!(half.try_get::("", "actual").unwrap(), 1); assert_eq!(half.try_get::("", "routes").unwrap(), 0); - txn.execute_unprepared( - "ALTER TABLE mst2_snapshot_lease ENABLE TRIGGER mst2_route_lease_insert", - ) - .await - .unwrap(); - assert_eq!(trigger_modes(&txn).await, before); + let paused = before.replacen( + "mst2_snapshot_lease:mst2_route_lease_insert:O", + "mst2_snapshot_lease:mst2_route_lease_insert:D", + 1, + ); + assert_ne!(paused, before); + assert_eq!(trigger_modes(&txn).await, paused); + let complete = txn + .query_one_raw(Statement::from_string( + DbBackend::Postgres, + "SELECT t.tgenabled::text AS mode,t.tgdeferrable AS deferrable,t.tginitdeferred AS deferred + FROM pg_catalog.pg_trigger t WHERE t.tgrelid='mst2_snapshot_lease'::regclass + AND t.tgname='mst2_route_complete' AND NOT t.tgisinternal", + )) + .await + .unwrap() + .unwrap(); + let mode: String = complete.try_get("", "mode").unwrap(); + assert!(matches!(mode.as_str(), "O" | "A")); + assert!(before.contains(&format!("mst2_snapshot_lease:mst2_route_complete:{mode}"))); + assert!(complete.try_get::("", "deferrable").unwrap()); + assert!(complete.try_get::("", "deferred").unwrap()); let rejected = txn.commit().await.unwrap_err(); assert!( rejected diff --git a/src/api/router/snapshot_storage_route_tests.rs b/src/api/router/snapshot_storage_route_tests.rs index bd8df6f9..25d40ec3 100644 --- a/src/api/router/snapshot_storage_route_tests.rs +++ b/src/api/router/snapshot_storage_route_tests.rs @@ -1038,7 +1038,7 @@ async fn mst2_generic_storage_routes_temp_prepare_shadow_rejects_qualified_conte scalar(&txn, "SELECT count(*) FROM mst2_metadata_prepare").await, 0 ); - assert_eq!(scalar(&txn, "SELECT (to_regclass('mst2_metadata_prepare')='pg_temp.mst2_metadata_prepare'::regclass)::bigint").await, 1); + assert_eq!(scalar(&txn, "SELECT CASE WHEN to_regclass('mst2_metadata_prepare')='pg_temp.mst2_metadata_prepare'::regclass THEN 1::bigint ELSE 0::bigint END").await, 1); let rejected = txn.execute_raw(statement(&format!( "INSERT INTO {schema}.mst2_snapshot_context(snapshot_id,canonical_descriptor,instance_id,commit_oid, root_tree_oid,metadata_root,prepare_id,publication_sequence,writer_epoch,certificate_receipt_id,authorization_epoch,state)