Skip to content

Add unstableSince timestamp to tolerated tests#9718

Open
mazhelez wants to merge 4 commits into
mainfrom
mazhelez/test-tolerance-unstable-since
Open

Add unstableSince timestamp to tolerated tests#9718
mazhelez wants to merge 4 commits into
mainfrom
mazhelez/test-tolerance-unstable-since

Conversation

@mazhelez

@mazhelez mazhelez commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What & why

Tolerated ("unstable") tests are tracked in the per-branch unstable-tests.json artifact, but until now there was no record of when a test first became unstable. This adds an unstableSince field to each entry so we can see how long a test has been continuously flaky (useful for triage and for eventually retiring or fixing long-standing offenders).

The rule is deliberately simple and lives in a single place. A new Set-UnstableSince pass runs just before the artifact is written and, for each entry, applies one rule: if unstableSince is already set, leave it; otherwise stamp the current UTC time (ISO 8601).

The one non-obvious bit: the hourly updater fully recomputes the list from scratch each run, so rebuilt entries start with no timestamp. To keep the timestamp meaningful (instead of resetting to "now" every hour), Set-UnstableSince also consults the previous artifact, so a test that already had a timestamp there is treated as "already set" and keeps it. A test that self-heals off the list and later returns starts a fresh timestamp.

Linked work

Fixes #

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • This is a PowerShell build-tooling change (test tolerance scripts), not AL app code, so there is no Business Central runtime scenario to exercise.
  • Ran the full Pester suite in build/scripts/TestTolerance locally: 61 passed, 0 failed.
  • Added/updated unit tests covering Set-UnstableSince: stamps a fresh UTC timestamp when missing, keeps an already-set value, preserves a timestamp carried over from the previous artifact across a full recompute, and adds the property when an entry lacks it entirely.
  • Manually verified a round-trip: an entry already unstable in the prior artifact keeps its original timestamp through a recompute, while a newly detected test is stamped with the current time.
  • Parse-checked all changed scripts via the PowerShell language parser (no errors).

Risk & compatibility

Low risk; scoped to the test-tolerance updater scripts and their tests.

  • Artifacts produced before this change carry no unstableSince; the first run after this change stamps every surviving test with that run's time, and the value is preserved on subsequent runs.
  • The additive path (Add-FailedTestsToUnstableTests) no longer stamps timestamps itself; stamping is centralized in Set-UnstableSince, which the driver scripts call once before saving.
  • No change to the tolerance-matching behavior or the artifact's identity key, so existing tolerated-test matching is unaffected.

Record when each tolerated test first became unstable via a new 'unstableSince'
field on unstable-tests artifact entries. A single Set-UnstableSince pass runs
just before the artifact is written and applies one rule per entry: if
'unstableSince' is already set, leave it; otherwise stamp the current UTC time.

Because the sliding-window updater fully recomputes the list each run (rebuilding
entries from scratch), the previous artifact is consulted so an already-recorded
timestamp counts as 'already set' and survives the recompute instead of resetting
hourly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mazhelez
mazhelez requested review from a team July 24, 2026 15:31
@github-actions github-actions Bot added Build: scripts & configs Build scripts and configuration files Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234'

mazhelez and others added 3 commits July 24, 2026 17:46
Remove the standalone Set-UnstableSince pass and stamp 'unstableSince' when the
entry is built in ConvertTo-UnstableTestEntry. Each driver computes one timestamp
per run and passes it through, so every entry created in the same run shares the
same value.

Timestamps still survive the hourly full recompute: Update-UnstableTestsList now
carries each still-unstable test's prior 'unstableSince' forward from the previous
artifact, so a rebuilt entry keeps its original time instead of being restamped.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Previously a newly unstable test left Update-UnstableTestsList with an empty
'unstableSince' that ConvertTo-UnstableTestEntry stamped later. That intermediate
empty value was confusing and split the stamping across two functions. Now
Update-UnstableTestsList assigns the run timestamp directly for a test with no
prior entry (and still carries a prior timestamp forward), so its output is
already correct.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Treats 'unstableSince' as a designed-in field rather than a bolted-on one:
removes a stale doc comment that claimed new tests are left without a
timestamp, drops the redundant -UnstableSince argument from the entry
factory calls that follow Update-UnstableTestsList (those entries already
carry their timestamp), and rewrites the surrounding comments and DESIGN
notes in plain, native terms. Behavior is unchanged; all 61 tests pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: scripts & configs Build scripts and configuration files Other GitHub request for other area than SCM, Finance or Integration Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant