Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Aug 26, 2024
1 parent 077719e commit b323d28
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public static class Operations
public const string CreateContainerIfNotExists = "create_container_if_not_exists";
public const string DeleteContainer = "delete_container";
public const string DeleteContainerStream = "delete_container_stream";
/* public const string QueryContainers = "query_containers";
public const string ReadAllContainers = "read_all_containers";*/
public const string ReadContainer = "read_container";
public const string ReadContainerStream = "read_container_stream";
public const string ReplaceContainer = "replace_container";
Expand All @@ -49,10 +47,8 @@ public static class Operations
public const string CreateDatabaseIfNotExists = "create_database_if_not_exists";
public const string DeleteDatabase = "delete_database";
public const string DeleteDatabaseStream = "delete_database_stream";
//public const string QueryDatabases = "query_databases";
public const string ReadDatabase = "read_database";
public const string ReadDatabaseStream = "read_database_stream";
//public const string ReadAllDatabases = "read_all_databases";

// Item Operations
public const string CreateItem = "create_item";
Expand All @@ -64,8 +60,6 @@ public static class Operations
public const string PatchItemStream = "patch_item_stream";
public const string QueryItems = "query_items";
public const string TypedQueryItems = "typed_query_items";
/* public const string ReadAllItems = "read_all_items";
public const string ReadAllItemsOfLogicalPartition = "read_all_items_of_logical_partition";*/
public const string ReadManyItems = "read_many_items";
public const string ReadManyItemsStream = "read_many_items_stream";
public const string ReadItem = "read_item";
Expand All @@ -78,8 +72,6 @@ public static class Operations
// Permission operations
public const string CreatePermission = "create_permission";
public const string DeletePermission = "delete_permission";
/* public const string QueryPermissions = "query_permissions";
public const string ReadAllPermissions = "read_all_permissions";*/
public const string ReadPermission = "read_permission";
public const string ReplacePermission = "replace_permission";
public const string UpsertPermission = "upsert_permission";
Expand All @@ -89,8 +81,6 @@ public static class Operations
public const string DeleteStoreProcedure = "delete_stored_procedure";
public const string ExecuteStoredProcedure = "execute_stored_procedure";
public const string ExecuteStoredProcedureStream = "execute_stored_procedure_stream";
/* public const string QueryStoredProcedures = "query_stored_procedures";
public const string ReadAllStoredProcedures = "read_all_stored_procedures";*/
public const string ReadStoredProcedure = "read_stored_procedure";
public const string ReplaceStoredProcedure = "replace_stored_procedure";

Expand All @@ -103,16 +93,12 @@ public static class Operations
// Trigger operations
public const string CreateTrigger = "create_trigger";
public const string DeleteTrigger = "delete_trigger";
/* public const string QueryTriggers = "query_triggers";
public const string ReadAllTriggers = "read_all_triggers";*/
public const string ReadTrigger = "read_trigger";
public const string ReplaceTrigger = "replace_trigger";

// User operations
public const string CreateUser = "create_user";
public const string DeleteUser = "delete_user";
/*public const string QueryUsers = "query_users";
public const string ReadAllUsers = "read_all_users";*/
public const string ReadUser = "read_user";
public const string ReplaceUser = "replace_user";
public const string UpsertUser = "upsert_user";
Expand All @@ -121,17 +107,13 @@ public static class Operations
public const string CreateUserDefinedFunction = "create_user_defined_function";
public const string DeleteUserDefinedFunctions = "delete_user_defined_function";
public const string ReplaceUserDefinedFunctions = "replace_user_defined_function";
// public const string QueryUserDefinedFunctions = "query_user_defined_functions";
public const string ReadAllUserDefinedFunctions = "read_all_user_defined_functions";
public const string ReadUserDefinedFunction = "read_user_defined_function";

// Encryption Key operations
public const string CreateClientEncryptionKey = "create_client_encryption_key";
/* public const string QueryEncryptionKeys = "query_encryption_keys";
public const string ReadAllEncryptionKeys = "read_all_encryption_keys";*/
public const string ReadClientEncryptionKey = "read_client_encryption_key";
public const string ReplaceClientEncryptionKey = "replace_client_encryption_key";

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes
using Microsoft.Azure.Cosmos.ChangeFeed.Utils;
using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed;
using Microsoft.Azure.Cosmos.Services.Management.Tests;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -188,7 +189,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync()
Assert.IsNotNull(context.Headers);
Assert.IsNotNull(context.Headers.Session);
Assert.IsTrue(context.Headers.RequestCharge > 0);
Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async"));
Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
Assert.AreEqual(expected: 3, actual: docs.Count);
ChangeFeedItem<dynamic> createChange = docs.ElementAt(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes
using Microsoft.Azure.Cosmos.ChangeFeed.Utils;
using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed;
using Microsoft.Azure.Cosmos.Services.Management.Tests;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -539,7 +540,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync(bool pr
Assert.IsNotNull(context.Headers);
Assert.IsNotNull(context.Headers.Session);
Assert.IsTrue(context.Headers.RequestCharge > 0);
Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async"));
Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
Assert.AreEqual(expected: 3, actual: docs.Count);
ChangeFeedItem<ToDoActivity> createChange = docs.ElementAt(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Scripts;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -319,7 +320,7 @@ private void ValidateContext(ChangeFeedProcessorContext changeFeedProcessorConte
Assert.IsNotNull(changeFeedProcessorContext.Headers.Session);
Assert.IsTrue(changeFeedProcessorContext.Headers.RequestCharge > 0);
string diagnosticsAsString = changeFeedProcessorContext.Diagnostics.ToString();
Assert.IsTrue(diagnosticsAsString.Contains("Change Feed Processor Read Next Async"));
Assert.IsTrue(diagnosticsAsString.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Scripts;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

Expand Down Expand Up @@ -377,7 +378,7 @@ private async Task ValidateContextAsync(ChangeFeedProcessorContext changeFeedPro
Assert.IsNotNull(changeFeedProcessorContext.Headers.Session);
Assert.IsTrue(changeFeedProcessorContext.Headers.RequestCharge > 0);
string diagnosticsAsString = changeFeedProcessorContext.Diagnostics.ToString();
Assert.IsTrue(diagnosticsAsString.Contains("Change Feed Processor Read Next Async"));
Assert.IsTrue(diagnosticsAsString.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));

await this.ValidateFeedRangeAsync(changeFeedProcessorContext.FeedRange);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Core.Trace;
using Microsoft.Azure.Cosmos.Resource.CosmosExceptions;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -217,7 +218,7 @@ public async Task CreateIfNotExists()
Assert.IsNotNull(createExistingResponse.Diagnostics);
string diagnostics = createExistingResponse.Diagnostics.ToString();
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
Assert.IsTrue(diagnostics.Contains("CreateDatabaseIfNotExistsAsync"));
Assert.IsTrue(diagnostics.Contains(OpenTelemetryConstants.Operations.CreateDatabaseIfNotExists));

bool conflictReturned = false;
requestHandlerHelper.CallBackOnResponse = (request, response) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Diagnostics;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.Azure.Documents;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand Down Expand Up @@ -57,7 +58,7 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
catch(NullReferenceException nre)
{
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
Assert.IsTrue(nre.Message.Contains("CreateItemAsync"));
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.CreateItem));
string cosmosToString = nre.ToString();
Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}");
Assert.IsTrue(cosmosToString.Contains(errorMessage));
Expand All @@ -73,11 +74,11 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
catch (NullReferenceException nre)
{
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
Assert.IsTrue(nre.Message.Contains("Typed FeedIterator ReadNextAsync"));
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.TypedQueryItems));
string cosmosToString = nre.ToString();
Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}");
Assert.IsTrue(cosmosToString.Contains(errorMessage));
Assert.IsTrue(cosmosToString.Contains("Typed FeedIterator ReadNextAsync"));
Assert.IsTrue(cosmosToString.Contains(OpenTelemetryConstants.Operations.TypedQueryItems));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Tests
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement;
using Microsoft.Azure.Cosmos.Telemetry;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.Azure.Cosmos.Tests;
using Microsoft.Azure.Cosmos.Tracing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -40,7 +41,7 @@ public async Task EtagPassesContinuation()
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Documents.OperationType>(),
Expand Down Expand Up @@ -120,7 +121,7 @@ public async Task NextReadHasUpdatedContinuation()
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Documents.OperationType>(),
Expand Down Expand Up @@ -190,7 +191,7 @@ public async Task ShouldSetFeedRangePartitionKeyRange()
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Documents.OperationType>(),
Expand Down Expand Up @@ -272,7 +273,7 @@ public async Task ShouldUseFeedRangeEpk()
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Documents.OperationType>(),
Expand Down

0 comments on commit b323d28

Please sign in to comment.