Skip to content

Commit

Permalink
Merge pull request #595 from SkillsFundingAgency/CV-461-healthcheck
Browse files Browse the repository at this point in the history
Cv-462 Uses ping endpoint when checking FAT API
  • Loading branch information
subhamano authored Dec 2, 2019
2 parents bc439f4 + a5594cb commit 7c2c387
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Testing" Version="3.0.22" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Moq;
using NUnit.Framework;
using SFA.DAS.Apprenticeships.Api.Types.Providers;
using SFA.DAS.CommitmentsV2.Api.HealthChecks;
using SFA.DAS.Providers.Api.Client;

Expand All @@ -26,15 +24,15 @@ public void SetUp()
[Test]
public async Task CheckHealthAsync_WhenFindAllAsyncSucceeds_ThenShouldReturnHealthyStatus()
{
var healthCheckResult = await _fixture.SetFindAllAsyncSuccess().CheckHealthAsync();
var healthCheckResult = await _fixture.CheckHealthAsync();

Assert.AreEqual(HealthStatus.Healthy, healthCheckResult.Status);
}

[Test]
public async Task CheckHealthAsync_WhenFindAllAsyncFails_ThenShouldReturnDegradedStatus()
{
var healthCheckResult = await _fixture.SetFindAllAsyncFailure().CheckHealthAsync();
var healthCheckResult = await _fixture.PingFailure().CheckHealthAsync();

Assert.AreEqual(HealthStatus.Degraded, healthCheckResult.Status);
Assert.AreEqual(_fixture.Exception.Message, healthCheckResult.Description);
Expand Down Expand Up @@ -65,16 +63,9 @@ public Task<HealthCheckResult> CheckHealthAsync()
return HealthCheck.CheckHealthAsync(HealthCheckContext, CancellationToken);
}

public ApprenticeshipInfoServiceHealthCheckTestsFixture SetFindAllAsyncSuccess()
public ApprenticeshipInfoServiceHealthCheckTestsFixture PingFailure()
{
ProviderApiClient.Setup(c => c.FindAllAsync()).ReturnsAsync(new List<ProviderSummary>());

return this;
}

public ApprenticeshipInfoServiceHealthCheckTestsFixture SetFindAllAsyncFailure()
{
ProviderApiClient.Setup(c => c.FindAllAsync()).ThrowsAsync(Exception);
ProviderApiClient.Setup(c => c.Ping()).ThrowsAsync(Exception);

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Providers.Api.Client" Version="0.11.98" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Providers.Api.Client" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Testing" Version="3.0.22" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
{
try
{
await _providerApiClient.FindAllAsync();
await _providerApiClient.Ping();

return HealthCheckResult.Healthy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="morelinq" Version="3.1.0" />
<PackageReference Include="SFA.DAS.Account.Api.Client" Version="1.6.2276" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.199" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Client" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Apprenticeships.Api.Types" Version="0.11.233" />
<PackageReference Include="SFA.DAS.Authorization.Features" Version="4.3.1" />
<PackageReference Include="SFA.DAS.Encoding" Version="1.1.57" />
<PackageReference Include="SFA.DAS.Learners" Version="1.1.181" />
<PackageReference Include="SFA.DAS.NServiceBus" Version="15.0.8" />
<PackageReference Include="SFA.DAS.NServiceBus.SqlServer" Version="15.0.8" />
<PackageReference Include="SFA.DAS.Providers.Api.Client" Version="0.11.98" />
<PackageReference Include="SFA.DAS.Providers.Api.Client" Version="0.11.233" />
<PackageReference Include="SFA.DAS.UnitOfWork" Version="9.0.8" />
<PackageReference Include="SFA.DAS.PAS.Account.Api.ClientV2" Version="1.1.851" />
<PackageReference Include="SFA.DAS.Configuration.AzureTableStorage" Version="3.0.77" />
Expand Down

0 comments on commit 7c2c387

Please sign in to comment.