diff --git a/sdk/core/src/policies/retry_policies/retry_policy.rs b/sdk/core/src/policies/retry_policies/retry_policy.rs index ce3342bba9d..db7df10582b 100644 --- a/sdk/core/src/policies/retry_policies/retry_policy.rs +++ b/sdk/core/src/policies/retry_policies/retry_policy.rs @@ -91,11 +91,16 @@ where error } Err(error) => { - log::debug!( - "error occurred when making request which will be retried: {}", + if error.kind() == &ErrorKind::Io { + log::debug!( + "io error occurred when making request which will be retried: {}", + error + ); error - ); - error + } else { + log::error!("non-io error occurred which will not be retried: {}", error); + return Err(error); + } } }; diff --git a/sdk/data_cosmos/src/authorization_policy.rs b/sdk/data_cosmos/src/authorization_policy.rs index 2fa57d59b87..5ddcf40a44d 100644 --- a/sdk/data_cosmos/src/authorization_policy.rs +++ b/sdk/data_cosmos/src/authorization_policy.rs @@ -1,7 +1,6 @@ -use crate::headers::{HEADER_DATE, HEADER_VERSION}; use crate::resources::permission::AuthorizationToken; use crate::resources::ResourceType; -use azure_core::headers::{HeaderValue, AUTHORIZATION}; +use azure_core::headers::{HeaderValue, AUTHORIZATION, MS_DATE, VERSION}; use azure_core::{date, Context, Policy, PolicyResult, Request}; use hmac::{Hmac, Mac}; use sha2::Sha256; @@ -11,7 +10,7 @@ use time::OffsetDateTime; use url::form_urlencoded; const AZURE_VERSION: &str = "2018-12-31"; -const VERSION: &str = "1.0"; +const VERSION_NUMBER: &str = "1.0"; /// The `AuthorizationPolicy` takes care to authenticate your calls to Azure CosmosDB. /// @@ -75,8 +74,8 @@ impl Policy for AuthorizationPolicy { &auth ); - request.insert_header(HEADER_DATE, HeaderValue::from(time_nonce.to_string())); - request.insert_header(HEADER_VERSION, HeaderValue::from_static(AZURE_VERSION)); + request.insert_header(MS_DATE, HeaderValue::from(date::to_rfc1123(&time_nonce))); + request.insert_header(VERSION, HeaderValue::from_static(AZURE_VERSION)); request.insert_header(AUTHORIZATION, HeaderValue::from(auth)); // next[0] will not panic, because we checked at the beginning of the function @@ -161,7 +160,7 @@ fn generate_authorization( let str_unencoded = format!( "type={}&ver={}&sig={}", - authorization_type, VERSION, signature + authorization_type, VERSION_NUMBER, signature ); trace!( "generate_authorization::str_unencoded == {:?}", diff --git a/sdk/data_cosmos/src/headers/from_headers.rs b/sdk/data_cosmos/src/headers/from_headers.rs index d59905dfd62..b526bbd3e77 100644 --- a/sdk/data_cosmos/src/headers/from_headers.rs +++ b/sdk/data_cosmos/src/headers/from_headers.rs @@ -21,7 +21,7 @@ pub(crate) fn number_of_read_regions_from_headers(headers: &Headers) -> azure_co } pub(crate) fn activity_id_from_headers(headers: &Headers) -> azure_core::Result { - headers.get_as(&HEADER_ACTIVITY_ID) + headers.get_as(&headers::ACTIVITY_ID) } pub(crate) fn content_path_from_headers(headers: &Headers) -> azure_core::Result { diff --git a/sdk/data_cosmos/src/headers/mod.rs b/sdk/data_cosmos/src/headers/mod.rs index c089638ca71..4b68e53325f 100644 --- a/sdk/data_cosmos/src/headers/mod.rs +++ b/sdk/data_cosmos/src/headers/mod.rs @@ -2,8 +2,6 @@ use azure_core::headers::HeaderName; pub(crate) mod from_headers; -pub(crate) const HEADER_VERSION: HeaderName = HeaderName::from_static("x-ms-version"); -pub(crate) const HEADER_DATE: HeaderName = HeaderName::from_static("x-ms-date"); pub(crate) const HEADER_DOCUMENTDB_IS_UPSERT: HeaderName = HeaderName::from_static("x-ms-documentdb-is-upsert"); pub(crate) const HEADER_INDEXING_DIRECTIVE: HeaderName = @@ -14,7 +12,6 @@ pub(crate) const HEADER_SESSION_TOKEN: HeaderName = HeaderName::from_static("x-m pub(crate) const HEADER_ALLOW_MULTIPLE_WRITES: HeaderName = HeaderName::from_static("x-ms-cosmos-allow-tentative-writes"); pub(crate) const HEADER_A_IM: HeaderName = HeaderName::from_static("A-IM"); -pub(crate) const HEADER_ACTIVITY_ID: HeaderName = HeaderName::from_static("x-ms-activity-id"); pub(crate) const HEADER_DOCUMENTDB_PARTITIONRANGEID: HeaderName = HeaderName::from_static("x-ms-documentdb-partitionkeyrangeid"); pub(crate) const HEADER_DOCUMENTDB_PARTITIONKEY: HeaderName = diff --git a/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs b/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs index 7cc7ff3b239..070fac11995 100644 --- a/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs +++ b/sdk/data_cosmos/src/operations/create_or_replace_user_defined_function.rs @@ -41,7 +41,9 @@ impl CreateOrReplaceUserDefinedFunctionBuilder { .client .pipeline() .send( - self.context.clone().insert(ResourceType::Permissions), + self.context + .clone() + .insert(ResourceType::UserDefinedFunctions), &mut request, ) .await?; diff --git a/sdk/data_cosmos/src/operations/delete_stored_procedure.rs b/sdk/data_cosmos/src/operations/delete_stored_procedure.rs index 5324e05d79d..3c3b0885e26 100644 --- a/sdk/data_cosmos/src/operations/delete_stored_procedure.rs +++ b/sdk/data_cosmos/src/operations/delete_stored_procedure.rs @@ -26,7 +26,7 @@ impl DeleteStoredProcedureBuilder { .client .pipeline() .send( - self.context.clone().insert(ResourceType::Permissions), + self.context.clone().insert(ResourceType::StoredProcedures), &mut request, ) .await?; diff --git a/sdk/data_cosmos/tests/user_defined_function_operations.rs b/sdk/data_cosmos/tests/user_defined_function_operations.rs index e6218d3074a..1c7e87a1d6e 100644 --- a/sdk/data_cosmos/tests/user_defined_function_operations.rs +++ b/sdk/data_cosmos/tests/user_defined_function_operations.rs @@ -1,8 +1,7 @@ -#![cfg(all(test, feature = "test_e2e"))] use azure_data_cosmos::prelude::*; use futures::stream::StreamExt; -mod setup; +mod setup_mock; const FN_BODY: &str = r#" function tax(income) { @@ -18,47 +17,58 @@ function tax(income) { #[tokio::test] async fn user_defined_function_operations() -> azure_core::Result<()> { + env_logger::init(); const DATABASE_NAME: &str = "test-cosmos-db-udf"; const COLLECTION_NAME: &str = "test-udf"; const USER_DEFINED_FUNCTION_NAME: &str = "test"; - let client = setup::initialize()?; + let client = setup_mock::initialize("user_defined_function_operations")?; + log::info!("creating database"); // create a temp database let _ = client.create_database(DATABASE_NAME).into_future().await?; + log::info!("created database"); let database = client.database_client(DATABASE_NAME); // create a temp collection + log::info!("creating collection"); let _ = database .create_collection(COLLECTION_NAME, "/id") .into_future() .await?; + log::info!("created collection"); let collection = database.collection_client(COLLECTION_NAME); let user_defined_function = collection.user_defined_function_client(USER_DEFINED_FUNCTION_NAME); + log::info!("creating user defined function"); let ret = user_defined_function .create_user_defined_function("body") .into_future() .await?; + log::info!("created user defined function"); + log::info!("listing user defined functions"); let stream = collection .list_user_defined_functions() .max_item_count(3) .consistency_level(&ret); let mut stream = stream.into_stream(); while let Some(ret) = stream.next().await { - let ret = ret?; - assert_eq!(ret.item_count, 1); + assert_eq!(ret?.item_count, 1); } + log::info!("listed user defined functions"); + log::info!("replacing user defined functions"); let ret = user_defined_function .replace_user_defined_function(FN_BODY) .consistency_level(&ret) .into_future() .await?; + log::info!("replaced user defined functions"); + log::info!("querying documents"); let query_stmt = format!("SELECT udf.{}(100)", USER_DEFINED_FUNCTION_NAME); let ret = collection .query_documents(Query::new(query_stmt)) @@ -74,7 +84,9 @@ async fn user_defined_function_operations() -> azure_core::Result<()> { let fn_return = ret.documents().next().unwrap().as_object().unwrap(); let value = fn_return.iter().take(1).next().unwrap().1.as_f64().unwrap(); assert_eq!(value, 10.0); + log::info!("queried documents"); + log::info!("querying documents again"); let query_stmt = format!("SELECT udf.{}(10000)", USER_DEFINED_FUNCTION_NAME); let ret = collection .query_documents(Query::new(query_stmt)) @@ -97,7 +109,9 @@ async fn user_defined_function_operations() -> azure_core::Result<()> { .as_f64() .unwrap(); assert_eq!(value, 4000.0); + log::info!("queried documents again"); + log::info!("deleting test resources"); let _ret = user_defined_function .delete_user_defined_function() .consistency_level(&ret) @@ -106,6 +120,7 @@ async fn user_defined_function_operations() -> azure_core::Result<()> { // delete the database database.delete_database().into_future().await?; + log::info!("deleted test resources"); Ok(()) } diff --git a/test/transactions/user_defined_function_operations/0_request.json b/test/transactions/user_defined_function_operations/0_request.json new file mode 100644 index 00000000000..30a999c724c --- /dev/null +++ b/test/transactions/user_defined_function_operations/0_request.json @@ -0,0 +1,11 @@ +{ + "uri": "/dbs", + "method": "POST", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-date": "Tue, 09 Aug 2022 09:29:22 GMT", + "x-ms-version": "2018-12-31" + }, + "body": "eyJpZCI6InRlc3QtY29zbW9zLWRiLXVkZiJ9" +} diff --git a/test/transactions/user_defined_function_operations/0_response.json b/test/transactions/user_defined_function_operations/0_response.json new file mode 100644 index 00000000000..15d5cb2b84e --- /dev/null +++ b/test/transactions/user_defined_function_operations/0_response.json @@ -0,0 +1,34 @@ +{ + "status": 201, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "177", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:46 GMT", + "etag": "\"0000a044-0000-0700-0000-62f228ce0000\"", + "lsn": "127", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "49944775-1192-46af-bebf-4223266e74cc", + "x-ms-cosmos-llsn": "127", + "x-ms-cosmos-quorum-acked-llsn": "126", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "126", + "x-ms-last-state-change-utc": "Wed, 03 Aug 2022 00:09:12.948 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "126", + "x-ms-request-charge": "4.95", + "x-ms-request-duration-ms": "21.661", + "x-ms-resource-quota": "databases=1000;", + "x-ms-resource-usage": "databases=1;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#127", + "x-ms-transport-request-id": "1334697", + "x-ms-xp-role": "1" + }, + "body": "eyJpZCI6InRlc3QtY29zbW9zLWRiLXVkZiIsIl9yaWQiOiJoYkZqQUE9PSIsIl9zZWxmIjoiZGJzXC9oYkZqQUE9PVwvIiwiX2V0YWciOiJcIjAwMDBhMDQ0LTAwMDAtMDcwMC0wMDAwLTYyZjIyOGNlMDAwMFwiIiwiX2NvbGxzIjoiY29sbHNcLyIsIl91c2VycyI6InVzZXJzXC8iLCJfdHMiOjE2NjAwMzczMjZ9" +} diff --git a/test/transactions/user_defined_function_operations/1_request.json b/test/transactions/user_defined_function_operations/1_request.json new file mode 100644 index 00000000000..3ff38e8638c --- /dev/null +++ b/test/transactions/user_defined_function_operations/1_request.json @@ -0,0 +1,11 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls", + "method": "POST", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-date": "Tue, 09 Aug 2022 09:29:24 GMT", + "x-ms-version": "2018-12-31" + }, + "body": "eyJpZCI6InRlc3QtdWRmIiwicGFydGl0aW9uS2V5Ijp7InBhdGhzIjpbIi9pZCJdLCJraW5kIjoiSGFzaCJ9fQ==" +} diff --git a/test/transactions/user_defined_function_operations/1_response.json b/test/transactions/user_defined_function_operations/1_response.json new file mode 100644 index 00000000000..af1c380618a --- /dev/null +++ b/test/transactions/user_defined_function_operations/1_response.json @@ -0,0 +1,38 @@ +{ + "status": 201, + "headers": { + "cache-control": "no-store, no-cache", + "collection-partition-index": "0", + "collection-service-index": "0", + "content-length": "609", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:47 GMT", + "etag": "\"0000a244-0000-0700-0000-62f228d00000\"", + "lsn": "1", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "34148ada-bf59-47fe-b905-d69619ad79f1", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf", + "x-ms-cosmos-item-llsn": "1", + "x-ms-cosmos-llsn": "1", + "x-ms-cosmos-quorum-acked-llsn": "1", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "1", + "x-ms-item-lsn": "1", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:35.421 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "1", + "x-ms-request-charge": "1", + "x-ms-request-duration-ms": "0.638", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#1", + "x-ms-transport-request-id": "2", + "x-ms-xp-role": "1" + }, + "body": "eyJpZCI6InRlc3QtdWRmIiwiaW5kZXhpbmdQb2xpY3kiOnsiaW5kZXhpbmdNb2RlIjoiY29uc2lzdGVudCIsImF1dG9tYXRpYyI6dHJ1ZSwiaW5jbHVkZWRQYXRocyI6W3sicGF0aCI6IlwvKiJ9XSwiZXhjbHVkZWRQYXRocyI6W3sicGF0aCI6IlwvXCJfZXRhZ1wiXC8/In1dfSwicGFydGl0aW9uS2V5Ijp7InBhdGhzIjpbIlwvaWQiXSwia2luZCI6Ikhhc2gifSwiY29uZmxpY3RSZXNvbHV0aW9uUG9saWN5Ijp7Im1vZGUiOiJMYXN0V3JpdGVyV2lucyIsImNvbmZsaWN0UmVzb2x1dGlvblBhdGgiOiJcL190cyIsImNvbmZsaWN0UmVzb2x1dGlvblByb2NlZHVyZSI6IiJ9LCJnZW9zcGF0aWFsQ29uZmlnIjp7InR5cGUiOiJHZW9ncmFwaHkifSwiX3JpZCI6ImhiRmpBTGVDRytFPSIsIl90cyI6MTY2MDAzNzMyOCwiX3NlbGYiOiJkYnNcL2hiRmpBQT09XC9jb2xsc1wvaGJGakFMZUNHK0U9XC8iLCJfZXRhZyI6IlwiMDAwMGEyNDQtMDAwMC0wNzAwLTAwMDAtNjJmMjI4ZDAwMDAwXCIiLCJfZG9jcyI6ImRvY3NcLyIsIl9zcHJvY3MiOiJzcHJvY3NcLyIsIl90cmlnZ2VycyI6InRyaWdnZXJzXC8iLCJfdWRmcyI6InVkZnNcLyIsIl9jb25mbGljdHMiOiJjb25mbGljdHNcLyJ9" +} diff --git a/test/transactions/user_defined_function_operations/2_request.json b/test/transactions/user_defined_function_operations/2_request.json new file mode 100644 index 00000000000..df5261b2fe2 --- /dev/null +++ b/test/transactions/user_defined_function_operations/2_request.json @@ -0,0 +1,11 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/udfs", + "method": "POST", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-date": "Tue, 09 Aug 2022 09:29:26 GMT", + "x-ms-version": "2018-12-31" + }, + "body": "eyJib2R5IjoiYm9keSIsImlkIjoidGVzdCJ9" +} diff --git a/test/transactions/user_defined_function_operations/2_response.json b/test/transactions/user_defined_function_operations/2_response.json new file mode 100644 index 00000000000..619f9110504 --- /dev/null +++ b/test/transactions/user_defined_function_operations/2_response.json @@ -0,0 +1,37 @@ +{ + "status": 201, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "208", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:48 GMT", + "etag": "\"c100d2e1-0000-0700-0000-62f228d10000\"", + "lsn": "2", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "798d4f0c-55c7-4a59-886b-88da4aba1c7a", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-llsn": "2", + "x-ms-cosmos-quorum-acked-llsn": "1", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "1", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:35.421 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "1", + "x-ms-request-charge": "4.95", + "x-ms-request-duration-ms": "4.854", + "x-ms-resource-quota": "functions=50;", + "x-ms-resource-usage": "functions=1;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#2", + "x-ms-transport-request-id": "3", + "x-ms-xp-role": "1" + }, + "body": "eyJib2R5IjoiYm9keSIsImlkIjoidGVzdCIsIl9yaWQiOiJoYkZqQUxlQ0crRUJBQUFBQUFBQVlBPT0iLCJfc2VsZiI6ImRic1wvaGJGakFBPT1cL2NvbGxzXC9oYkZqQUxlQ0crRT1cL3VkZnNcL2hiRmpBTGVDRytFQkFBQUFBQUFBWUE9PVwvIiwiX2V0YWciOiJcImMxMDBkMmUxLTAwMDAtMDcwMC0wMDAwLTYyZjIyOGQxMDAwMFwiIiwiX3RzIjoxNjYwMDM3MzI5fQ==" +} diff --git a/test/transactions/user_defined_function_operations/3_request.json b/test/transactions/user_defined_function_operations/3_request.json new file mode 100644 index 00000000000..022b6ce2334 --- /dev/null +++ b/test/transactions/user_defined_function_operations/3_request.json @@ -0,0 +1,14 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/udfs", + "method": "GET", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-consistency-level": "Session", + "x-ms-date": "Tue, 09 Aug 2022 09:29:26 GMT", + "x-ms-max-item-count": "3", + "x-ms-session-token": "0:-1#2", + "x-ms-version": "2018-12-31" + }, + "body": "" +} diff --git a/test/transactions/user_defined_function_operations/3_response.json b/test/transactions/user_defined_function_operations/3_response.json new file mode 100644 index 00000000000..781894299fd --- /dev/null +++ b/test/transactions/user_defined_function_operations/3_response.json @@ -0,0 +1,34 @@ +{ + "status": 200, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "268", + "content-location": "https://azuresdktesting.documents.azure.com/dbs/test-cosmos-db-udf/colls/test-udf/udfs", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:48 GMT", + "lsn": "2", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "104c320c-de80-40f2-a7f7-2839c12ad4c6", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-llsn": "2", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "2", + "x-ms-item-count": "1", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:53.246 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-request-charge": "1", + "x-ms-request-duration-ms": "0.578", + "x-ms-resource-quota": "functions=50;", + "x-ms-resource-usage": "functions=1;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#2", + "x-ms-transport-request-id": "8517", + "x-ms-xp-role": "2" + }, + "body": "eyJfcmlkIjoiaGJGakFMZUNHK0U9IiwiVXNlckRlZmluZWRGdW5jdGlvbnMiOlt7ImJvZHkiOiJib2R5IiwiaWQiOiJ0ZXN0IiwiX3JpZCI6ImhiRmpBTGVDRytFQkFBQUFBQUFBWUE9PSIsIl9zZWxmIjoiZGJzXC9oYkZqQUE9PVwvY29sbHNcL2hiRmpBTGVDRytFPVwvdWRmc1wvaGJGakFMZUNHK0VCQUFBQUFBQUFZQT09XC8iLCJfZXRhZyI6IlwiYzEwMGQyZTEtMDAwMC0wNzAwLTAwMDAtNjJmMjI4ZDEwMDAwXCIiLCJfdHMiOjE2NjAwMzczMjl9XSwiX2NvdW50IjoxfQ==" +} diff --git a/test/transactions/user_defined_function_operations/4_request.json b/test/transactions/user_defined_function_operations/4_request.json new file mode 100644 index 00000000000..aed6ca802d7 --- /dev/null +++ b/test/transactions/user_defined_function_operations/4_request.json @@ -0,0 +1,13 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/udfs/test", + "method": "PUT", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-consistency-level": "Session", + "x-ms-date": "Tue, 09 Aug 2022 09:29:26 GMT", + "x-ms-session-token": "0:-1#2", + "x-ms-version": "2018-12-31" + }, + "body": "eyJib2R5IjoiXG5mdW5jdGlvbiB0YXgoaW5jb21lKSB7XG4gICAgaWYgKGluY29tZSA9PSB1bmRlZmluZWQpXG4gICAgICAgIHRocm93ICdubyBpbnB1dCc7XG4gICAgaWYgKGluY29tZSA8IDEwMDApXG4gICAgICAgIHJldHVybiBpbmNvbWUgKiAwLjE7XG4gICAgZWxzZSBpZiAoaW5jb21lIDwgMTAwMDApXG4gICAgICAgIHJldHVybiBpbmNvbWUgKiAwLjI7XG4gICAgZWxzZVxuICAgICAgICByZXR1cm4gaW5jb21lICogMC40O1xufSIsImlkIjoidGVzdCJ9" +} diff --git a/test/transactions/user_defined_function_operations/4_response.json b/test/transactions/user_defined_function_operations/4_response.json new file mode 100644 index 00000000000..cbe05f06b77 --- /dev/null +++ b/test/transactions/user_defined_function_operations/4_response.json @@ -0,0 +1,38 @@ +{ + "status": 200, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "442", + "content-location": "https://azuresdktesting.documents.azure.com/dbs/test-cosmos-db-udf/colls/test-udf/udfs/test", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:49 GMT", + "etag": "\"c100eee1-0000-0700-0000-62f228d20000\"", + "lsn": "3", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "575d9890-9efe-4fb3-abce-d04980fe8f29", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-llsn": "3", + "x-ms-cosmos-quorum-acked-llsn": "2", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "2", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:35.421 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "2", + "x-ms-request-charge": "9.9", + "x-ms-request-duration-ms": "3.263", + "x-ms-resource-quota": "functions=50;", + "x-ms-resource-usage": "functions=1;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#3", + "x-ms-transport-request-id": "4", + "x-ms-xp-role": "1" + }, + "body": "eyJib2R5IjoiXG5mdW5jdGlvbiB0YXgoaW5jb21lKSB7XG4gICAgaWYgKGluY29tZSA9PSB1bmRlZmluZWQpXG4gICAgICAgIHRocm93ICdubyBpbnB1dCc7XG4gICAgaWYgKGluY29tZSA8IDEwMDApXG4gICAgICAgIHJldHVybiBpbmNvbWUgKiAwLjE7XG4gICAgZWxzZSBpZiAoaW5jb21lIDwgMTAwMDApXG4gICAgICAgIHJldHVybiBpbmNvbWUgKiAwLjI7XG4gICAgZWxzZVxuICAgICAgICByZXR1cm4gaW5jb21lICogMC40O1xufSIsImlkIjoidGVzdCIsIl9yaWQiOiJoYkZqQUxlQ0crRUJBQUFBQUFBQVlBPT0iLCJfc2VsZiI6ImRic1wvaGJGakFBPT1cL2NvbGxzXC9oYkZqQUxlQ0crRT1cL3VkZnNcL2hiRmpBTGVDRytFQkFBQUFBQUFBWUE9PVwvIiwiX2V0YWciOiJcImMxMDBlZWUxLTAwMDAtMDcwMC0wMDAwLTYyZjIyOGQyMDAwMFwiIiwiX3RzIjoxNjYwMDM3MzMwfQ==" +} diff --git a/test/transactions/user_defined_function_operations/5_request.json b/test/transactions/user_defined_function_operations/5_request.json new file mode 100644 index 00000000000..ee52fe54e13 --- /dev/null +++ b/test/transactions/user_defined_function_operations/5_request.json @@ -0,0 +1,17 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/docs", + "method": "POST", + "headers": { + "authorization": "<>", + "content-type": "application/query+json", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-consistency-level": "Session", + "x-ms-date": "Tue, 09 Aug 2022 09:29:27 GMT", + "x-ms-documentdb-isquery": "true", + "x-ms-documentdb-query-enablecrosspartition": "false", + "x-ms-max-item-count": "2", + "x-ms-session-token": "0:-1#3", + "x-ms-version": "2018-12-31" + }, + "body": "eyJxdWVyeSI6IlNFTEVDVCB1ZGYudGVzdCgxMDApIiwicGFyYW1ldGVycyI6W119" +} diff --git a/test/transactions/user_defined_function_operations/5_response.json b/test/transactions/user_defined_function_operations/5_response.json new file mode 100644 index 00000000000..a4b1eb4ef43 --- /dev/null +++ b/test/transactions/user_defined_function_operations/5_response.json @@ -0,0 +1,36 @@ +{ + "status": 200, + "headers": { + "content-length": "58", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:49 GMT", + "lsn": "3", + "server": "Compute", + "x-ms-activity-id": "cad3fdf2-ef35-4fae-946f-a4098808641a", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-is-partition-key-delete-pending": "false", + "x-ms-cosmos-llsn": "3", + "x-ms-cosmos-query-execution-info": "{\"reverseRidEnabled\":false,\"reverseIndexScan\":false}", + "x-ms-cosmos-quorum-acked-llsn": "3", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "2.0.0", + "x-ms-global-committed-lsn": "3", + "x-ms-item-count": "1", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:35.421 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "3", + "x-ms-request-charge": "2.7", + "x-ms-request-duration-ms": "5.336", + "x-ms-resource-quota": "documentSize=10240;documentsSize=10485760;documentsCount=-1;collectionSize=10485760;", + "x-ms-resource-usage": "documentSize=0;documentsSize=0;documentsCount=0;collectionSize=0;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#3", + "x-ms-transport-request-id": "1", + "x-ms-xp-role": "1" + }, + "body": "eyJfcmlkIjoiaGJGakFMZUNHK0U9IiwiRG9jdW1lbnRzIjpbeyIkMSI6MTB9XSwiX2NvdW50IjoxfQ==" +} diff --git a/test/transactions/user_defined_function_operations/6_request.json b/test/transactions/user_defined_function_operations/6_request.json new file mode 100644 index 00000000000..78a54a876fa --- /dev/null +++ b/test/transactions/user_defined_function_operations/6_request.json @@ -0,0 +1,17 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/docs", + "method": "POST", + "headers": { + "authorization": "<>", + "content-type": "application/query+json", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-consistency-level": "Session", + "x-ms-date": "Tue, 09 Aug 2022 09:29:27 GMT", + "x-ms-documentdb-isquery": "true", + "x-ms-documentdb-query-enablecrosspartition": "false", + "x-ms-max-item-count": "2", + "x-ms-session-token": "0:-1#3", + "x-ms-version": "2018-12-31" + }, + "body": "eyJxdWVyeSI6IlNFTEVDVCB1ZGYudGVzdCgxMDAwMCkiLCJwYXJhbWV0ZXJzIjpbXX0=" +} diff --git a/test/transactions/user_defined_function_operations/6_response.json b/test/transactions/user_defined_function_operations/6_response.json new file mode 100644 index 00000000000..c9734a7716f --- /dev/null +++ b/test/transactions/user_defined_function_operations/6_response.json @@ -0,0 +1,32 @@ +{ + "status": 200, + "headers": { + "content-length": "60", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:49 GMT", + "lsn": "3", + "server": "Compute", + "x-ms-activity-id": "697e4c5c-538a-43bc-8c52-4e1e6fbd40a6", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-is-partition-key-delete-pending": "false", + "x-ms-cosmos-llsn": "3", + "x-ms-cosmos-query-execution-info": "{\"reverseRidEnabled\":false,\"reverseIndexScan\":false}", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "2.0.0", + "x-ms-global-committed-lsn": "3", + "x-ms-item-count": "1", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:53.255 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-request-charge": "2.71", + "x-ms-request-duration-ms": "3.53", + "x-ms-resource-quota": "documentSize=10240;documentsSize=10485760;documentsCount=-1;collectionSize=10485760;", + "x-ms-resource-usage": "documentSize=0;documentsSize=0;documentsCount=0;collectionSize=0;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#3", + "x-ms-transport-request-id": "1", + "x-ms-xp-role": "1" + }, + "body": "eyJfcmlkIjoiaGJGakFMZUNHK0U9IiwiRG9jdW1lbnRzIjpbeyIkMSI6NDAwMH1dLCJfY291bnQiOjF9" +} diff --git a/test/transactions/user_defined_function_operations/7_request.json b/test/transactions/user_defined_function_operations/7_request.json new file mode 100644 index 00000000000..0bedebb642f --- /dev/null +++ b/test/transactions/user_defined_function_operations/7_request.json @@ -0,0 +1,13 @@ +{ + "uri": "/dbs/test-cosmos-db-udf/colls/test-udf/udfs/test", + "method": "DELETE", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-consistency-level": "Session", + "x-ms-date": "Tue, 09 Aug 2022 09:29:28 GMT", + "x-ms-session-token": "0:-1#3", + "x-ms-version": "2018-12-31" + }, + "body": "" +} diff --git a/test/transactions/user_defined_function_operations/7_response.json b/test/transactions/user_defined_function_operations/7_response.json new file mode 100644 index 00000000000..fde30c95965 --- /dev/null +++ b/test/transactions/user_defined_function_operations/7_response.json @@ -0,0 +1,37 @@ +{ + "status": 204, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "0", + "content-location": "https://azuresdktesting.documents.azure.com/dbs/test-cosmos-db-udf/colls/test-udf/udfs/test", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:51 GMT", + "lsn": "4", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "bdc0b523-bfbe-4ca2-90b0-019e79bcb8f0", + "x-ms-alt-content-path": "dbs/test-cosmos-db-udf/colls/test-udf", + "x-ms-content-path": "hbFjALeCG+E=", + "x-ms-cosmos-llsn": "4", + "x-ms-cosmos-quorum-acked-llsn": "3", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-documentdb-partitionkeyrangeid": "0", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "3", + "x-ms-last-state-change-utc": "Tue, 09 Aug 2022 09:25:35.421 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "3", + "x-ms-request-charge": "4.95", + "x-ms-request-duration-ms": "4.662", + "x-ms-resource-quota": "functions=50;", + "x-ms-resource-usage": "functions=0;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#4", + "x-ms-transport-request-id": "5", + "x-ms-xp-role": "1" + }, + "body": "" +} diff --git a/test/transactions/user_defined_function_operations/8_request.json b/test/transactions/user_defined_function_operations/8_request.json new file mode 100644 index 00000000000..d795f8b6fa0 --- /dev/null +++ b/test/transactions/user_defined_function_operations/8_request.json @@ -0,0 +1,11 @@ +{ + "uri": "/dbs/test-cosmos-db-udf", + "method": "DELETE", + "headers": { + "authorization": "<>", + "user-agent": "azsdk-rust-data_cosmos/0.4.0 (1.62.1; linux; x86_64)", + "x-ms-date": "Tue, 09 Aug 2022 09:29:28 GMT", + "x-ms-version": "2018-12-31" + }, + "body": "" +} diff --git a/test/transactions/user_defined_function_operations/8_response.json b/test/transactions/user_defined_function_operations/8_response.json new file mode 100644 index 00000000000..ccd9df915c3 --- /dev/null +++ b/test/transactions/user_defined_function_operations/8_response.json @@ -0,0 +1,34 @@ +{ + "status": 204, + "headers": { + "cache-control": "no-store, no-cache", + "content-length": "0", + "content-location": "https://azuresdktesting.documents.azure.com/dbs/test-cosmos-db-udf", + "content-type": "application/json", + "date": "Tue, 09 Aug 2022 09:28:51 GMT", + "lsn": "129", + "pragma": "no-cache", + "server": "Microsoft-HTTPAPI/2.0", + "strict-transport-security": "max-age=31536000", + "x-ms-activity-id": "98a7bf5f-7e94-4756-9b43-6e03a1e4ed56", + "x-ms-cosmos-llsn": "129", + "x-ms-cosmos-quorum-acked-llsn": "128", + "x-ms-current-replica-set-size": "4", + "x-ms-current-write-quorum": "3", + "x-ms-gatewayversion": "version=2.14.0", + "x-ms-global-committed-lsn": "128", + "x-ms-last-state-change-utc": "Wed, 03 Aug 2022 00:09:12.948 GMT", + "x-ms-number-of-read-regions": "0", + "x-ms-quorum-acked-lsn": "128", + "x-ms-request-charge": "4.95", + "x-ms-request-duration-ms": "32.407", + "x-ms-resource-quota": "databases=1000;", + "x-ms-resource-usage": "databases=0;", + "x-ms-schemaversion": "1.14", + "x-ms-serviceversion": "version=2.14.0.0", + "x-ms-session-token": "0:-1#129", + "x-ms-transport-request-id": "1334695", + "x-ms-xp-role": "1" + }, + "body": "" +}