Skip to content

Stabilize nightly integration tests around midnight and correct last-hour merchant KPI logic#496

Merged
StuartFerguson merged 3 commits intomainfrom
copilot/investigate-nightly-build-failure
Mar 11, 2026
Merged

Stabilize nightly integration tests around midnight and correct last-hour merchant KPI logic#496
StuartFerguson merged 3 commits intomainfrom
copilot/investigate-nightly-build-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

The nightly build was failing in integration tests while the PR workflow usually passed because several tests and one KPI path were sensitive to wall-clock time around midnight. This change removes the midnight boundary dependency from the affected tests and fixes the production KPI calculation to use a true rolling last-hour window.

  • Nightly failure mode

    • TodaysSales integration tests were seeding transactions with DateTime.Now.AddHours(-1), which can move data across the date/time cutoff used by reporting queries when the nightly run crosses midnight.
    • MerchantKpi logic treated "last hour" as "today and within the last hour", which drops valid sales from the previous calendar day when the last hour spans midnight.
  • Reporting logic

    • Capture now once and compute MerchantsWithSaleInLastHour using a real bounded time window:
    DateTime now = DateTime.Now;
    Int32 merchantsWithSaleInLastHour =
        (from m in merchants
         where m.LastSaleDateTime >= now.AddHours(-1) && m.LastSaleDateTime <= now
         select m).Count();
    • Reused the same captured now for related day-based KPI comparisons to keep the calculation internally consistent.
  • Integration test determinism

    • Updated the three flaky TransactionsEndpoint_TodaysSales* tests to seed "today" transactions at DateTime.Now.Date and comparison transactions at today.AddDays(-1) rather than relative hour offsets.
    • This preserves the intent of the tests while removing dependence on the exact wall-clock time the workflow happens to execute.
  • KPI test consistency

    • Updated MerchantEndpoint_GetMerchantKpis_MerchantKpisReturned to capture DateTime.Now once and use that single value for all seeded merchants, avoiding intra-test drift during setup.

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 restore 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:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Investigate nightly build failures Stabilize nightly integration tests around midnight and correct last-hour merchant KPI logic Mar 11, 2026
@StuartFerguson StuartFerguson marked this pull request as ready for review March 11, 2026 16:48
@StuartFerguson StuartFerguson merged commit a0ab3d2 into main Mar 11, 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