Skip to content

Commit

Permalink
Add test of out of order UploadPart (#7047)
Browse files Browse the repository at this point in the history
* Add test of out of order UploadPart

* Update object_store/src/integration.rs

---------

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
  • Loading branch information
tustvold and alamb authored Feb 3, 2025
1 parent c63b81d commit 9327f47
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions object_store/src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ mod tests {
stream_get(&integration).await;
multipart(&integration, &integration).await;
multipart_race_condition(&integration, true).await;
multipart_out_of_order(&integration).await;
signing(&integration).await;
s3_encryption(&integration).await;
put_get_attributes(&integration).await;
Expand Down
1 change: 1 addition & 0 deletions object_store/src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ mod tests {
put_opts(&integration, true).await;
multipart(&integration, &integration).await;
multipart_race_condition(&integration, false).await;
multipart_out_of_order(&integration).await;
signing(&integration).await;

let validate = !integration.client.config().disable_tagging;
Expand Down
1 change: 1 addition & 0 deletions object_store/src/gcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ mod test {
stream_get(&integration).await;
multipart(&integration, &integration).await;
multipart_race_condition(&integration, true).await;
multipart_out_of_order(&integration).await;
// Fake GCS server doesn't currently honor preconditions
get_opts(&integration).await;
put_opts(&integration, true).await;
Expand Down
35 changes: 33 additions & 2 deletions object_store/src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use core::str;
use crate::multipart::MultipartStore;
use crate::path::Path;
use crate::{
Attribute, Attributes, DynObjectStore, Error, GetOptions, GetRange, ObjectStore, PutMode,
PutPayload, UpdateVersion, WriteMultipart,
Attribute, Attributes, DynObjectStore, Error, GetOptions, GetRange, MultipartUpload,
ObjectStore, PutMode, PutPayload, UpdateVersion, WriteMultipart,
};
use bytes::Bytes;
use futures::stream::FuturesUnordered;
Expand Down Expand Up @@ -1196,3 +1196,34 @@ pub async fn multipart_race_condition(storage: &dyn ObjectStore, last_writer_win
));
}
}

/// Tests performing out of order multipart uploads
pub async fn multipart_out_of_order(storage: &dyn ObjectStore) {
let path = Path::from("test_multipart_out_of_order");
let mut multipart_upload = storage.put_multipart(&path).await.unwrap();

let part1 = std::iter::repeat(b'1')
.take(5 * 1024 * 1024)
.collect::<Bytes>();
let part2 = std::iter::repeat(b'2')
.take(5 * 1024 * 1024)
.collect::<Bytes>();
let part3 = std::iter::repeat(b'3')
.take(5 * 1024 * 1024)
.collect::<Bytes>();
let full = [part1.as_ref(), part2.as_ref(), part3.as_ref()].concat();

let fut1 = multipart_upload.put_part(part1.into());
let fut2 = multipart_upload.put_part(part2.into());
let fut3 = multipart_upload.put_part(part3.into());
// note order is 2,3,1 , different than the parts were created in
fut2.await.unwrap();
fut3.await.unwrap();
fut1.await.unwrap();

multipart_upload.complete().await.unwrap();

let result = storage.get(&path).await.unwrap();
let bytes = result.bytes().await.unwrap();
assert_eq!(bytes, full);
}

0 comments on commit 9327f47

Please sign in to comment.