Skip to content

Commit

Permalink
fixup! Use randomized content ID for Azure multipart uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
avarnon committed Dec 12, 2024
1 parent d11eb21 commit 5edc040
Showing 1 changed file with 0 additions and 99 deletions.
99 changes: 0 additions & 99 deletions object_store/src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,10 @@ impl MultipartStore for MicrosoftAzure {

#[cfg(test)]
mod tests {
use core::str;

use super::*;
use crate::integration::*;
use crate::tests::*;
use bytes::Bytes;
use rand::thread_rng;
use rand::Rng;

#[tokio::test]
async fn azure_blob_test() {
Expand Down Expand Up @@ -397,99 +393,4 @@ mod tests {
azure_storage_token
);
}

#[tokio::test]
async fn azure_parallel_put_multipart_test() {
maybe_skip_integration!();
let integration = MicrosoftAzureBuilder::from_env().build().unwrap();

let rng = thread_rng();
let suffix = String::from_utf8(
rng.sample_iter(rand::distributions::Alphanumeric)
.take(32)
.collect(),
)
.unwrap();
let path = Path::from(format!("put_multipart_{suffix}"));

let mut multipart_upload_1 = integration.put_multipart(&path).await.unwrap();
let mut multipart_upload_2 = integration.put_multipart(&path).await.unwrap();

multipart_upload_1
.put_part(Bytes::from("1:0,").into())
.await
.unwrap();
multipart_upload_2
.put_part(Bytes::from("2:0,").into())
.await
.unwrap();

multipart_upload_2
.put_part(Bytes::from("2:1,").into())
.await
.unwrap();
multipart_upload_1
.put_part(Bytes::from("1:1,").into())
.await
.unwrap();

multipart_upload_1
.put_part(Bytes::from("1:2,").into())
.await
.unwrap();
multipart_upload_2
.put_part(Bytes::from("2:2,").into())
.await
.unwrap();

multipart_upload_2
.put_part(Bytes::from("2:3,").into())
.await
.unwrap();
multipart_upload_1
.put_part(Bytes::from("1:3,").into())
.await
.unwrap();

multipart_upload_1
.put_part(Bytes::from("1:4,").into())
.await
.unwrap();
multipart_upload_2
.put_part(Bytes::from("2:4,").into())
.await
.unwrap();

multipart_upload_1.complete().await.unwrap();
let err = multipart_upload_2.complete().await.unwrap_err();

assert!(matches!(err, crate::Error::Generic { .. }), "{err}");

if let crate::Error::Generic { source, store } = err as crate::Error {
assert_eq!(store, STORE);

if let Some(crate::client::retry::Error::Client { status, body, .. }) =
source.downcast_ref::<crate::client::retry::Error>()
{
assert_eq!(status.clone(), http::StatusCode::BAD_REQUEST);

let body = body.clone().unwrap();
if !body.contains("<Error><Code>InvalidBlockList</Code><Message>The specified block list is invalid.") {
panic!(
"assertion failed: `{body:?}` is not an InvalidBlockList response",
);
}
} else {
panic!("Not a Client error")
}
} else {
panic!("Not a Generic error")
}

let get_result = integration.get(&path).await.unwrap();
let bytes = get_result.bytes().await.unwrap();
let string_contents = str::from_utf8(&bytes).unwrap();

assert_eq!("1:0,1:1,1:2,1:3,1:4,", string_contents);
}
}

0 comments on commit 5edc040

Please sign in to comment.