Skip to content

Commit

Permalink
fix: MongoCollectionProvider.Check had a condition wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem committed Jan 24, 2025
1 parent ca23f07 commit 945730f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Adaptors/MongoDB/src/Common/MongoCollectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -68,10 +69,10 @@ public Task<HealthCheckResult> Check(HealthCheckTag tag)
HealthCheckTag.Startup or HealthCheckTag.Readiness => Task.FromResult(isInitialized_
? HealthCheckResult.Healthy()
: HealthCheckResult
.Unhealthy($"Mongo Collection<{nameof(TData)}> not initialized yet.")),
HealthCheckTag.Liveness => Task.FromResult(isInitialized_ && mongoCollection_ is null
.Unhealthy($"Mongo Collection<{typeof(TData)}> not initialized yet.")),
HealthCheckTag.Liveness => Task.FromResult(isInitialized_ && mongoCollection_ is not null
? HealthCheckResult.Healthy()
: HealthCheckResult.Unhealthy($"Mongo Collection<{nameof(TData)}> not initialized yet.")),
: HealthCheckResult.Unhealthy($"Mongo Collection<{typeof(TData)}> not initialized yet.")),
_ => throw new ArgumentOutOfRangeException(nameof(tag),
tag,
null),
Expand Down
5 changes: 2 additions & 3 deletions Common/tests/Pollster/PollsterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,8 @@ await testServiceProvider.Pollster.Init(CancellationToken.None)

Console.WriteLine(res.Description);

Assert.AreEqual(new StringBuilder().AppendLine(desc)
.ToString(),
healthResult.Description);
Assert.AreEqual(desc,
healthResult.Description?.Trim());
Assert.AreEqual(new AggregateException(ex).Message,
healthResult.Exception?.Message);
Assert.AreEqual(HealthStatus.Unhealthy,
Expand Down
3 changes: 2 additions & 1 deletion Utils/src/HealthCheckResultCombiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public static async Task<HealthCheckResult> Combine(HealthCheckTag
{
var exceptions = new List<Exception>();
var data = new Dictionary<string, object>();
var description = new StringBuilder(desc);
var description = new StringBuilder();
var worstStatus = HealthStatus.Healthy;
description.AppendLine(desc);

foreach (var healthCheckResult in await providers.Select(p => p.Check(tag))
.WhenAll()
Expand Down

0 comments on commit 945730f

Please sign in to comment.