From 37cbb32c796e52e68ccd61621f6d1fd714d93ccf Mon Sep 17 00:00:00 2001
From: Christian Hagemeier <chagem@amazon.com>
Date: Fri, 10 Jan 2025 17:02:20 +0000
Subject: [PATCH] Add failing proptest

Adds a proptest that exposes (most likely) a bug in Mountpoint regarding the local content (a file that is created, but not open yet) of a directory being forgotten, if all of the remote content is deleted.

Signed-off-by: Christian Hagemeier <chagem@amazon.com>
---
 mountpoint-s3/tests/reftests/harness.rs | 61 +++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/mountpoint-s3/tests/reftests/harness.rs b/mountpoint-s3/tests/reftests/harness.rs
index 5202a91b0..ab9e08dc8 100644
--- a/mountpoint-s3/tests/reftests/harness.rs
+++ b/mountpoint-s3/tests/reftests/harness.rs
@@ -1290,4 +1290,65 @@ mod mutations {
             0,
         )
     }
+
+
+    #[test]
+    fn regression_local_lost_when_removing_remote_entries() {
+        run_test(TreeNode::Directory(BTreeMap::from([])), vec![
+            Op::CreateDirectory(
+                DirectoryIndex(
+                    0,
+                ),
+                ValidName(
+                    "a".into(),
+                ),
+            ),
+            Op::CreateDirectory(
+                DirectoryIndex(
+                    0,
+                ),
+                ValidName(
+                    "-".into(),
+                ),
+            ),
+            Op::WriteFile(
+                ValidName(
+                    "a".into(),
+                ),
+                DirectoryIndex(
+                    1,
+                ),
+                FileContent(
+                    0,
+                    FileSize::Small(0),
+                ),
+            ),
+            Op::CreateFile(
+                ValidName(
+                    "aa".into(),
+                ),
+                DirectoryIndex(
+                    1,
+                ),
+                FileContent(
+                    0,
+                    FileSize::Small(0),
+                ),
+            ),
+            Op::DeleteObject(
+                KeyIndex(
+                    0,
+                ),
+            ),
+            Op::CreateDirectory(
+                DirectoryIndex(
+                    0,
+                ),
+                ValidName(
+                    "a".into(),
+                ),
+            ),
+        ], 0)
+    }
+
 }