Skip to content

test: cover the three test gaps that CodeRabbit found in #1924, #1938 and #1986 - #2033

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/coderabbit-test-gaps
Nov 20, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/coderabbit-test-gaps

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Part of #2011: its three test gaps. No change in behavior.

Each new check fails without what it checks: with getModifier()
ignoring the hint, the session test fails ("A read-only value can't be
set"), and with the first listener only, on a JVM started with
-Djava.net.preferIPv6Addresses=true, the IPv4 test fails.

On such a JVM, six tests of SocketStreamConnectionProviderTest and
UserDefinedSocketConnectionTest fail before and after this change: they
expect the text of an IPv4 address, such as HOST + ":" + port without
the brackets of an IPv6 address, or 127.0.0.1 before [::1]. They are
left as they are.

Tests

ApplicationUtilsTest, SocketStreamConnectionProviderTest, DAPBreakOnValueChangeSessionTest and DAPValueReadOnlyTest pass (46 tests).

…oper#1924, redhat-developer#1938 and redhat-developer#1986

Part of redhat-developer#2011: its three test gaps. No change in behavior.

- `ApplicationUtilsTest` (redhat-developer#1924): on the EDT without read access, it now
  checks that there is no read access before each of the two overloads,
  not only before the first, so the second shows that it takes the
  write-intent lock itself, rather than running with access that the
  first one left.
- "Set Value..." of a read-only variable (redhat-developer#1938): `DAPValueReadOnlyTest`
  checks `canSetValue`, but not that `DAPValue.getModifier()` uses it. A
  `DAPValue` needs a debug session, so the check is in
  `DAPBreakOnValueChangeSessionTest`, whose DAP server now supports
  `setVariable` and has a read-only field: `getModifier()` gives a
  modifier for `count` and none for `limit`.
- The IPv4 listener (redhat-developer#1986): `ConnectingServer` connects to
  `InetAddress.getLoopbackAddress()`, which is `::1` on a JVM that
  prefers IPv6, so no test reached the IPv4 listener there.
  `IPv4ConnectingServer` connects to `127.0.0.1`, as
  `IPv6ConnectingServer` does to `::1`.

Each new check fails without what it checks: with `getModifier()`
ignoring the hint, the session test fails ("A read-only value can't be
set"), and with the first listener only, on a JVM started with
`-Djava.net.preferIPv6Addresses=true`, the IPv4 test fails.

On such a JVM, six tests of `SocketStreamConnectionProviderTest` and
`UserDefinedSocketConnectionTest` fail before and after this change: they
expect the text of an IPv4 address, such as `HOST + ":" + port` without
the brackets of an IPv6 address, or `127.0.0.1` before `[::1]`. They are
left as they are.
@lagergren lagergren added this to the 0.30.2 milestone Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Expanded coverage for debugger variables to verify that writable values offer “Set Value…” while read-only values do not.
    • Added checks for write-intent lock behavior across cancellable read-action overloads.
    • Added coverage for language server connections over IPv4 loopback, including a successful ping round trip.

The changes update tests for DAP variable actions, cancellable read-action locks, and IPv4 loopback socket connections.

Changes: DAP variable actions

Layer / File(s) Summary
Read-only variable test
src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPBreakOnValueChangeSessionTest.java
The mock DAP server advertises variable-setting support and returns writable count and read-only limit variables. The test checks modifier availability for both.

Read-action lock checks

Layer / File(s) Summary
Cancellable read-action checks
src/test/java/com/redhat/devtools/lsp4ij/internal/ApplicationUtilsTest.java
The test checks read access and write-intent lock state for each cancellable read-action overload.

IPv4 socket connection

Layer / File(s) Summary
IPv4 loopback round trip
src/test/java/com/redhat/devtools/lsp4ij/server/SocketTestServers.java, src/test/java/com/redhat/devtools/lsp4ij/server/SocketStreamConnectionProviderTest.java
A test server connects to 127.0.0.1. The test verifies a ping round trip through the accepted connection and reaps the provider.

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

Change: Other

Merge Risk: Minimal · up to af233

This change only adds tests and does not alter production behavior. No actionable merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding tests that close three coverage gaps (ApplicationUtilsTest, read-only Set Value modifier test, IPv4 listener test). It is specific and matches the changeset. No…
Description check Passed The description matches the changeset. It explains each of the three added tests, why they are needed, how they fail without the behavior under test, and which existing tests fail on IPv6-preferring J…
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 main change: adding tests that close three coverage gaps (ApplicationUtilsTest, read-only Set Value modifier test, IPv4 listener test). It is specific and matches the changeset. Note: it cites issue numbers that the objectives describe differently (#2033 vs #2011 in the description), but the title itself is related to the changeset.

Full details: Description check

Explanation

The description matches the changeset. It explains each of the three added tests, why they are needed, how they fail without the behavior under test, and which existing tests fail on IPv6-preferring JVMs. It is related and detailed.

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: b0a6b0af-572a-4959-8859-bf7ed81f4aff
Commits

Reviewing files that changed from the base of the PR and between b354c38 and af2338c.

Files selected for processing: 4

  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPBreakOnValueChangeSessionTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/internal/ApplicationUtilsTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/server/SocketStreamConnectionProviderTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/server/SocketTestServers.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 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.42%. Comparing base (b354c38) to head (af2338c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2033      +/-   ##
==========================================
+ Coverage   49.39%   49.42%   +0.03%     
==========================================
  Files         813      813              
  Lines       33323    33323              
  Branches     5191     6848    +1657     
==========================================
+ Hits        16461    16471      +10     
+ Misses      14290    14277      -13     
- Partials     2572     2575       +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
lagergren merged commit 13916a2 into redhat-developer:main Nov 20, 2026
13 of 14 checks passed
lagergren added a commit that referenced this pull request Nov 20, 2026
…2034)

On a JVM started with `-Djava.net.preferIPv6Addresses=true`,
`InetAddress.getLoopbackAddress()` is `::1`, and six socket tests failed,
for the way they wrote the expected text, not for what LSP4IJ does:

- `SocketStreamConnectionProviderTest` wrote the host before a port as
  `HOST + ":" + port`, which for `0:0:0:0:0:0:0:1` lacks the brackets
  that the provider writes, as it must:
  `testConnectsToALanguageServerThatRunsAlreadyAndLeavesItRunningWhenItStops`,
  `testCannotStartWhenNoLanguageServerListens` and
  `testConnectionDescriptionForAttach`.
- `UserDefinedSocketConnectionTest` looked for the JVM's loopback address
  as `getHostAddress() + ":" + port`, so `0:0:0:0:0:0:0:1:6005` in
  `connect to [::1]:6005 or 127.0.0.1:6005`:
  `testALanguageServerThatRunsAlreadyIsReachedOnTheLoopbackAddressWithoutAHost`,
  `testABlankHostIsTheLoopbackAddress` and
  `testALanguageServerWhichListensIsReachedOnTheLoopbackAddress`.

The first now writes the host in brackets when it is an IPv6 address.
The second now checks both loopback addresses in the order the provider
tries them, the JVM's first, which also checks that order, where it
checked each address on its own before.

Follow-up to #2033, which adds a test of the IPv4 listener for such a JVM. The two touch different lines and merge cleanly.

### Tests

- On a JVM that prefers IPv6 addresses (`JAVA_TOOL_OPTIONS=-Djava.net.preferIPv6Addresses=true`), the 22 test classes that use loopback addresses had these six failures and no others (171 tests). With this change, `SocketStreamConnectionProviderTest` and `UserDefinedSocketConnectionTest` pass there, and on a default JVM (37 tests each).
- With #2033 merged in, both classes pass on a JVM that prefers IPv6 addresses too, its new IPv4 test included (38 tests).
lagergren added a commit that referenced this pull request Nov 21, 2026
…#2035)

`DAPLoopbackConnectionTest.withoutAnAddressTheWaitForTheDAPServerSeesItsSocketOnTheIPv6LoopbackAddress`
failed in the 2026.3 job of #2032, which doesn't touch DAP:

    org.opentest4j.AssertionFailedError: expected: <false> but was: <true>
        at ...DAPLoopbackConnectionTest.java:59

The three tests of the class listen on a port of `::1` that the system
picks, and expect nothing on the same port of `127.0.0.1`: a connection
there must be refused, and a client without an address must fall through
to `::1`. A port that is free on `::1` can be in use on `127.0.0.1` by
another program or test, and then the connection is accepted and the
test fails.

The tests now also bind that port of `127.0.0.1` with a socket that
doesn't listen, and take another port when it is in use. While it is
bound, nothing else can listen there, so a connection to it is refused.

### Tests

Checked on macOS, with another process as the other program:
- a program can listen on `127.0.0.1` on the port that the test has on `::1`, and a connection to it is then accepted, which is the failure of the job;
- then the reservation can't bind the port (`Address already in use`), and the test takes another one;
- once the port is reserved, another program can't listen on it, even with `SO_REUSEADDR`, nor can a `ServerSocket` with `SO_REUSEADDR`, and a connection to it is refused.

`DAPLoopbackConnectionTest` passes on a default JVM and on one that prefers IPv6 addresses.

Not here: two tests of `SocketStreamConnectionProviderTest` have the same race, `testWithoutAHostItReachesALanguageServerWhichListensOnTheIPv6LoopbackAddressOnly` and `testAnIPv4AddressAsTheHostIsNotTriedOverIPv6`. #2033 and #2034 change that file, so they can follow once those are merged.
lagergren added a commit that referenced this pull request Nov 23, 2026
… of the file it found (#2089)

Fixes #2011

## What

When the check of an installer finds the server installed, the download doesn't run, and only the download gives the server its command. So a server created from a template once its binary was installed kept the template's command, such as `clangd` or `${BASE_DIR}/rust-analyzer`.

#2041, #2054 and #2057 fixed the templates with a fixed path. This fixes the rest: servers in a folder or file named after their version, or at a path by architecture. #2033 already covered the test gaps of #2011.

## Change

- **`${check.file}`:** `fileExists` gives the file it found to the tasks after it.
  - The path is as written in `file`, with `${...}` properties resolved and macros kept, as `$USER_HOME$/.lsp4ij/lsp/clangd_19.1.2/bin/clangd`. That is the same form as a download's `${output.dir}`.
  - If a glob matches several files, the last in natural order wins, segment by segment: `clangd_19.1.10` after `clangd_19.1.2`, and `camel-lsp-server-1.31.0.jar` after `camel-lsp-server-1.9.0.jar`.
  - A `fileExists` that finds nothing removes `${check.file}`.
- **A new task, `replaceTemplateCommand`,** with `templateCommand` and `command`, both by OS like `command`.
  - It sets the command as `configureServer` does, but only while the server's command is exactly `templateCommand`.
  - Otherwise it leaves the command and succeeds, so the check still passes, and *Check installation* in the settings keeps a command that the user or a download set.
  - On an OS without a `templateCommand`, it changes nothing.
- **Why a separate task, not an option of `configureServer`: older versions stay safe.**
  - LSP4IJ 0.30.1 skips a task type it doesn't know. So after a downgrade, a Settings Sync with an older IDE, or a template imported into an older version, the check still passes, and the server keeps its command.
  - A `configureServer` there would set the literal `"${check.file}"`.
  - Both were checked by running the 0.30.1 code on these installers.
- **`configureServer`** is unchanged, except that a command that still has `${check.file}` after resolution is now reported as an error and not set.
- **The bundled installers:** the checks of clangd, camel-lsp-server, ada_language_server, rust-analyzer, wgsl-analyzer, codelldb, perl-dap and vscode-js-debug get an `onSuccess` `replaceTemplateCommand`, with their template's command and the command that their download gives, from `${check.file}`. cpp_ls, docker-language-server and terraform-ls keep their commands on the PATH.
- **ada_language_server's check** now looks under `integration/`. Every Ada release archive since before the template existed has that single root folder, which the download adds to `${output.dir}`, so the old check never found the installed server.
- **Schema and docs:** the `installer.json` schema and `docs/UserDefinedLanguageServerTemplate.md` describe `fileExists`, `${check.file}` and `replaceTemplateCommand`, with clangd's check as the example.

Servers created before this change keep the installer they were created with, so they aren't affected.

## Test

- **`FileExistsTaskTest`:** `${check.file}` without a glob, with several matches (in natural order; a folder without the file is ignored), with a glob in the file name, and with macros kept; no property when the file is missing, and an earlier one removed.
- **`ReplaceTemplateCommandTaskTest`** (new):
  - the template's command is replaced;
  - a command that the user changed, and one that an earlier download set, stay, and the task still succeeds;
  - no `templateCommand` for the OS changes nothing;
  - an unresolved `${check.file}` is an error and changes nothing, in this task and in `configureServer`;
  - `configureServer` still changes the command as before;
  - `templateCommand` by OS;
  - the plugin's registry loads the task for the bundled clangd installer;
  - a full check with two versions of clangd.
- **`InstallerTaskRegistryFileExistsTest`:** for clangd, camel-lsp-server, codelldb, perl-dap and vscode-js-debug, it runs the download from a local archive, then the check for a server with the template's command. The check sets the same command as the download, and a changed command and one from an earlier version stay.
- **`BundledTemplateCommandsTest`:** for the eight templates and each OS and architecture that they declare, the check finds the file that the download installs, its command equals the download's, and `templateCommand` equals the template's command. The test of a home directory with a space now also covers the check commands.
- **Results:** the installation and template tests pass (110), and so does the full suite (1,845 tests, 0 failures, 7 skipped).
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