Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing Java Test Runner Support for Java #14871

Closed
thisHermit opened this issue Oct 13, 2019 · 23 comments
Closed

Installing Java Test Runner Support for Java #14871

thisHermit opened this issue Oct 13, 2019 · 23 comments
Assignees
Labels
area/languages Issues related to Language extensions or plugins integration. kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P2 Has a minor but important impact to the usage or development of the system.
Milestone

Comments

@thisHermit
Copy link

thisHermit commented Oct 13, 2019

Issue

There seems to be no support for running Tests in Java on Che 7.

Adding the Java Test Runner extension would be a good solution to this problem as it would add support for both class level and function level tests.

Steps tried

  • Tried installing the plugin by copying the Code Quick Open from here as suggested over here
  • Tried installing the plugin by publishing it as mentioned over here by publishing it.
    • The publishing instructions were not very clear. On stumbling about, found this page about customising the registries
  • Tried editing the plugin registry at runtime as mentioned here.
    • The commands did not mention changing the namespace.
    • kubectl exec $\{PLUGIN_REG_POD} -i -t -- /var/www/html/index_v2.sh v3 > /var/www/html/v3/plugins/index.json did not work. It kept confusing the files by trying to find the file on my local machine.

Help regarding any of the above solutions is much appreciated.

Here are the issues that are keeping this extension from working properly in Che:
[x] Support VS Code Standard Icons in Contributions eclipse-theia/theia#7634
[x] Support Command Type for StatusBarItem.command eclipse-theia/theia#8241
[x] Cannot resolve /hostedPlugin/ Resources from Sidecar Containers #17517

@thisHermit thisHermit added the kind/question Questions that haven't been identified as being feature requests or bugs. label Oct 13, 2019
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Oct 13, 2019
@ibuziuk
Copy link
Member

ibuziuk commented Oct 14, 2019

@tsmaeder do you happen to know about any ongoing work related to java test runner support ?

@ibuziuk ibuziuk added kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system. area/languages Issues related to Language extensions or plugins integration. and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. kind/question Questions that haven't been identified as being feature requests or bugs. labels Oct 14, 2019
@tsmaeder
Copy link
Contributor

any ongoing work related to java test runner support ?

No, there is nothing planned.

@ibuziuk ibuziuk added severity/P2 Has a minor but important impact to the usage or development of the system. and removed severity/P1 Has a major impact to usage or development of the system. labels Oct 14, 2019
@ibuziuk
Copy link
Member

ibuziuk commented Oct 14, 2019

@tsmaeder moving to P2 and letting you prioritize accordingly ;-)

@thisHermit
Copy link
Author

thisHermit commented Oct 14, 2019

Java Test Runner plugin is not shown in the available plugins in the editor on running a custom plugin registry.

Running kubectl logs <registry-pod-name> -n che gave the following outuput repeated for almost every plugin.

Checking meta /var/www/html/v3/plugins/ms-vscode/node-debug/latest/meta.yaml
Updating image registry to https://github.com/microsoft/vscode-java-test
Updating image organization to microsoft
Updating image tag to vscode-java-test}

It seems to be repeated 103 times as indicated by this command
kubectl logs <registry-pod-name> -n che | grep https://github.com/microsoft/vscode-java-test | wc -l

which is very close to 101 times as returned by this command
tree ./v3/plugins/ | grep meta.yaml | wc -l
run inside the plugin-registry repo

