From 48c26937cbaa2313ec5d24cdcba461693d0a297f Mon Sep 17 00:00:00 2001 From: stemjacobs Date: Mon, 7 Aug 2023 10:47:49 -0500 Subject: [PATCH 1/4] content-type reflects non compressed encoding --- Cargo.lock | 2 +- src/sinks/azure_blob/request_builder.rs | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63cffea6b49db..e48ba38426549 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -499,7 +499,7 @@ dependencies = [ "proc-macro2 1.0.66", "quote 1.0.32", "strum", - "syn 2.0.27", + "syn 2.0.28", "thiserror", ] diff --git a/src/sinks/azure_blob/request_builder.rs b/src/sinks/azure_blob/request_builder.rs index ae8f8770381a5..9f2fd96d13010 100644 --- a/src/sinks/azure_blob/request_builder.rs +++ b/src/sinks/azure_blob/request_builder.rs @@ -93,20 +93,9 @@ impl RequestBuilder<(String, Vec)> for AzureBlobRequestOptions { AzureBlobRequest { blob_data, content_encoding: self.compression.content_encoding(), - content_type: self.compression.content_type(), + content_type: self.encoder.1.content_type(), metadata: azure_metadata, request_metadata, } } -} - -impl Compression { - pub const fn content_type(self) -> &'static str { - match self { - Self::None => "text/plain", - Self::Gzip(_) => "application/gzip", - Self::Zlib(_) => "application/zlib", - Self::Zstd(_) => "application/zstd", - } - } -} +} \ No newline at end of file From 102a9c35224e13531a13e4ad721aa8a14445565d Mon Sep 17 00:00:00 2001 From: stemjacobs Date: Mon, 7 Aug 2023 15:37:00 -0500 Subject: [PATCH 2/4] update tests --- src/sinks/azure_blob/integration_tests.rs | 21 ++++++++++++++++++--- src/sinks/azure_blob/test.rs | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/sinks/azure_blob/integration_tests.rs b/src/sinks/azure_blob/integration_tests.rs index ec3dc5ac1d1c8..3668f57713f9e 100644 --- a/src/sinks/azure_blob/integration_tests.rs +++ b/src/sinks/azure_blob/integration_tests.rs @@ -111,7 +111,14 @@ async fn azure_blob_insert_json_into_blob() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; - assert_eq!(blob.properties.content_type, String::from("text/plain")); + assert_eq!( + blob.properties.content_encoding, + None + ); + assert_eq!( + blob.properties.content_type, + String::from("application/x-ndjson") + ); let expected = events .iter() .map(|event| serde_json::to_string(&event.as_log().all_fields().unwrap()).unwrap()) @@ -138,9 +145,13 @@ async fn azure_blob_insert_lines_into_blob_gzip() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log.gz")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; + assert_eq!( + blob.properties.content_encoding, + Some(String::from("gzip")) + ); assert_eq!( blob.properties.content_type, - String::from("application/gzip") + String::from("text/plain") ); assert_eq!(lines, blob_lines); } @@ -170,9 +181,13 @@ async fn azure_blob_insert_json_into_blob_gzip() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log.gz")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; + assert_eq!( + blob.properties.content_encoding, + Some(String::from("gzip")) + ); assert_eq!( blob.properties.content_type, - String::from("application/gzip") + String::from("application/json") ); let expected = events .iter() diff --git a/src/sinks/azure_blob/test.rs b/src/sinks/azure_blob/test.rs index 0c4ad1f38dd53..d35606ac12938 100644 --- a/src/sinks/azure_blob/test.rs +++ b/src/sinks/azure_blob/test.rs @@ -129,7 +129,7 @@ fn azure_blob_build_request_with_compression() { assert_eq!(request.metadata.partition_key, "blob.log.gz".to_string()); assert_eq!(request.content_encoding, Some("gzip")); - assert_eq!(request.content_type, "application/gzip"); + assert_eq!(request.content_type, "text/plain"); } #[test] From c37ae7ed46bda26a5c266af877a1d8184d1f9f46 Mon Sep 17 00:00:00 2001 From: Steve Jacobs Date: Tue, 8 Aug 2023 11:09:08 -0500 Subject: [PATCH 3/4] Update src/sinks/azure_blob/integration_tests.rs Good callout, yeah this slipped past me since that particular test is currently ignored. Co-authored-by: Doug Smith --- src/sinks/azure_blob/integration_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sinks/azure_blob/integration_tests.rs b/src/sinks/azure_blob/integration_tests.rs index 3668f57713f9e..dc9c1c5d51587 100644 --- a/src/sinks/azure_blob/integration_tests.rs +++ b/src/sinks/azure_blob/integration_tests.rs @@ -187,7 +187,7 @@ async fn azure_blob_insert_json_into_blob_gzip() { ); assert_eq!( blob.properties.content_type, - String::from("application/json") + String::from("application/x-ndjson") ); let expected = events .iter() From ead61629730ea4a1504d25d918fe7c0f85dc97ce Mon Sep 17 00:00:00 2001 From: stemjacobs Date: Tue, 8 Aug 2023 13:04:46 -0500 Subject: [PATCH 4/4] fix formatting --- src/sinks/azure_blob/integration_tests.rs | 22 +++++----------------- src/sinks/azure_blob/request_builder.rs | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/sinks/azure_blob/integration_tests.rs b/src/sinks/azure_blob/integration_tests.rs index dc9c1c5d51587..9cddbef79f949 100644 --- a/src/sinks/azure_blob/integration_tests.rs +++ b/src/sinks/azure_blob/integration_tests.rs @@ -111,12 +111,9 @@ async fn azure_blob_insert_json_into_blob() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; + assert_eq!(blob.properties.content_encoding, None); assert_eq!( - blob.properties.content_encoding, - None - ); - assert_eq!( - blob.properties.content_type, + blob.properties.content_type, String::from("application/x-ndjson") ); let expected = events @@ -145,14 +142,8 @@ async fn azure_blob_insert_lines_into_blob_gzip() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log.gz")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; - assert_eq!( - blob.properties.content_encoding, - Some(String::from("gzip")) - ); - assert_eq!( - blob.properties.content_type, - String::from("text/plain") - ); + assert_eq!(blob.properties.content_encoding, Some(String::from("gzip"))); + assert_eq!(blob.properties.content_type, String::from("text/plain")); assert_eq!(lines, blob_lines); } @@ -181,10 +172,7 @@ async fn azure_blob_insert_json_into_blob_gzip() { assert_eq!(blobs.len(), 1); assert!(blobs[0].clone().ends_with(".log.gz")); let (blob, blob_lines) = config.get_blob(blobs[0].clone()).await; - assert_eq!( - blob.properties.content_encoding, - Some(String::from("gzip")) - ); + assert_eq!(blob.properties.content_encoding, Some(String::from("gzip"))); assert_eq!( blob.properties.content_type, String::from("application/x-ndjson") diff --git a/src/sinks/azure_blob/request_builder.rs b/src/sinks/azure_blob/request_builder.rs index 9f2fd96d13010..0ae3fb848d922 100644 --- a/src/sinks/azure_blob/request_builder.rs +++ b/src/sinks/azure_blob/request_builder.rs @@ -98,4 +98,4 @@ impl RequestBuilder<(String, Vec)> for AzureBlobRequestOptions { request_metadata, } } -} \ No newline at end of file +}