From d226a508024e60bd904e779184adcb4ed9c6edac Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 19 Oct 2023 00:27:55 +0530 Subject: [PATCH] Client Telemetry Release test fix --- .../ClientTelemetryReleaseTests.cs | 2 -- .../ClientTelemetryTestsBase.cs | 16 +++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryReleaseTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryReleaseTests.cs index 7a54f490c0..07230e63a8 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryReleaseTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryReleaseTests.cs @@ -4,11 +4,9 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests { - using System; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Azure.Cosmos.Fluent; - using Microsoft.Azure.Cosmos.Telemetry; using Microsoft.VisualStudio.TestTools.UnitTesting; /// diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs index 3bb8a53c0c..97dc6e709e 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs @@ -15,11 +15,9 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Azure.Cosmos.Tracing; using Microsoft.Azure.Cosmos.Telemetry; - using Microsoft.Azure.Cosmos.Handler; using Microsoft.Azure.Documents; using Newtonsoft.Json.Linq; using Newtonsoft.Json; - using Documents.Rntbd; using System.Globalization; using System.Linq; using Cosmos.Util; @@ -27,7 +25,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests public abstract class ClientTelemetryTestsBase : BaseCosmosClientHelper { - protected static readonly Uri telemetryServiceEndpoint = new Uri("http://dummy.telemetry.service/api/url"); + protected static readonly Uri telemetryServiceEndpoint = new Uri("https://tools.cosmos.azure.com/api/clienttelemetry/trace"); private static readonly List preferredRegionList = new List { @@ -71,7 +69,7 @@ public virtual void TestInitialize() { RequestCallBack = (request, cancellation) => { - if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { string jsonObject = request.Content.ReadAsStringAsync().GetAwaiter().GetResult(); @@ -84,7 +82,7 @@ public virtual void TestInitialize() }, ResponseIntercepter = (response) => { - if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } @@ -93,7 +91,7 @@ public virtual void TestInitialize() }, ExceptionIntercepter = (request, exception) => { - if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { this.isClientTelemetryAPICallFailed = true; } @@ -110,7 +108,7 @@ public virtual void TestInitialize() return Task.FromResult(result); } - if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { string jsonObject = request.Content.ReadAsStringAsync().GetAwaiter().GetResult(); @@ -124,7 +122,7 @@ public virtual void TestInitialize() }, ResponseIntercepter = (response) => { - if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } @@ -132,7 +130,7 @@ public virtual void TestInitialize() }, ExceptionIntercepter = (request, exception) => { - if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) + if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) { this.isClientTelemetryAPICallFailed = true; }