Skip to content

Commit 080f87b

Browse files
committed
fix tests
1 parent 077719e commit 080f87b

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes
1414
using Microsoft.Azure.Cosmos.ChangeFeed.Utils;
1515
using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed;
1616
using Microsoft.Azure.Cosmos.Services.Management.Tests;
17+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1718
using Microsoft.VisualStudio.TestTools.UnitTesting;
1819
using Newtonsoft.Json;
1920
using Newtonsoft.Json.Linq;
@@ -188,7 +189,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync()
188189
Assert.IsNotNull(context.Headers);
189190
Assert.IsNotNull(context.Headers.Session);
190191
Assert.IsTrue(context.Headers.RequestCharge > 0);
191-
Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async"));
192+
Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
192193
Assert.AreEqual(expected: 3, actual: docs.Count);
193194

194195
ChangeFeedItem<dynamic> createChange = docs.ElementAt(0);

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CFP/AllVersionsAndDeletes/BuilderWithCustomSerializerTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.CFP.AllVersionsAndDeletes
1616
using Microsoft.Azure.Cosmos.ChangeFeed.Utils;
1717
using Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed;
1818
using Microsoft.Azure.Cosmos.Services.Management.Tests;
19+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1920
using Microsoft.VisualStudio.TestTools.UnitTesting;
2021
using Newtonsoft.Json;
2122
using Newtonsoft.Json.Linq;
@@ -539,7 +540,7 @@ public async Task WhenADocumentIsCreatedThenUpdatedThenDeletedTestsAsync(bool pr
539540
Assert.IsNotNull(context.Headers);
540541
Assert.IsNotNull(context.Headers.Session);
541542
Assert.IsTrue(context.Headers.RequestCharge > 0);
542-
Assert.IsTrue(context.Diagnostics.ToString().Contains("Change Feed Processor Read Next Async"));
543+
Assert.IsTrue(context.Diagnostics.ToString().Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
543544
Assert.AreEqual(expected: 3, actual: docs.Count);
544545

545546
ChangeFeedItem<ToDoActivity> createChange = docs.ElementAt(0);

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicStreamTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed
1111
using System.Threading;
1212
using System.Threading.Tasks;
1313
using Microsoft.Azure.Cosmos.Scripts;
14+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1415
using Microsoft.VisualStudio.TestTools.UnitTesting;
1516
using Newtonsoft.Json;
1617
using Newtonsoft.Json.Linq;
@@ -319,7 +320,7 @@ private void ValidateContext(ChangeFeedProcessorContext changeFeedProcessorConte
319320
Assert.IsNotNull(changeFeedProcessorContext.Headers.Session);
320321
Assert.IsTrue(changeFeedProcessorContext.Headers.RequestCharge > 0);
321322
string diagnosticsAsString = changeFeedProcessorContext.Diagnostics.ToString();
322-
Assert.IsTrue(diagnosticsAsString.Contains("Change Feed Processor Read Next Async"));
323+
Assert.IsTrue(diagnosticsAsString.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange));
323324
}
324325
}
325326
}

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ChangeFeed/DynamicTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.ChangeFeed
1010
using System.Threading;
1111
using System.Threading.Tasks;
1212
using Microsoft.Azure.Cosmos.Scripts;
13+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1314
using Microsoft.VisualStudio.TestTools.UnitTesting;
1415
using Newtonsoft.Json;
1516

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

382383
await this.ValidateFeedRangeAsync(changeFeedProcessorContext.FeedRange);
383384
}

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosDatabaseTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
1313
using System.Threading.Tasks;
1414
using Microsoft.Azure.Cosmos.Core.Trace;
1515
using Microsoft.Azure.Cosmos.Resource.CosmosExceptions;
16+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1617
using Microsoft.VisualStudio.TestTools.UnitTesting;
1718
using Newtonsoft.Json;
1819
using Newtonsoft.Json.Linq;
@@ -217,7 +218,7 @@ public async Task CreateIfNotExists()
217218
Assert.IsNotNull(createExistingResponse.Diagnostics);
218219
string diagnostics = createExistingResponse.Diagnostics.ToString();
219220
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
220-
Assert.IsTrue(diagnostics.Contains("CreateDatabaseIfNotExistsAsync"));
221+
Assert.IsTrue(diagnostics.Contains(OpenTelemetryConstants.Operations.CreateDatabaseIfNotExists));
221222

