From 32d39d1269e7a1a68b34a4a377aa6e5c598dcb45 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 19 Oct 2023 00:27:55 +0530 Subject: [PATCH 1/4] 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; } From 97f283c4f86456f060ea747a3a9c8ae24f554345 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 19 Oct 2023 01:25:25 +0530 Subject: [PATCH 2/4] get endpoint from env variable --- .../ClientTelemetryTestsBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 97dc6e709e..39279a9b51 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs @@ -25,7 +25,7 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests public abstract class ClientTelemetryTestsBase : BaseCosmosClientHelper { - protected static readonly Uri telemetryServiceEndpoint = new Uri("https://tools.cosmos.azure.com/api/clienttelemetry/trace"); + protected static readonly Uri telemetryServiceEndpoint = new Uri(ConfigurationManager.GetEnvironmentVariable("CLIENT_TELEMETRY_SERVICE_ENDPOINT", "https://dummy.url/api/clienttelemetry")); private static readonly List preferredRegionList = new List { From cdbad51990a630bb5ccb00c1a6ba205013b3f270 Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 19 Oct 2023 01:36:18 +0530 Subject: [PATCH 3/4] read client telemetry endpoint service from env --- .../ClientTelemetryTestsBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 39279a9b51..85e3496731 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTestsBase.cs @@ -69,7 +69,7 @@ public virtual void TestInitialize() { RequestCallBack = (request, cancellation) => { - if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { string jsonObject = request.Content.ReadAsStringAsync().GetAwaiter().GetResult(); @@ -82,7 +82,7 @@ public virtual void TestInitialize() }, ResponseIntercepter = (response) => { - if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } @@ -91,7 +91,7 @@ public virtual void TestInitialize() }, ExceptionIntercepter = (request, exception) => { - if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { this.isClientTelemetryAPICallFailed = true; } @@ -108,7 +108,7 @@ public virtual void TestInitialize() return Task.FromResult(result); } - if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { string jsonObject = request.Content.ReadAsStringAsync().GetAwaiter().GetResult(); @@ -122,7 +122,7 @@ public virtual void TestInitialize() }, ResponseIntercepter = (response) => { - if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (response.RequestMessage != null && response.RequestMessage.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } @@ -130,7 +130,7 @@ public virtual void TestInitialize() }, ExceptionIntercepter = (request, exception) => { - if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery)) + if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri)) { this.isClientTelemetryAPICallFailed = true; } From 2e091c9d8c31dbf68174218f846e17a00f1ca13a Mon Sep 17 00:00:00 2001 From: Sourabh Jain Date: Thu, 19 Oct 2023 01:48:42 +0530 Subject: [PATCH 4/4] updated yaml --- azure-pipelines-official.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines-official.yml b/azure-pipelines-official.yml index db77d4b0fd..2410dfb61f 100644 --- a/azure-pipelines-official.yml +++ b/azure-pipelines-official.yml @@ -54,6 +54,7 @@ stages: testRunTitle: Microsoft.Azure.Cosmos.EmulatorTests env: COSMOSDB_ACCOUNT_CONNECTION_STRING: $(COSMOSDB_ACCOUNT_CONNECTION_STRING) # Real Account Connection String used by Integration Tests while running as part of release pipeline + CLIENT_TELEMETRY_SERVICE_ENDPOINT: $(CLIENT_TELEMETRY_SERVICE_ENDPOINT) # Client telemetry service url returned by configured account client config API - stage: displayName: Publish