Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
sourabh1007 committed Sep 17, 2024
commit ca7e903ac1ef8297c5b21ff529f4b01d0e8b51a0
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement;
using Microsoft.Azure.Cosmos.CosmosElements;
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
using Microsoft.Azure.Cosmos.Tracing;
using Microsoft.Azure.Documents;

Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/CosmosClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ public virtual Task<DatabaseResponse> CreateDatabaseAsync(
}

return this.ClientContext.OperationHelperAsync(
operationName: nameof(CreateDatabaseAsync),
operationName: nameof(CreateDatabaseAsync),
containerName: null,
databaseName: id,
operationType: OperationType.Create,
Expand Down
1 change: 0 additions & 1 deletion Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ private bool IsBulkOperationSupported(
OperationType operationType)
{
this.ThrowIfDisposed();

if (!this.ClientOptions.AllowBulkExecution)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override Task<ResponseMessage> DeleteContainerStreamAsync(
CancellationToken cancellationToken = default)
{
return this.ClientContext.OperationHelperAsync(
operationName: nameof(DeleteContainerAsync),
operationName: nameof(DeleteContainerStreamAsync),
containerName: this.Id,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Delete,
Expand Down Expand Up @@ -298,7 +298,7 @@ public override Task<ItemResponse<T>> UpsertItemAsync<T>(
CancellationToken cancellationToken = default)
{
return this.ClientContext.OperationHelperAsync(
operationName: nameof(UpsertItemStreamAsync),
operationName: nameof(UpsertItemAsync),
containerName: this.Id,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Upsert,
Expand All @@ -316,7 +316,7 @@ public override Task<ResponseMessage> ReplaceItemStreamAsync(
CancellationToken cancellationToken = default)
{
return this.ClientContext.OperationHelperAsync(
operationName: nameof(ReplaceItemAsync),
operationName: nameof(ReplaceItemStreamAsync),
containerName: this.Id,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Replace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override Task<PermissionResponse> UpsertPermissionAsync(
CancellationToken cancellationToken = default)
{
return this.ClientContext.OperationHelperAsync(
operationName: OpenTelemetryConstants.Operations.UpsertPermission,
operationName: nameof(UpsertPermissionAsync),
containerName: null,
databaseName: this.Database.Id,
operationType: Documents.OperationType.Upsert,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@
}
]
}]]></Json><OTelActivities>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.ReadManyItemsStreamAsync" displayName="ReadManyItemsStreamAsync containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.read_many_items" displayName="read_many_items containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">ReadManyItemsStreamAsync</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">read_many_items</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand Down Expand Up @@ -1136,10 +1136,10 @@
}
]
}]]></Json><OTelActivities>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.ReadManyItemsAsync" displayName="ReadManyItemsAsync containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.read_many_items" displayName="read_many_items containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">ReadManyItemsAsync</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">read_many_items</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
</Input>
<Output>
<Text><![CDATA[.
└── ReplaceItemAsync(00000000-0000-0000-0000-000000000000) Transport-Component 00:00:00:000 0.00 milliseconds
└── ReplaceItemStreamAsync(00000000-0000-0000-0000-000000000000) Transport-Component 00:00:00:000 0.00 milliseconds
│ (
│ [Client Configuration]
│ Redacted To Not Change The Baselines From Run To Run
Expand All @@ -283,7 +283,7 @@
]]></Text>
<Json><![CDATA[{
"Summary": {},
"name": "ReplaceItemAsync",
"name": "ReplaceItemStreamAsync",
"start datetime": "0001-01-01T00:00:00Z",
"duration in milliseconds": 0,
"data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes
using System.Diagnostics;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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 @@ -218,7 +217,7 @@ public async Task CreateIfNotExists()
Assert.IsNotNull(createExistingResponse.Diagnostics);
string diagnostics = createExistingResponse.Diagnostics.ToString();
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
Assert.IsTrue(diagnostics.Contains(OpenTelemetryConstants.Operations.CreateDatabaseIfNotExists));
Assert.IsTrue(diagnostics.Contains("CreateDatabaseIfNotExistsAsync"));

bool conflictReturned = false;
requestHandlerHelper.CallBackOnResponse = (request, response) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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 @@ -58,7 +57,7 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
catch(NullReferenceException nre)
{
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.CreateItem));
Assert.IsTrue(nre.Message.Contains("CreateItemAsync"));
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 @@ -74,11 +73,11 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
catch (NullReferenceException nre)
{
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.QueryItems));
Assert.IsTrue(nre.Message.Contains("Typed FeedIterator ReadNextAsync"));
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(OpenTelemetryConstants.Operations.QueryItems));
Assert.IsTrue(cosmosToString.Contains("Typed FeedIterator ReadNextAsync"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Microsoft.Azure.Cosmos.EmulatorTests.Tracing
using Microsoft.Azure.Cosmos.Diagnostics;
using Microsoft.Azure.Cosmos.SDK.EmulatorTests;
using Microsoft.Azure.Cosmos.Services.Management.Tests.BaselineTest;
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 @@ -1531,7 +1530,7 @@ public override Output ExecuteTest(Input input)
oTelActivitiesString.Append("</OTelActivities>");
}

AssertTraceProperties(input.Trace);
AssertTraceProperites(input.Trace);
Assert.IsTrue(text.Contains("Client Side Request Stats"), $"All diagnostics should have request stats: {text}");
Assert.IsTrue(json.Contains("Client Side Request Stats"), $"All diagnostics should have request stats: {json}");
Assert.IsTrue(text.Contains("Client Configuration"), $"All diagnostics should have Client Configuration: {text}");
Expand Down Expand Up @@ -1620,13 +1619,23 @@ private static JObject FindChild(
}


private static void AssertTraceProperties(ITrace trace)
private static void AssertTraceProperites(ITrace trace)
{
if (trace.Name == OpenTelemetryConstants.Operations.ReadManyItems || // skip test for read many as the queries are done in parallel
trace.Name == OpenTelemetryConstants.Operations.QueryChangeFeedEstimator || // Change Feed Estimator issues parallel requests
trace.Children.Count == 0) // Base case
if (trace.Name == "ReadManyItemsStreamAsync" ||
trace.Name == "ReadManyItemsAsync")
{
return;
return; // skip test for read many as the queries are done in parallel
}

if (trace.Name == "Change Feed Estimator Read Next Async")
{
return; // Change Feed Estimator issues parallel requests
}

if (trace.Children.Count == 0)
{
// Base case
return;
}

// Trace stopwatch should be greater than the sum of all children's stop watches
Expand All @@ -1635,7 +1644,7 @@ private static void AssertTraceProperties(ITrace trace)
foreach (ITrace child in trace.Children)
{
sumOfChildrenTimeSpan += child.Duration;
AssertTraceProperties(child);
AssertTraceProperites(child);
}

if (rootTimeSpan < sumOfChildrenTimeSpan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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