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 080f87b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
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 080f87b

Please sign in to comment.