My meta.yaml file for the java-test-runner (v2 used as mentioned in #14853's comment):

apiVersion: v2
publisher: microsoft
name: vscode-java-test
version: latest
type: VS Code extension
displayName: Tester
title: Java Test Runner
description: Run and Debug Java Unit Tests
category: Debugger
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
repository: https://github.com/microsoft/vscode-java-test.git
spec:
extensions:
- https://github.com/redhat-developer/vscode-java/releases/download/v0.47.0/redhat.java-0.47.0.vsix
- https://github.com/microsoft/vscode-java-debug/releases/download/0.22.0/vscode-java-debug-0.22.0.vsix
- https://github.com/microsoft/vscode-java-test/releases/download/0.20.0/vscode-java-test-0.20.0.vsix

@thisHermit
Copy link
Author

As you have moved this to a P2 priority, would you mind if I take this up?

If yes, can you please suggest me the steps I should take?

@tolusha
Copy link
Contributor

tolusha commented Oct 15, 2019

@thisHermit
I suggest to add test extension into https://github.com/eclipse/che-plugin-registry/blob/master/v3/plugins/redhat/java/latest/meta.yaml, test if everything works fine and submit a PR

@tolusha
Copy link
Contributor

tolusha commented Oct 15, 2019

In your case the meta yaml will be the following

apiVersion: v2
publisher: redhat
name: java
version: latest
type: VS Code extension
displayName: Language Support for Java(TM)
title: Language Support for Java(TM) by Red Hat
description: Java Linting, Intellisense, formatting, refactoring, Maven/Gradle support
  and more...
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
repository: https://github.com/redhat-developer/vscode-java
category: Language
firstPublicationDate: "2019-10-03"
spec:
  containers:
  - image: "docker.io/eclipse/che-remote-plugin-runner-java8:next"
    name: vscode-java
    memoryLimit: "1500Mi"
    volumes:
    - mountPath: "/home/theia/.m2"
      name: m2
  extensions:
  - https://github.com/microsoft/vscode-java-debug/releases/download/0.20.0/vscode-java-debug-0.20.0.vsix
  - https://download.jboss.org/jbosstools/static/jdt.ls/stable/java-0.50.0-1825.vsix
  - https://github.com/microsoft/vscode-java-test/releases/download/0.20.0/vscode-java-test-0.20.0.vsix

@tolusha
Copy link
Contributor

tolusha commented Oct 15, 2019

Host it somewhere, for instance as a gist and add into a devfile of your workspace

  - type: chePlugin
    reference: <path to raw file>

@ibuziuk ibuziuk added the status/open-for-dev An issue has had its specification reviewed and confirmed. Waiting for an engineer to take it. label Oct 15, 2019
@thisHermit
Copy link
Author

thisHermit commented Oct 15, 2019

@tolusha, just wanted a confirmation, will java test runner actually work after installing it? Are there any restrictions that could prevent it from working?

Edit:
Not sure if I am understanding this correctly, but this comment here implies that the API needs to be changed to support tests.
#14023 (comment)

@tsmaeder
Copy link
Contributor

@thisHermit no, that issue has nothing to do with this one.

@tsmaeder
Copy link
Contributor

@thisHermit missed the first part of your question, though. The extension should work, mostly. That said, there are parts of the VS Code API theia does not implement yet (or not in exactly the same way), so you'll need to test, I'm afraid.
Also, the fact that the plugin runs on a separate container with a separate files system can break features that make the assumption that the extension and the IDE run on the same machine.

@tsmaeder
Copy link
Contributor

This is another extension that needs to be run together with jdt.ls. We really need a solution for mix-and-match jdt.ls extensions before we proceed here.

@tsmaeder tsmaeder added status/blocked Issue that can’t be moved forward. Must include a comment on the reason for the blockage. and removed status/open-for-dev An issue has had its specification reviewed and confirmed. Waiting for an engineer to take it. labels Nov 25, 2019
@tsmaeder tsmaeder added this to the Backlog - Languages milestone Jan 23, 2020
@ericwill ericwill mentioned this issue Apr 1, 2020
47 tasks
@ericwill
Copy link
Contributor

I tried installing vscode-java-test (alongside vscode-java-debug and vscode-java) and I can't get the tests to run in my workspace.

When I try to open the Test Explorer, I get an error in the notification area Java: No delegateCommandHandler for vscode.java.test.search.items. Same things happens if I try to run the command "Java: Run all tests". I tried debugging the issue, including trying a known workaround, but it didn't fix the issue.

Could this be some missing VSCode API on our end?

@tsmaeder
Copy link
Contributor

@ericwill do you run the vscode-java-test extension in the same Che plugin as vscode-java? The missing command handler could indicate that an extension bundle (probably provided by the test extension) is not found by jdt.ls.

@ericwill
Copy link
Contributor

@ericwill do you run the vscode-java-test extension in the same Che plugin as vscode-java? The missing command handler could indicate that an extension bundle (probably provided by the test extension) is not found by jdt.ls.

Yes they are running in the same Che plugin. There are some errors logged in the vscode-java/jdt-ls console: error.log.

@tsmaeder
Copy link
Contributor

FWIW, it the java test runner seems to start up fine for the following combination in Theia master:

redhat.java-0.62.0.vsix
vscjava.vscode-java-debug-0.26.0.vsix
vscjava.vscode-java-test-0.22.3.vsix

@tsmaeder
Copy link
Contributor

Further problems I've identified:

  1. With the "Test Report" opened, clicking on "Navigate to Source" has no effect (no error, either) (theia and che-theia)
  2. Within the test runner view in Theia, I see a green checkmark next to a sucessfully run test. Not in Che
  3. There are "Run test" and "Debug test" links shown above a test method in the editor in Theia. Not in Che.

@benoitf
Copy link
Contributor

benoitf commented Jul 28, 2020

for 2. and 3. do you see errors reported ?

@tsmaeder tsmaeder self-assigned this Jul 29, 2020
@tsmaeder
Copy link
Contributor

@benoitf I'll be analysing these differences today and will let you know.

@tsmaeder
Copy link
Contributor

Just found a case where there are no tests shown in the test explorer, even though "run all tests" correctly executes tests. Reopening the test explorer correctly shows the tests. Seems it's an timing/event problem.

@tsmaeder
Copy link
Contributor

The problem with the code lenses is a bug in the test runner extension, it seems: "dispose" is called on TestCodeLensProvider, which disposes the event. Not quite clear why this would be observed in Theia and not Che Theia, though. Trying a fix to validate the theory.

@tsmaeder
Copy link
Contributor

While I think that the "dispose" problem above is real, it turns out the problem I'm seeing is more subtle: the cause for the code lenses not showing up is that the DocumentSelector used to register the code lense provider does not match when I open a file containing a test. This is caused by the fact that I am running the Theia back-end in Linux (Che inside crc) and the front-end on Windows. That's why it works in naked Theia, since then I'm running back-end and front end on the same file system.

The problem arises that monaco compares the currently opened file with a relative glob pattern in the DocumentSelector by using URI.fsPath, which in turn calls this method: https://github.com/microsoft/vscode/blob/90efeb4f2dc41827b382c8bb5da1c3abfff9459f/src/vs/base/common/uri.ts#L579
This results in the path separators being converted to backslashes. However, the same treatment is not done with the pattern, so the paths will not match. For example, the open file might be file:///projects/foo/bar and the pattern we match might be /projects/foo/bar, but we'll end up comparing \projects\foo\barwith /projects/foo/bar, which obviously fails.
On VS Code this does not arise, since they're always running on the same machine.

@tsmaeder
Copy link
Contributor

The problem loading the "pass", "running", etc. icons is that the front end is trying to load an icon with an URI like this: https://routeij17ga9z-che.apps-crc.testing/hostedPlugin/vscode-java-test/resources/media/dark/pass.svg. This kind of icon is resolved locally to the Theia back end process in https://github.com/eclipse-theia/theia/blob/dfcfccc1d4cfa86534419dd28dfe86faab2c494b/packages/plugin-ext/src/hosted/node/plugin-reader.ts#L51. However, the icon would have to be read from the container running the plugin and there are no provisions for forwarding the request to the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/languages Issues related to Language extensions or plugins integration. kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P2 Has a minor but important impact to the usage or development of the system.
Projects
None yet
Development

No branches or pull requests

7 participants