Skip to content

Commit

Permalink
Merge branch 'master' into chore/#323_AddNetStandard2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-krystianc authored Aug 1, 2024
2 parents 3818404 + 1c27d01 commit 5aca3c4
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions Consul.Test/HealthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Consul.Filtering;
using NuGet.Versioning;
using Xunit;

Expand Down Expand Up @@ -128,29 +130,28 @@ public async Task Health_Connect()
ID = destinationServiceID,
Name = destinationServiceID,
Port = 8000,
Check = new AgentServiceCheck
{
TTL = TimeSpan.FromSeconds(15)
},
Connect = new AgentServiceConnect
{
SidecarService = new AgentServiceRegistration
{
Port = 8001
}
}
Check = new AgentServiceCheck { TTL = TimeSpan.FromSeconds(15) },
Connect = new AgentServiceConnect { SidecarService = new AgentServiceRegistration { Port = 8001 } }
};

try
{
await _client.Agent.ServiceRegister(registration);
QueryResult<ServiceEntry[]> checks;
ulong lastIndex = 0;
do
{
var q = new QueryOptions { WaitIndex = lastIndex, };
// Use the Health.Connect method to query health information for Connect-enabled services
checks = await _client.Health.Connect(destinationServiceID, "", false, q, null,
new CancellationTokenSource(TimeSpan.FromMinutes(1)).Token);
Assert.Equal(HttpStatusCode.OK, checks.StatusCode);
Assert.True(checks.LastIndex > q.WaitIndex);
lastIndex = checks.LastIndex;
} while (!checks.Response.Any());

// Use the Health.Connect method to query health information for Connect-enabled services
var checks = await _client.Health.Connect(destinationServiceID, "", false, QueryOptions.Default, null); // Passing null for the filter parameter

Assert.NotNull(checks);
Assert.NotEqual((ulong)0, checks.LastIndex);
Assert.NotEmpty(checks.Response);
Assert.Single(checks.Response);
Assert.Equal(registration.Connect.SidecarService.Port, checks.Response[0].Service.Port);
}
finally
{
Expand Down

0 comments on commit 5aca3c4

Please sign in to comment.