Skip to content

Commit

Permalink
Add missing tests and any impl for CRC64Nvme in ListObjectsV2, HeadOb…
Browse files Browse the repository at this point in the history
…ject, GetObjectAttributes, GetObject

Signed-off-by: Daniel Carl Jones <[email protected]>
  • Loading branch information
dannycjones authored and passaro committed Jan 24, 2025
1 parent d098530 commit d8bb32d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions mountpoint-s3-client/src/s3_crt_client/list_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ fn parse_checksum_algorithm(element: &mut xmltree::Element) -> Result<Vec<Checks
while let Some(content) = element.take_child("ChecksumAlgorithm") {
let algo_string = get_text(&content)?;
let checksum_algorithm = match algo_string.as_str() {
"CRC64NVME" => ChecksumAlgorithm::Crc64nvme,
"CRC32" => ChecksumAlgorithm::Crc32,
"CRC32C" => ChecksumAlgorithm::Crc32c,
"SHA1" => ChecksumAlgorithm::Sha1,
Expand Down
5 changes: 5 additions & 0 deletions mountpoint-s3-client/tests/get_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ async fn test_get_object_user_metadata_after_stream(size: usize, metadata: HashM
assert_eq!(actual_metadata, metadata);
}

#[test_case(ChecksumAlgorithm::Crc64Nvme)]
#[test_case(ChecksumAlgorithm::Crc32)]
#[test_case(ChecksumAlgorithm::Crc32C)]
#[test_case(ChecksumAlgorithm::Sha1)]
Expand Down Expand Up @@ -473,6 +474,10 @@ async fn test_get_object_checksum(checksum_algorithm: ChecksumAlgorithm) {
let checksum: Checksum = result.get_object_checksum().expect("should return checksum");

match checksum_algorithm {
ChecksumAlgorithm::Crc64Nvme => assert_eq!(
checksum.checksum_crc64nvme,
put_object_output.checksum_crc64_nvme().map(|s| s.to_string())
),
ChecksumAlgorithm::Crc32 => assert_eq!(
checksum.checksum_crc32,
put_object_output.checksum_crc32().map(|s| s.to_string())
Expand Down
13 changes: 9 additions & 4 deletions mountpoint-s3-client/tests/get_object_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ async fn test_with_checksum(checksum_algorithm: ChecksumAlgorithm) {

let checksum = result.checksum.unwrap();
match checksum_algorithm {
ChecksumAlgorithm::Crc64Nvme => assert_eq!(
checksum.checksum_crc64nvme,
put_object_output.checksum_crc64_nvme().map(|s| s.to_string())
),
ChecksumAlgorithm::Crc32 => assert_eq!(
checksum.checksum_crc32,
put_object_output.checksum_crc32().map(|s| s.to_string())
Expand Down Expand Up @@ -210,10 +214,11 @@ async fn test_get_attributes() {
assert!(result.object_parts.is_none());
}

#[test_case(ChecksumAlgorithm::Crc32; "Checksum CRC32")]
#[test_case(ChecksumAlgorithm::Crc32C; "Checksum CRC32C")]
#[test_case(ChecksumAlgorithm::Sha1; "Checksum SHA1")]
#[test_case(ChecksumAlgorithm::Sha256; "Checksum SHA256")]
#[test_case(ChecksumAlgorithm::Crc64Nvme)]
#[test_case(ChecksumAlgorithm::Crc32)]
#[test_case(ChecksumAlgorithm::Crc32C)]
#[test_case(ChecksumAlgorithm::Sha1)]
#[test_case(ChecksumAlgorithm::Sha256)]
#[tokio::test]
async fn test_get_attributes_with_checksum(checksum_algorithm: ChecksumAlgorithm) {
test_with_checksum(checksum_algorithm).await;
Expand Down
5 changes: 5 additions & 0 deletions mountpoint-s3-client/tests/head_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async fn test_head_object() {
);
}

#[test_case(ChecksumAlgorithm::Crc64Nvme)]
#[test_case(ChecksumAlgorithm::Crc32)]
#[test_case(ChecksumAlgorithm::Crc32C)]
#[test_case(ChecksumAlgorithm::Sha1)]
Expand Down Expand Up @@ -83,6 +84,10 @@ async fn test_head_object_checksum(checksum_algorithm: ChecksumAlgorithm) {
let checksum = result.checksum;
if retrieve_checksum {
match &checksum_algorithm {
ChecksumAlgorithm::Crc64Nvme => assert_eq!(
checksum.checksum_crc64nvme,
put_object_output.checksum_crc64_nvme().map(|s| s.to_string())
),
ChecksumAlgorithm::Crc32 => assert_eq!(
checksum.checksum_crc32,
put_object_output.checksum_crc32().map(|s| s.to_string())
Expand Down
2 changes: 2 additions & 0 deletions mountpoint-s3-client/tests/list_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async fn test_interesting_keys() {
assert!(result.next_continuation_token.is_none());
}

#[test_case(ChecksumAlgorithm::Crc64Nvme)]
#[test_case(ChecksumAlgorithm::Crc32)]
#[test_case(ChecksumAlgorithm::Crc32C)]
#[test_case(ChecksumAlgorithm::Sha1)]
Expand Down Expand Up @@ -211,6 +212,7 @@ async fn test_checksum_attribute(upload_checksum_algorithm: ChecksumAlgorithm) {
assert_eq!(object.key, format!("{}{}", prefix, "hello.txt"));

let expected_checksum_algorithm = match upload_checksum_algorithm {
ChecksumAlgorithm::Crc64Nvme => mountpoint_s3_client::types::ChecksumAlgorithm::Crc64nvme,
ChecksumAlgorithm::Crc32 => mountpoint_s3_client::types::ChecksumAlgorithm::Crc32,
ChecksumAlgorithm::Crc32C => mountpoint_s3_client::types::ChecksumAlgorithm::Crc32c,
ChecksumAlgorithm::Sha1 => mountpoint_s3_client::types::ChecksumAlgorithm::Sha1,
Expand Down

0 comments on commit d8bb32d

Please sign in to comment.