Skip to content

test: let the tab connect a file before LanguageServerManagerInstancesTest stops its instance - #2120

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/instances-test-waits-for-the-editor-connection
Nov 23, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/instances-test-waits-for-the-editor-connection

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

What

LanguageServerManagerInstancesTest.testAStartWithARootStartsNoOtherStoppedInstance failed on Windows (run 45060985654, on #2092): stop(b) waited 60 s for the instance to be stopped.

Verdict: the test is wrong, not LSP4IJ. It stops an instance with a plain stop(), which doesn't switch it off, while the instance's new editor still has background requests pending, and any request for an open file starts such a server again, as intended.

Cause

Opening a file in an editor makes two background requests for it:

  • the selected tab connects it (ConnectDocumentToLanguageServerSetupParticipant), after waiting for indexing, which can be up to about a second late;
  • code vision asks for its code lenses (LSPCodeLensProvider).

Either can end after the test's own request. When one ended after the test had stopped the instance, it started the instance again.

Change

Test only:

  • the class turns code vision off, as SelectedEditorConnectionTest does;
  • openAndConnect waits until the tab has connected the file before making its own request.

This also covers testEnableAndStartOfAnInstanceWhichFailedStartsDisabledStartsNoOtherStoppedInstance, which has the same exposure.

Test

  • Holding the tab's connection or the code lens request until the instance stops: 5 of 6 runs fail before, 0 of 6 after. The sixth was a run where code lens had created the file's support first, so the tab's connection was skipped.
  • The class, SelectedEditorConnectionTest and LanguageServerInstancesTest pass 3 runs of 127 tests each.

…sTest stops its instance

LanguageServerManagerInstancesTest.testAStartWithARootStartsNoOtherStoppedInstance
failed on Windows (run 45060985654): stop(b) waited 60 s for "The
language server must be stopped".

openAndConnect opened the file in an editor and connected it with a
request of its own. The editor makes two more requests for the file in
the background: its selected tab connects the file
(ConnectDocumentToLanguageServerSetupParticipant, once indexing is done,
in a non-blocking read action), and code vision asks for its code
lenses. Either can end after the request of the test. When it ended
after the test had stopped the instance with stop(), which doesn't
switch it off, it started the instance again, as any request for an
open file does, so the instance never stayed stopped.

openAndConnect now waits until the tab has connected the file before
it makes its own request, and the class disables code vision, as
SelectedEditorConnectionTest does. No product code changes.
@lagergren lagergren added this to the 0.30.2 milestone Nov 22, 2026
@lagergren lagergren added bug Something isn't working junit-test labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved test isolation by preserving and restoring the project’s Code Vision setting.
    • Made language-server connection checks wait for file opening to complete.

The instance tests now disable Code Vision during each test and restore its prior setting during teardown. The file-opening helper waits for the opened file to connect to an instance before querying language servers.

Changes: Instance test stability

Layer / File(s) Summary
Test setup and connection wait
src/test/java/com/redhat/devtools/lsp4ij/LanguageServerManagerInstancesTest.java
The tests save and disable the Code Vision setting, then restore it during teardown while ensuring superclass teardown runs. The openAndConnect helper waits for the opened file to connect before querying language servers.

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

Change: Other

Suggested reviewers: d-biehl

Merge Risk: Minimal · up to 2f81d

This change only stabilizes a flaky Windows instance test by disabling Code Vision during the test and waiting for the opened file to connect. It has no production impact and the remaining merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test class and the tab-connect wait, which is the main change: the test now waits for the tab to connect a file before the test stops its instance. The title is specific and matche…
Description check Passed The description states the failing test, the Windows run, the cause (background requests from the selected tab and code vision restarting a stopped instance), and the test-only change. It also gives v…
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 the test class and the tab-connect wait, which is the main change: the test now waits for the tab to connect a file before the test stops its instance. The title is specific and matches the test-only change. It is long (93 characters), but it stays on topic.

Full details: Description check

Explanation

The description states the failing test, the Windows run, the cause (background requests from the selected tab and code vision restarting a stopped instance), and the test-only change. It also gives verification results. It matches the changeset.

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: 1e481c88-b6c8-4e34-8cd7-8f192b3bd1fb
Commits

Reviewing files that changed from the base of the PR and between 35eb012 and 2f81d5a.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/LanguageServerManagerInstancesTest.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 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.50%. Comparing base (35eb012) to head (2f81d5a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2120      +/-   ##
==========================================
- Coverage   50.51%   50.50%   -0.02%     
==========================================
  Files         816      816              
  Lines       33871    33871              
  Branches     6974     5287    -1687     
==========================================
- Hits        17111    17106       -5     
- Misses      14109    14111       +2     
- Partials     2651     2654       +3     

☔ 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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 809911f into redhat-developer:main Nov 23, 2026
9 checks passed
lagergren added a commit that referenced this pull request Nov 24, 2026
…rflowed, and retry a refused download for a minute (#2175)

## What

Main's last CI run, for 436b029, failed on Windows before any test ran:

```
Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugins-bom/2.3.21/kotlin-gradle-plugins-bom-2.3.21.pom'.
> Received status code 429 from server: Too Many Requests
```

The job had no cache to start from: setup-gradle said "Gradle User Home cache not found. Will initialize empty.", so it
downloaded every dependency again.

**Why there was no cache:** the repository's Actions cache holds 12.2 GB, over GitHub's 10 GB per repository. Every
entry in it was saved in the 20 minutes before this PR, all on main. The biggest are `gradle-transforms` entries of 3.9,
3.3 and 0.9 GB. They are the IDEs that the IntelliJ Platform Gradle plugin extracts as Gradle artifact transforms, one
per job and platform version. Each push to main saves them again for the 5 test jobs, the plugin build and the
verifier. GitHub then evicts the oldest entries, the other jobs' downloads among them, and the next run of those jobs
fetches everything from Maven Central and JetBrains again.

## Change

- **The cache:** every `setup-gradle` step leaves `caches/transforms-4` and `caches/*/transforms` out of the Actions
  cache, with `gradle-home-cache-excludes`. setup-gradle deletes them before it saves. These are ci.yml, buildZip.yml,
  IJ.yml, IJ-latest.yml (3 steps), nightly.yml and release.yml.
  - The downloads themselves stay cached (`gradle-dependencies`, now 1.3 to 2 GB an entry), so the entries fit in
    10 GB, and Gradle extracts an IDE again from its cached download without a network access.
  - Locally the IDEs are in `caches/9.9.2/transforms/*/transformed/extracted`.
- **Retries:** Gradle 9.9.2 already retries a download refused with a server error or a 429
  (`NetworkingIssueVerifier`), but only 3 times, 1 and 2 seconds apart. `gradle.properties` raises that to 6 times, 2,
  4, 8, 16 and 32 seconds apart, with `systemProp.org.gradle.internal.network.retry.max.attempts` and `.initial.backOff`,
  which `NetworkOperationBackOffAndRetry` reads. A local build prints them back as 6 and 2000 from an init script.

## The other CI failures this week

I went through the 22 failed "Java CI with Gradle" runs since 2026-11-17:
- **6 were a real break**, fixed by #2138: `InstallerTaskRegistryInitializeTest` failed on every job after #2102.
- **Most of the rest were flaky tests, since fixed:**
  - `LanguageServerManagerInstancesTest` by #2120;
  - `CancelRequestAfterShutdownTest` by #2162;
  - `SocketLanguageServerTest` by #2064;
  - `SelectedEditorConnectionTest` and `FileDocumentMoveTest` by the fixes of #2099 and #2095.
- **Seen once and not fixed:** `WatchedFilesTest` (Windows, 2026-11-22) and `LanguageServerInstancesTest` (2026.3,
  2026-11-18).
- **Since 2026-11-23 14:00 UTC:** 36 runs passed, and the only failure was this 429.

## Check

A pull request reads the cache but doesn't write it, so this PR's own CI can't show the saving. After the merge, the
next run on main should leave the repository's cache under 10 GB, and the run after it should restore each job's entry.
I'll check both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working junit-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant