Skip to content

accounts: run DefaultAccountProvider session lookup retry tests in virtual time - #342248

Merged
Alexandru Dima (alexdima) merged 1 commit into
mainfrom
agents/test-perf-default-account-retries
Oct 17, 2026
Merged

Alexandru Dima (alexdima) merged 1 commit into
mainfrom
agents/test-perf-default-account-retries

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

cc Anthony Kim (@anthonykim1)


A failed session lookup is retried three times with 500ms delays, so these two tests spent about 1s each waiting in real time. Run each whole test in virtual time with runWithFakedTimers.

Both tests drop from ~1-1.1s to a few ms.

After the test body finishes, runWithFakedTimers also runs the remaining virtual timers, which includes DefaultAccountProvider's hourly account poll. That now happens after the assertions, and a temporary trace confirmed it starts no further session lookups that could leak into later tests.

Part of a series that speeds up unit tests waiting on real time, found from the slow tests in the Linux Electron unit test job. Each change is a separate PR so it can be reverted on its own. Test files only; no assertions changed.

How to test

npm run build-fast -- --client-only
./scripts/test.sh --run src/vs/workbench/services/accounts/test/browser/defaultAccount.test.ts

Results on macOS, with only this commit applied on top of 832a728:

  • ./scripts/test.sh --run src/vs/workbench/services/accounts/test/browser/defaultAccount.test.ts: 65 passing (3s)

Copilot AI balanced review requested due to automatic review settings October 17, 2026 08:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused test-only changes preserve assertions, restore timers reliably, and have no unresolved findings.

No open issues 🎉

What changed in this PR

Speeds up two DefaultAccountProvider tests by replacing real retry waits with fake time.

Changes:

  • Adds a helper that advances fake timeouts incrementally and restores the clock.
  • Applies the helper to two failed-session-lookup tests without changing assertions.
File Description
src/​vs/​workbench/​services/​accounts/​test/​browser/​defaultAccount.test.ts Fakes retry delays while avoiding the hourly account poll.

Review effort: Balanced

…rtual time

A failed session lookup is retried three times with 500ms delays, so these two tests spent about 1s each waiting in real time. Run each whole test in virtual time with `runWithFakedTimers`.

Both tests drop from ~1-1.1s to a few ms.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexdima
Alexandru Dima (alexdima) force-pushed the agents/test-perf-default-account-retries branch from f8e04d3 to a4df0c5 Compare October 17, 2026 09:49
@alexdima Alexandru Dima (alexdima) changed the title accounts: fake the session lookup retry delays in DefaultAccountProvider tests accounts: run DefaultAccountProvider session lookup retry tests in virtual time Oct 17, 2026
@alexdima
Alexandru Dima (alexdima) marked this pull request as ready for review October 17, 2026 15:12
@alexdima
Alexandru Dima (alexdima) merged commit 30ca50f into main Oct 17, 2026
83 of 84 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the agents/test-perf-default-account-retries branch October 17, 2026 15:36
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants