Skip to content

Commit

Permalink
Add failing proptest
Browse files Browse the repository at this point in the history
Adds a failing proptest, which occured as we did not remove inflight writes to a file, if it was overriden by a PutObject.
Signed-off-by: Christian Hagemeier <[email protected]>
  • Loading branch information
c-hagem committed Jan 15, 2025
1 parent 456c7de commit 2bf9c74
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion mountpoint-s3/tests/reftests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,21 @@ impl Harness {
self.client.add_object(&key, object.clone());
self.reference.add_remote_key(&key, object);
// Any local directories along the path are made remote by adding this object
self.reference.remove_local_parents(key_as_path);
self.reference.remove_local_parents(key_as_path.clone());
// If we overwrite a file that is currently part of an inflight write
// we have to remove that inflight write, as otherwise we fail when opening the
// ino to continue writing.
let mut idx: i32 = -1;
for inflight_write in &self.inflight_writes.writes {
idx += 1;
if inflight_write.path == key_as_path {
break;
}
}

if idx != -1 {
self.inflight_writes.remove(InflightWriteIndex(idx as usize));
}
}

/// Perform a DeleteObject on the bucket, to simulate concurrent access to the bucket by a
Expand Down Expand Up @@ -1330,4 +1344,25 @@ mod mutations {
0,
)
}

#[test]
fn regression_stale_ino() {
run_test(
TreeNode::Directory(BTreeMap::from([])),
vec![
Op::CreateFile(
ValidName("a".into()),
DirectoryIndex(0),
FileContent(0, FileSize::Small(0)),
),
Op::PutObject(
DirectoryIndex(0),
Name("a/a".into()),
FileContent(0, FileSize::Small(0)),
),
Op::FinishWrite(InflightWriteIndex(0)),
],
0,
);
}
}

0 comments on commit 2bf9c74

Please sign in to comment.