From 8fcebd4c205227d199d5d68a12633bc224271a9b Mon Sep 17 00:00:00 2001 From: John Simons Date: Fri, 9 Oct 2026 12:24:41 +1000 Subject: [PATCH] Fix flaky partitioning test by truncating the comparison time to the hour The test compared partition bounds to the raw current time, but provisioning works off hour-truncated timestamps. Near an hour boundary (especially midnight) this mismatch could make the assertions fail intermittently. --- .../PartitioningTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ServiceControl.Audit.Persistence.Tests.PostgreSql/PartitioningTests.cs b/src/ServiceControl.Audit.Persistence.Tests.PostgreSql/PartitioningTests.cs index 1679782844..72f497cb75 100644 --- a/src/ServiceControl.Audit.Persistence.Tests.PostgreSql/PartitioningTests.cs +++ b/src/ServiceControl.Audit.Persistence.Tests.PostgreSql/PartitioningTests.cs @@ -37,13 +37,13 @@ FROM pg_partitioned_table p public async Task Setup_provisions_whole_days_through_the_lookahead() { var end = await ProvisionedUntil(); - var now = configuration.TimeProvider.GetUtcNow().UtcDateTime; + var hour = AuditHours.Truncate(configuration.TimeProvider.GetUtcNow().UtcDateTime); using (Assert.EnterMultipleScope()) { Assert.That(end, Is.EqualTo(end!.Value.Date), "a partition holds a whole day"); - Assert.That(end, Is.GreaterThanOrEqualTo(now + AuditHours.Lookahead)); - Assert.That(end, Is.LessThan(now + AuditHours.Lookahead + TimeSpan.FromDays(1))); + Assert.That(end, Is.GreaterThanOrEqualTo(hour + AuditHours.Lookahead)); + Assert.That(end, Is.LessThan(hour + AuditHours.Lookahead + TimeSpan.FromDays(1))); } }