Skip to content

test: the hover cache test waits for the language server, and the thread run state test ignores the 2026.3 tab rebuild - #2312

Merged
lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:test/feature-cache-hover-flake
Nov 27, 2026
Merged

lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:test/feature-cache-hover-flake

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Two races in tests, one commit each, for a rebase merge. Nothing in the product was wrong.

1. FeatureCacheOtherFileChangeTest hovers only once the language server has started

testHoverIsAskedForAgainWhenAnotherFileChanges failed on main's Windows job twice in a row today (runs on d2ab131 and 1276e37), at line 53, "nothing has changed, so the hover is reused":

expected:<class Other[]> but was:<class Other[ // documented]>

Cause. Not the project's PSI modification count: logging every increment of PsiModificationTracker showed it, the file's stamp and its LSPFileSupport unchanged between the two hovers. Since #2208, LSPHoverSupport also records LanguageServiceAccessor.getModificationCount() when it sends a hover, and asks again once a language server started or stopped since. The mock language server starts in the background when other.foo opens; when its start was still running at the first hover, it ended during it (updateStatus(started) on the server's listener thread moved the count from 1 to 2), and the second hover asked again, as designed. On a slow runner the start takes longer than configureByText("main.foo").

Fix. The test waits for the language server (awaitLanguageServers(main)) before the first hover.

Reproduction. Holding the server's initialize until the first hover has read the counts makes the old test fail every time with the CI message; with the fix it passes. The definition test of the class, HoverWithoutWaitingTest, GotoDeclarationWriteActionTest and CompletionWhileTypingTest aren't exposed: only the hover uses the servers' count, and the others already wait for the language servers.

2. DAPThreadRunStateSessionTest no longer counts the views that IntelliJ 2026.3 rebuilds for a new session tab

testAThreadWhichContinuedAloneRunsAndShowsNoFramesOfItsStop counted settingsChanged from the moment it added its listener, and asserted at once that the views were built again after the worker continued.

Cause. In 2026.3 the frontend creates the session tab some time after the session starts, and its XDebugSessionTab.init rebuilds the views through an RPC to the backend, XDebugSessionImpl.frontendUpdate() → settingsChangedFromFrontend(), which calls settingsChanged() by default. In a local IU 2026.3 run it arrived 1.6 s after the start and 85 ms before the test added its listener, so it could be counted, and the test could pass without the client's own rebuild. 2024.2 and 2025.3 build the views of a new tab at once, during the start. The other risk, the client's rebuild arriving after the assertion, isn't real: DAPClient.continued calls rebuildViews() synchronously, and IntelliJ tells the listeners synchronously, before the ping that waitUntilHandled waits for.

Fix. The listener leaves out settingsChangedFromFrontend() (no @Override: 2024.2 and 2025.3 don't declare it), and the test waits for the rebuild with a bound and a message instead of asserting at once.

Proof, on IU 2026.3: with the product's rebuild switched off and the frontend's update delivered just after the listener is added, the old test passes for the wrong reason and the fixed one fails "the views of the stop are built again", as it should; with the product's rebuild, both pass.

Tests

Headless, 2024.2: FeatureCacheOtherFileChangeTest, dap.threads.*, features.documentation.*, features.navigation.*, CompletionWhileTypingTest, CancelRequestAfterShutdownTest and ServerStopPendingRequestsTest: 76 tests, no failure, error or skip.

…erver has started

testHoverIsAskedForAgainWhenAnotherFileChanges failed on main's Windows job twice
(runs 45990024944 and 45993688265): the second hover, which nothing had changed
for, asked the language server again and got its new answer.

The language server starts in the background when the first file opens. On a
slow runner it was still starting when the first hover was asked for. Since
redhat-developer#2208, LSPHoverSupport records the modification count of the project's language
servers when it sends a hover, and asks again once a server has started or
stopped since. The end of that start therefore made the second hover ask again,
as designed. The project's PSI modification count did not change.

The test now waits for the language server to start before the first hover. The
other tests of the class are not affected: the definition support does not use
the language servers' count, and a start does not change the PSI count.
…telliJ 2026.3 rebuilds for a new session tab

testAThreadWhichContinuedAloneRunsAndShowsNoFramesOfItsStop adds a session
listener after the stop and checks that the 'continued' event of the worker
rebuilds the views (settingsChanged).

In IntelliJ 2026.3, the frontend creates the session tab some time after the
session starts. XDebugSessionTab.init then rebuilds the views:
FrontendXDebuggerSession.rebuildViews runs a coroutine on the EDT, which calls
XDebugSessionApi.triggerUpdate. The backend handles that with
XDebugSessionImpl.frontendUpdate, which calls settingsChangedFromFrontend, and
that calls settingsChanged by default. Locally this arrived 1.6 s after the
session started and 85 ms before the test added its listener. On a slower
runner it can arrive after the listener is added. The test would then count it
and pass even if the client did not rebuild the views. In 2024.2 and 2025.3,
the tab rebuilds the views at once, while the session starts.

The listener now ignores settingsChangedFromFrontend. It counts only
XDebugSessionImpl.rebuildViews, which the client calls when it handles the
event. The client calls it synchronously on its message thread, and both
platforms notify the listeners synchronously, so the count was never zero when
it was asserted. The test still waits for it, with a bound, instead of
asserting it at once.
@lagergren lagergren added this to the 0.30.2 milestone Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved test reliability for debugger thread-state updates by waiting for the relevant event before checking the result.
    • Updated hover-cache testing to account for language-server startup and the timing of the first hover request. These changes make the automated checks more consistent when validating debugger and hover behavior.

Two tests now wait for asynchronous setup or event handling before proceeding. The DAP test waits for a settings notification, and the hover-cache test waits for its language server to start.

Changes: Test timing synchronization

Layer / File(s) Summary
Synchronize asynchronous test steps
src/test/java/com/redhat/devtools/lsp4ij/dap/threads/DAPThreadRunStateSessionTest.java, src/test/java/com/redhat/devtools/lsp4ij/features/FeatureCacheOtherFileChangeTest.java
The DAP test adds a listener override and waits for the settings event. The hover-cache test retains the configured main file and waits for its language server to start before requesting hover.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Merge Risk: Minimal · up to 9566b

This PR only makes two tests wait for asynchronous setup and event handling, so it should reduce test flakiness. It has no product behavior impact, and I found no remaining merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names both changes: the hover cache test now waits for the language server, and the thread run state test ignores the 2026.3 tab rebuild. Both match the changeset and the PR objectives. The …
Description check Passed The description explains both test races, their causes, the fixes, reproduction steps, and the test results. It matches the changeset and the objectives.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names both changes: the hover cache test now waits for the language server, and the thread run state test ignores the 2026.3 tab rebuild. Both match the changeset and the PR objectives. The title is long (118 characters) but still specific.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1abbbd9d-8f7f-4b33-a557-57d9c7982cfd
Commits

Reviewing files that changed from the base of the PR and between 1276e37 and 9566be6.

Files selected for processing: 2

  • src/test/java/com/redhat/devtools/lsp4ij/dap/threads/DAPThreadRunStateSessionTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/FeatureCacheOtherFileChangeTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.63%. Comparing base (1276e37) to head (9566be6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2312      +/-   ##
==========================================
- Coverage   58.64%   58.63%   -0.02%     
==========================================
  Files         848      848              
  Lines       36674    36674              
  Branches     7603     7603              
==========================================
- Hits        21507    21503       -4     
- Misses      12169    12171       +2     
- Partials     2998     3000       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren
lagergren merged commit d369a98 into redhat-developer:main Nov 27, 2026
11 checks passed
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.

1 participant