Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Darling/Darling.Tests/AvailabilityGroupCountReadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ await DarlingMcpTestData.ExecAsync(connection, ct,
}

var unfilteredCount = await DarlingAgReader.GetAvailabilityGroupCountAsync(postgres, null, ct);
var unfilteredTopology = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var unfilteredTopology = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);
Assert.Equal(2, unfilteredCount);
Assert.Equal(unfilteredTopology.AvailabilityGroupCount, unfilteredCount);

// $1 binds the same way on both reads (the server-filtered path /api/read/get_ag_health takes).
var filteredCount = await DarlingAgReader.GetAvailabilityGroupCountAsync(postgres, ServerId, ct);
var filteredTopology = await DarlingAgReader.GetAgHealthAsync(postgres, ServerId, DateTime.UtcNow, ct);
var filteredTopology = await DarlingAgReader.GetAgHealthAsync(postgres, ServerId, DateTime.UtcNow, cancellationToken: ct);
Assert.Equal(2, filteredCount);
Assert.Equal(filteredTopology.AvailabilityGroupCount, filteredCount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ the output-side is_enabled join excludes it exactly as today. */
Assert.Equal(2, removedCard.Databases.Count);
}

var fleetHealth = await DarlingAgReader.GetAgHealthAsync(postgres, null, now, ct);
var fleetHealth = await DarlingAgReader.GetAgHealthAsync(postgres, null, now, cancellationToken: ct);
var fleetGroups = fleetHealth.AvailabilityGroups.Where(g => sentinelIds.Contains(g.ServerId)).ToList();
Assert.Equal(9, fleetGroups.Count);
Assert.DoesNotContain(fleetGroups, g => g.ServerId == disabledId);

var fleetCount = await DarlingAgReader.GetAvailabilityGroupCountAsync(postgres, null, ct);
Assert.Equal(fleetHealth.AvailabilityGroupCount, fleetCount);

var scopedHealth = await DarlingAgReader.GetAgHealthAsync(postgres, staleId, now, ct);
var scopedHealth = await DarlingAgReader.GetAgHealthAsync(postgres, staleId, now, cancellationToken: ct);
Assert.Equal(StaleName, Assert.Single(scopedHealth.AvailabilityGroups).ServerName);

var fleetJson = await DarlingMcpAgTools.GetAgHealth(postgres, null);
Expand Down
12 changes: 6 additions & 6 deletions Darling/Darling.Tests/DarlingMcpAgToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ await DarlingMcpTestData.ExecAsync(connection, ct,
"ONLINE", "CONNECTED", "ONLINE", "HEALTHY", "SYNCHRONOUS_COMMIT", "AUTOMATIC", "TCP://AGNODE1:5022");

/* Straight through the reader, exactly as the /api/ag endpoint calls it — no server filter. */
var result = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var result = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);

var group = Assert.Single(result.AvailabilityGroups, g => g.ServerName == ServerName);
Assert.Equal("AG_FLEET", group.AgName);
Expand Down Expand Up @@ -340,7 +340,7 @@ public async Task AgHealth_ReturnsOnlyTheNewestSnapshot_AgainstDevPostgres()
/* Newest sweep: one replica, healthy. */
await InsertReplicaAsync(connection, ct, newest, "AG_SNAP", "NEW1", "PRIMARY", "HEALTHY");

var result = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var result = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);

var group = Assert.Single(result.AvailabilityGroups, g => g.ServerName == ServerName);
Assert.Equal(newest, group.CollectionTime);
Expand Down Expand Up @@ -386,10 +386,10 @@ the unfiltered one. */
await InsertReplicaAsync(connection, ct, when, "AG_MINE", "MINE1", "PRIMARY", "HEALTHY");
await InsertReplicaAsync(connection, ct, when, "AG_THEIRS", "THEIRS1", "PRIMARY", "HEALTHY", otherId, OtherName);

var filtered = await DarlingAgReader.GetAgHealthAsync(postgres, ServerId, DateTime.UtcNow, ct);
var filtered = await DarlingAgReader.GetAgHealthAsync(postgres, ServerId, DateTime.UtcNow, cancellationToken: ct);
Assert.Equal("AG_MINE", Assert.Single(filtered.AvailabilityGroups).AgName);

var unfiltered = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var unfiltered = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);
var names = unfiltered.AvailabilityGroups.Select(g => g.AgName).ToList();
Assert.Contains("AG_MINE", names);
Assert.Contains("AG_THEIRS", names);
Expand Down Expand Up @@ -428,13 +428,13 @@ go with it rather than linger until retention expires the collected rows. */
var when = DarlingMcpTestData.TruncateToSeconds(DateTime.UtcNow).AddMinutes(-5);
await InsertReplicaAsync(connection, ct, when, "AG_DISABLED", "NODE1", "PRIMARY", "HEALTHY");

var before = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var before = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);
Assert.Contains("AG_DISABLED", before.AvailabilityGroups.Select(g => g.AgName));

await DarlingMcpTestData.ExecAsync(connection, ct,
"UPDATE servers SET is_enabled = FALSE WHERE server_id = $1", ServerId);

var after = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, ct);
var after = await DarlingAgReader.GetAgHealthAsync(postgres, null, DateTime.UtcNow, cancellationToken: ct);
Assert.DoesNotContain("AG_DISABLED", after.AvailabilityGroups.Select(g => g.AgName));

bodySucceeded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ its own empty state and the nav gate can read the count off the same response. *
app.MapGet("/api/ag", async (HttpContext context) =>
{
var result = await DarlingAgReader.GetAgHealthAsync(
postgres, null, DateTime.UtcNow, context.RequestAborted);
postgres, null, DateTime.UtcNow, cancellationToken: context.RequestAborted);
return Results.Json(result, DarlingAgReader.JsonOptions);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static async Task<AgHealthResult> GetAgHealthAsync(
NpgsqlDataSource postgres,
int? serverIdFilter = null,
DateTime? nowUtc = null,
CancellationToken cancellationToken = default,
int? limit = null)
int? limit = null,
CancellationToken cancellationToken = default)
{
var effectiveNow = nowUtc ?? DateTime.UtcNow;
var replicas = await ReadReplicasAsync(postgres, serverIdFilter, effectiveNow, cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion PerformanceMonitor.Analysis/FactAdvice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ private static string PluralNoun(string noun, bool isSingular)
return noun + "s";
}

private static bool IsVowel(char c) => "aeiouAEIOU".IndexOf(c) >= 0;
private static bool IsVowel(char c) => "aeiouAEIOU".Contains(c);

// Anomaly value formatters (passed to ComposeAnomaly as the observed/baseline renderer).
private static string Pct(double v) => $"{v:0.#}%";
Expand Down
Loading