You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2026/10/26 16:31:34 UTC

(opendal-yinyang) branch xuanwo/managed-sync-namespace updated: test: exercise namespace publish recovery while offline

This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch xuanwo/managed-sync-namespace
in repository https://gitbox.apache.org/repos/asf/opendal-yinyang.git


The following commit(s) were added to refs/heads/xuanwo/managed-sync-namespace by this push:
     new 612bf8e  test: exercise namespace publish recovery while offline
612bf8e is described below

commit 612bf8e4a147a0368e28004081a966e583035e29
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Tue Oct 27 00:31:28 2026 +0800

    test: exercise namespace publish recovery while offline
    
    Co-authored-by: Chojan Shang <ps...@apache.org>
---
 tests/sync.rs | 45 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/tests/sync.rs b/tests/sync.rs
index 1952e89..35cb182 100644
--- a/tests/sync.rs
+++ b/tests/sync.rs
@@ -672,14 +672,18 @@ async fn namespace_unknown_survives_unavailable_recovery_and_resolves_once() {
     let sync = Sync::open(authority.clone(), temp.path().join("sync"))
         .await
         .unwrap();
-    assert!(sync.resolve_namespace(intent).await.is_err());
-    assert_eq!(
-        sync.namespace_status(intent).await.unwrap().state,
-        NamespaceState::Unknown
-    );
+    let before = sync.namespace_status(intent).await.unwrap();
+    assert_eq!(before.state, NamespaceState::Unknown);
+    assert!(sync.publish(intent).await.is_err());
+    let after = sync.namespace_status(intent).await.unwrap();
+    assert_eq!(after.state, NamespaceState::Unknown);
+    assert_eq!(after.intent.commit_id, before.intent.commit_id);
+    assert_eq!(after.intent.request_digest, before.intent.request_digest);
 
     backend.state.lock().unwrap().offline = false;
+    let revision = sync.publish(intent).await.unwrap();
     let receipt = sync.resolve_namespace(intent).await.unwrap().unwrap();
+    assert_eq!(revision, receipt.cursor.revision);
     assert!(matches!(
         sync.namespace_status(intent).await.unwrap().state,
         NamespaceState::Committed(_)
@@ -690,3 +694,34 @@ async fn namespace_unknown_survives_unavailable_recovery_and_resolves_once() {
     );
     assert_eq!(sync.publish(intent).await.unwrap(), receipt.cursor.revision);
 }
+
+#[tokio::test]
+async fn namespace_restore_failure_keeps_a_prepared_intent_retryable() {
+    let backend = TestBackend::default();
+    let authority: Arc<dyn Authority> = Arc::new(
+        Fs::create(backend.operator(), BackendProfile::Minio)
+            .await
+            .unwrap(),
+    );
+    let temp = tempfile::tempdir().unwrap();
+    let sync = Sync::open(authority.clone(), temp.path().join("sync"))
+        .await
+        .unwrap();
+    let baseline = authority.observe_latest().await.unwrap();
+    let intent = sync
+        .stage_create_directory(authority.root(), "retry-restore", baseline.revision())
+        .await
+        .unwrap();
+    backend.state.lock().unwrap().offline = true;
+    assert!(sync.publish(intent).await.is_err());
+    assert_eq!(
+        sync.namespace_status(intent).await.unwrap().state,
+        NamespaceState::Retryable
+    );
+    backend.state.lock().unwrap().offline = false;
+    sync.publish(intent).await.unwrap();
+    assert!(matches!(
+        sync.namespace_status(intent).await.unwrap().state,
+        NamespaceState::Committed(_)
+    ));
+}