alamb commented on code in PR #929:
URL:
https://github.com/apache/arrow-rs-object-store/pull/929#discussion_r4812927464
##########
src/aws/client.rs:
##########
@@ -1242,6 +1321,47 @@ mod tests {
.unwrap()
}
+ #[cfg(feature = "reqwest")]
+ #[tokio::test]
+ async fn test_list_throttle_preserves_type() {
+ let mock = MockServer::new().await;
+ mock.push(
+ Response::builder()
+ .status(StatusCode::TOO_MANY_REQUESTS)
+ .body(String::new())
+ .unwrap(),
+ );
+
+ let store = AmazonS3Builder::new()
+ .with_endpoint(mock.url())
+ .with_bucket_name("test-bucket")
+ .with_region("us-east-1")
+ .with_allow_http(true)
+ .with_skip_signature(true)
+ .with_retry(RetryConfig {
+ max_retries: 0,
+ ..Default::default()
+ })
+ .build()
+ .unwrap();
+ let prefix = Path::from("prefix");
+ let error = store
+ .list(Some(&prefix))
+ .try_collect::<Vec<_>>()
+ .await
+ .unwrap_err();
+
+ let error_debug = format!("{error:?}");
Review Comment:
what is this error debug thing all about? Why not just use te format
directly?
##########
src/azure/client.rs:
##########
@@ -2371,4 +2466,91 @@ Time:2018-06-14T16:46:54.6040685Z</Message></Error>\r
assert_eq!("404", code);
assert_eq!("The specified blob does not exist.", reason);
}
+
+ #[tokio::test]
+ async fn test_parse_blob_batch_delete_body_classifies_throttles() {
+ let boundary = "batchresponse_mixed";
+ let response_body = format!(
+ "--{boundary}\r\n\
+ Content-Type: application/http\r\n\
+ Content-ID: 0\r\n\
+ \r\n\
+ HTTP/1.1 202 Accepted\r\n\
+ \r\n\
+ --{boundary}\r\n\
+ Content-Type: application/http\r\n\
+ Content-ID: 1\r\n\
+ \r\n\
+ HTTP/1.1 404 Not Found\r\n\
+ x-ms-error-code: BlobNotFound\r\n\
+ \r\n\
+ --{boundary}\r\n\
+ Content-Type: application/http\r\n\
+ Content-ID: 2\r\n\
+ \r\n\
+ HTTP/1.1 429 Too Many Requests\r\n\
+ \r\n\
+ --{boundary}\r\n\
+ Content-Type: application/http\r\n\
+ Content-ID: 3\r\n\
+ \r\n\
+ HTTP/1.1 503 Service Unavailable\r\n\
+ x-ms-error-code: ServerBusy\r\n\
+ \r\n\
+ --{boundary}\r\n\
+ Content-Type: application/http\r\n\
+ Content-ID: 4\r\n\
+ \r\n\
+ HTTP/1.1 503 Service Unavailable\r\n\
+ x-ms-error-code: InternalError\r\n\
+ \r\n\
+ --{boundary}--\r\n"
+ );
+ let paths = [
+ Path::from("ok"),
+ Path::from("missing"),
+ Path::from("rate-limited"),
+ Path::from("busy"),
+ Path::from("unavailable"),
+ ];
+
+ let results =
+ parse_blob_batch_delete_body(Bytes::from(response_body),
boundary.to_string(), &paths)
+ .await
+ .unwrap();
+
+ assert_eq!(results.len(), paths.len());
+ assert_eq!(results[0].as_ref().unwrap(), &paths[0]);
+ assert!(matches!(
+ results[1].as_ref().unwrap_err(),
+ crate::Error::NotFound { path, .. } if path == paths[1].as_ref()
+ ));
+ assert!(matches!(
Review Comment:
could you plese rewrite this test with a fixture so it is easier to
undertand what input goes with what expected output? Trying to remember
results[3] maps to something is tricky for sure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]