Skip to content

Stabilize nightly integration tests across the midnight boundary#504

Merged
StuartFerguson merged 2 commits intomainfrom
copilot/investigate-nightly-build-failure-again
Mar 12, 2026
Merged

Stabilize nightly integration tests across the midnight boundary#504
StuartFerguson merged 2 commits intomainfrom
copilot/investigate-nightly-build-failure-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

Nightly builds were failing while PR builds passed because a small set of integration tests seeded date/time-sensitive data using DateTime.Now. When the nightly run crossed midnight, those tests shifted records onto the wrong calendar day or outside the comparison time window.

  • Root cause

    • Merchant KPI tests classified merchants using relative timestamps such as AddMinutes(-10) and AddHours(-2), which stop meaning “today” once execution crosses midnight.
    • Failed-sales tests seeded comparison transactions with comparisonDate.AddHours(-1), which can move data onto the previous date and cause the comparison query to return zero rows.
  • Changes

    • Merchant KPI test setup
      • Reworked seeded merchants to use stable day buckets:
        • last hour → now
        • no sale today → prior calendar days
        • no sale in last 7 days → older than 7 days
      • Removed reliance on “earlier today” offsets that become “yesterday” after midnight.
    • Failed-sales endpoint test setup
      • Seeded today/comparison transactions at the target date boundary instead of subtracting an hour.
      • This keeps TransactionDate aligned with the API’s date filter and avoids falling outside TransactionTime <= DateTime.Now.TimeOfDay.
    • Equivalent fact-controller coverage
      • Applied the same stabilization to the matching fact-controller integration tests so nightly and PR behavior stay aligned across both endpoint surfaces.
  • Representative change

    DateTime todaysDateTime = DateTime.Now.Date;
    DateTime comparisonDate = todaysDateTime.AddDays(-1);
    
    Transaction today = await helper.BuildTransactionX(
        todaysDateTime, merchantId, operatorId, contractId, productId, "1009", amount);
    
    Transaction comparison = await helper.BuildTransactionX(
        comparisonDate, merchantId, operatorId, contractId, productId, "1009", amount);
  • Scope

    • Test-only changes.
    • No production reporting logic or workflow definitions were modified.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • f.feedz.io
    • Triggering command: /usr/bin/dotnet dotnet test EstateReportingAPI.sln (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/EstateReportingAPI/EstateReportingAPI/EstateReportingAPI.sln --packages /tmp/codeql-scratch-f294ada2fef3658c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-f294ada2fef3658c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-f294ada2fef3658c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate nightly build failure compared to PR workflow Stabilize nightly integration tests across the midnight boundary Mar 12, 2026
@StuartFerguson StuartFerguson marked this pull request as ready for review March 12, 2026 12:49
@StuartFerguson StuartFerguson merged commit f2d9afa into main Mar 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants