Skip to content
Merged
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
Code changes to fix pipeline build.
  • Loading branch information
kundadebdatta committed Mar 23, 2023
commit 4cc7b929dc8e8f2b87a53995dc342161b1e7da1c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos.Tracing;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Rntbd;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

Expand Down Expand Up @@ -109,8 +110,11 @@ public void TestGatewayAddressCacheAutoRefreshOnSuboptimalPartition()
public async Task TestGatewayAddressCacheUpdateOnConnectionResetAsync()
{
FakeMessageHandler messageHandler = new FakeMessageHandler();
HttpClient httpClient = new HttpClient(messageHandler);
httpClient.Timeout = TimeSpan.FromSeconds(120);
HttpClient httpClient = new HttpClient(messageHandler)
{
Timeout = TimeSpan.FromSeconds(120)
};

GatewayAddressCache cache = new GatewayAddressCache(
new Uri(GatewayAddressCacheTests.DatabaseAccountApiEndpoint),
Documents.Client.Protocol.Tcp,
Expand All @@ -131,7 +135,8 @@ public async Task TestGatewayAddressCacheUpdateOnConnectionResetAsync()
Assert.IsNotNull(addresses.AllAddresses.Select(address => address.PhysicalUri == "https://blabla.com"));

// Mark transport addresses to Unhealthy depcting a connection reset event.
await cache.MarkAddressesToUnhealthyAsync(new Documents.Rntbd.ServerKey(new Uri("https://blabla.com")));
ServerKey faultyServerKey = new (new Uri("https://blabla2.com"));
await cache.MarkAddressesToUnhealthyAsync(faultyServerKey);

// check if the addresss is updated
addresses = await cache.TryGetAddressesAsync(
Expand All @@ -141,12 +146,15 @@ public async Task TestGatewayAddressCacheUpdateOnConnectionResetAsync()
false,
CancellationToken.None);

// Validate that the above transport uri with host blabla.com has been marked Unhealthy.
IReadOnlyList<TransportAddressUri> transportAddressUris = addresses.Get(Protocol.Tcp)?.ReplicaTransportAddressUris;
foreach (TransportAddressUri transportAddressUri in transportAddressUris)
{
Assert.IsTrue(transportAddressUri.GetCurrentHealthState().GetHealthStatus().Equals(TransportAddressHealthState.HealthStatus.Unhealthy));
}
// Validate that the above transport uri with host blabla2.com has been marked Unhealthy.
IReadOnlyList<TransportAddressUri> transportAddressUris = addresses
.Get(Protocol.Tcp)?
.ReplicaTransportAddressUris;

TransportAddressUri transportAddressUri = transportAddressUris
.Single(x => x.ReplicaServerKey.Equals(faultyServerKey));

Assert.IsTrue(condition: transportAddressUri.GetCurrentHealthState().GetHealthStatus().Equals(TransportAddressHealthState.HealthStatus.Unhealthy));
}

[TestMethod]
Expand Down