Skip to content

Commit

Permalink
Client Telemetry Release test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Oct 18, 2023
1 parent 5777a3a commit d226a50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ 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;
using Microsoft.Azure.Cosmos.Telemetry.Models;

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<string> preferredRegionList = new List<string>
{
Expand Down Expand Up @@ -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();

Expand All @@ -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);
}
Expand All @@ -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;
}
Expand All @@ -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();

Expand All @@ -124,15 +122,15 @@ 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);
}
return Task.FromResult(response);
},
ExceptionIntercepter = (request, exception) =>
{
if (request.RequestUri.AbsoluteUri.Equals(telemetryServiceEndpoint.AbsoluteUri))
if (request.RequestUri.AbsoluteUri.Contains(telemetryServiceEndpoint.PathAndQuery))
{
this.isClientTelemetryAPICallFailed = true;
}
Expand Down

0 comments on commit d226a50

Please sign in to comment.