222223
bool conflictReturned = false;
223224
requestHandlerHelper.CallBackOnResponse = (request, response) =>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosNullReferenceExceptionTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Microsoft.Azure.Cosmos.Diagnostics;
11+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1112
using Microsoft.Azure.Documents;
1213
using Microsoft.VisualStudio.TestTools.UnitTesting;
1314

@@ -57,7 +58,7 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
5758
catch(NullReferenceException nre)
5859
{
5960
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
60-
Assert.IsTrue(nre.Message.Contains("CreateItemAsync"));
61+
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.CreateItem));
6162
string cosmosToString = nre.ToString();
6263
Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}");
6364
Assert.IsTrue(cosmosToString.Contains(errorMessage));
@@ -73,11 +74,11 @@ public async Task CosmosEndToEndNullReferenceExceptionTestAsync()
7374
catch (NullReferenceException nre)
7475
{
7576
Assert.AreEqual(typeof(CosmosNullReferenceException), nre.GetType());
76-
Assert.IsTrue(nre.Message.Contains("Typed FeedIterator ReadNextAsync"));
77+
Assert.IsTrue(nre.Message.Contains(OpenTelemetryConstants.Operations.TypedQueryItems));
7778
string cosmosToString = nre.ToString();
7879
Assert.IsFalse(cosmosToString.Contains("Microsoft.Azure.Cosmos.CosmosNullReferenceException"), $"The internal wrapper exception should not be exposed to users. {cosmosToString}");
7980
Assert.IsTrue(cosmosToString.Contains(errorMessage));
80-
Assert.IsTrue(cosmosToString.Contains("Typed FeedIterator ReadNextAsync"));
81+
Assert.IsTrue(cosmosToString.Contains(OpenTelemetryConstants.Operations.TypedQueryItems));
8182
}
8283
}
8384
}

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/ChangeFeedPartitionKeyResultSetIteratorCoreTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Tests
1010
using System.Threading.Tasks;
1111
using Microsoft.Azure.Cosmos.ChangeFeed.LeaseManagement;
1212
using Microsoft.Azure.Cosmos.Telemetry;
13+
using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry;
1314
using Microsoft.Azure.Cosmos.Tests;
1415
using Microsoft.Azure.Cosmos.Tracing;
1516
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -40,7 +41,7 @@ public async Task EtagPassesContinuation()
4041
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
4142
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
4243
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
43-
It.Is<string>(str => str.Contains("Change Feed Processor")),
44+
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
4445
It.IsAny<string>(),
4546
It.IsAny<string>(),
4647
It.IsAny<Documents.OperationType>(),
@@ -120,7 +121,7 @@ public async Task NextReadHasUpdatedContinuation()
120121
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
121122
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
122123
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
123-
It.Is<string>(str => str.Contains("Change Feed Processor")),
124+
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
124125
It.IsAny<string>(),
125126
It.IsAny<string>(),
126127
It.IsAny<Documents.OperationType>(),
@@ -190,7 +191,7 @@ public async Task ShouldSetFeedRangePartitionKeyRange()
190191
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
191192
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
192193
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
193-
It.Is<string>(str => str.Contains("Change Feed Processor")),
194+
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
194195
It.IsAny<string>(),
195196
It.IsAny<string>(),
196197
It.IsAny<Documents.OperationType>(),
@@ -272,7 +273,7 @@ public async Task ShouldUseFeedRangeEpk()
272273
Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
273274
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
274275
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
275-
It.Is<string>(str => str.Contains("Change Feed Processor")),
276+
It.Is<string>(str => str.Contains(OpenTelemetryConstants.Operations.QueryChangeFeedForPartitionKeyRange)),
276277
It.IsAny<string>(),
277278
It.IsAny<string>(),
278279
It.IsAny<Documents.OperationType>(),

0 commit comments

Comments
 (0)