Example #1
0
        public async Task Health_Get_ReturnsValidList()
        {
            // Arrange
            var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger);

            // Act
            var response = await resourceDiscoveryClient.GetHealthAsync();

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Example #2
0
        public async Task Health_Get_ReturnsOk()
        {
            // Arrange
            var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger);

            // Act
            var response = await resourceDiscoveryClient.GetHealthAsync();

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.True(response.Headers.Contains(HttpHeaders.AgentVersion));
            Assert.Equal(ExpectedVersion, response.Headers.GetFirstOrDefaultHeaderValue(HttpHeaders.AgentVersion));
        }
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            try
            {
                var resourceDiscoveryHealthReport = await _resourceDiscoveryClient.GetHealthAsync();

                if (resourceDiscoveryHealthReport.Status == HealthStatus.Healthy)
                {
                    return(HealthCheckResult.Healthy("Successfully contacted Promitor Resource Discovery"));
                }

                return(HealthCheckResult.Degraded("Successfully contacted Promitor Resource Discovery but it's not in healthy state."));
            }
            catch (Exception exception)
            {
                return(HealthCheckResult.Unhealthy("Unable to contacted Promitor Resource Discovery.", exception: exception));
            }
        }