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

Ability to run tests of a vscode extension on top of che-theia #18219

Closed
benoitf opened this issue Oct 27, 2020 · 18 comments
Closed

Ability to run tests of a vscode extension on top of che-theia #18219

benoitf opened this issue Oct 27, 2020 · 18 comments
Assignees
Labels
area/plugins kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. severity/P2 Has a minor but important impact to the usage or development of the system.

Comments

@benoitf
Copy link
Contributor

benoitf commented Oct 27, 2020

Is your task related to a problem? Please describe.

A VS Code extension can declare some tests that can be run usually with test script.
https://code.visualstudio.com/api/working-with-extensions/testing-extension

It would be great to be able to execute these tests on top of a Che-Theia instance to validate if the extension behaves as expected.

Describe the solution you'd like

Have a way to easily provide an extension (or a set of extensions) and grab the result of the tests.

Additional context

Some of the vscode-test module is unpacking a VS Code instance, etc so we need to be sure that it can be launched as expected on top of Che-Theia

@benoitf benoitf added kind/task Internal things, technical debt, and to-do tasks to be performed. area/editor/theia Issues related to the che-theia IDE of Che labels Oct 27, 2020
@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 27, 2020
@ericwill ericwill removed the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Oct 27, 2020
@tolusha tolusha added the severity/P2 Has a minor but important impact to the usage or development of the system. label Oct 28, 2020
@ericwill ericwill mentioned this issue Nov 12, 2020
34 tasks
@ericwill ericwill added this to the 7.23 milestone Nov 18, 2020
@azatsarynnyy azatsarynnyy added area/plugins and removed area/editor/theia Issues related to the che-theia IDE of Che labels Dec 2, 2020
@ericwill ericwill mentioned this issue Dec 3, 2020
34 tasks
@ericwill ericwill modified the milestones: 7.23, 7.24 Dec 8, 2020
@nickboldt nickboldt modified the milestones: 7.24, 7.25 Jan 8, 2021
@ericwill ericwill mentioned this issue Jan 14, 2021
33 tasks
@mbenitez1607 mbenitez1607 modified the milestones: 7.25, 7.26 Jan 18, 2021
@svor
Copy link
Contributor

svor commented Jan 21, 2021

@benoitf As you wrote in the description some extensions like helloworld-test-sample download VS Code and run the Mocha tests on it. I've made it possible to run these tests from che in VS Code instance (i've just prepared an image for that) but I don't see the reason of it.
So, am I correct that we have to override this operation to run these tests in che instance NOT in VS Code.

@benoitf
Copy link
Contributor Author

benoitf commented Jan 21, 2021

@svor yes it needs to tests within a Che instance, not VS Code (the goal is to check if tests are passing in Che, not on VS Code)

@svor
Copy link
Contributor

svor commented Jan 28, 2021

@benoitf @ericwill
Could you please take a look at this instructions which I'm trying to implement right now and please let me know if you see some concerns or problems here.

The main idea is:

  1. Start a workspace by using the devfile which includes:

    • A sidecar plugin with VSCode extension which should be tested
    • Tested extension's source code (clone into /projects)
    • New theia plugin which will collect all tests from VSCode extension, run them and build the report.

So, the devfile will be like:

apiVersion: 1.0.0
metadata:
  name: test-runner
projects:
  - name: vscode-yaml //extension which needs to be tested
    source:
      location: 'https://github.com/redhat-developer/vscode-yaml.git'
      type: git
      branch: master
  - name: vscode-extension-test-runner
    source:
      location: 'https://github.com/vscode-extension-test-runner.git'
      type: git
      branch: main
components:
  - type: chePlugin
    reference: 'https://raw.githubusercontent.com/vscode-extension-test-runner/meta.yaml'
  - id: redhat/vscode-yaml/latest
    type: chePlugin
  - id: eclipse/che-theia/next
    memoryLimit: 1024Mi
    type: cheEditor
  1. When the workspace was started, the next steps are:
    • Build VS Code extension's source code
    • Execute some registered command by the new theia plugin to collect Mocha tests and run them
    • Generate testReport file with the results

@ericwill
Copy link
Contributor

I think it's a good first step. The end goal is to automate this in a CI job, whenever a new plugin is added/updated.

1. When the workspace was started, the next steps are:
   
   * Build VS Code extension's source code
   * Execute some registered command by the new theia plugin to collect Mocha tests and run them
   * Generate testReport file with the results

I guess the tests have to be run at build time, correct?

@benoitf
Copy link
Contributor Author

benoitf commented Jan 28, 2021

@svor I would say that intermediate devfile is not so important on the goal. (detail of implementation that belongs to you)

as Eric was saying:
When I submit a change to che-theia-plugins.yaml for every new VS Code extension added or updated, I need to run the tests contained by the provided Vsix files.

so yes basically it should contain a minkube deployment, che deployment and run a custom workspace based on a devfile

When the workspace was started, the next steps are:
Build VS Code extension's source code
Execute some registered command by the new theia plugin to collect Mocha tests and run them
Generate testReport file with the results

Here it's what is uncleared to me. You may just add different parameters to a Che-Theia instance starting in "test mode" and will execute tests and exit at the end. (0 = succeed, 1 = failure) as it's done on VS Code tests.

@ericwill
Copy link
Contributor

@svor I would say that intermediate devfile is not so important on the goal. (detail of implementation that belongs to you)

I would say we could include such a devfile in the plugin registry repo, as an example for users who want to test an extension inside their Che.

@benoitf
Copy link
Contributor Author

benoitf commented Jan 28, 2021

maybe if you want to test from inside Che, you might just want to run a command

open che-theia terminal

$ che-theia test /path-to-my.vsix

or if you have source code of your extension, you could do right click / test my extension in Che

but yes I'm not against having examples

@svor
Copy link
Contributor

svor commented Jan 28, 2021

When I submit a change to che-theia-plugins.yaml for every new VS Code extension added or updated, I need to run the tests contained by the provided Vsix files.

As I know vsix files don't contain tests

@benoitf
Copy link
Contributor Author

benoitf commented Jan 28, 2021

I mean' if you change in che-theia-plugins file some extensions/vsix then we need to test these VCode extensions. And we've repository/revision to grab associated source code ( of at least one extension) or if test folder is embedded in vsix

@svor
Copy link
Contributor

svor commented Feb 2, 2021

The current status

I've created an utility Theia pluin che-vscode-extension-tests. This plug-in provides a command which collects all *.test.js files from /projects folder and runs them one by one by using mocha. Also this plug-in contains a devfile which was adapted to work with helloworld-test-sample - it is a simple VS Code extension sample which shows how to write tests.

Devfile
  apiVersion: 1.0.0
metadata:
  name: che-helloworld-test-sample
projects:
  - name: helloworld-test-sample
    source:
      location: 'https://github.com/svor/helloworld-test-sample.git'
      type: git
      branch: main
components:
  - mountSources: true
    memoryLimit: 3Gi
    type: dockerimage
    image: 'quay.io/eclipse/che-theia-dev:next'
    alias: che-dev
  - type: chePlugin
    reference: 'https://raw.githubusercontent.com/svor/che-vscode-extension-tests/main/meta.yaml'
  - id: eclipse/che-theia/next
    memoryLimit: 1024Mi
    type: cheEditor
commands:
  - name: 1. Build extension
    actions:
    - type: exec
      component: che-dev
      command: yarn && yarn compile
      workdir: ${CHE_PROJECTS_ROOT}/helloworld-test-sample
Che plug-in meta.yaml
apiVersion: v2
publisher: Red Hat
name: Smoke-Test-Plugin
version: 0.0.1
type: Theia plugin
displayName: Smoke Test Plugin
title: Smoke-Test-Plugin
description: This plug-in runs tests
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
repository: https://github.com/svor/che-vscode-extension-tests
category: Language
firstPublicationDate: "2021-01-28"
spec:
  extensions:
    - https://raw.githubusercontent.com/svor/che-vscode-extension-tests/main/che_vscode_test_theia_plugin.theia
    - https://raw.githubusercontent.com/svor/helloworld-test-sample/main/helloworld-sample-0.0.1.vsix

If start the a workspace by using this devfile, it will initialize 2 plugins: the one is VS Extension which needs to be tested and another to collect and execute tests, also it'll clone source code of the tested extension into the workspace. By executing 1.Build extension command we build the VS Code extension's source code to prepare tests files.
screenshot-che-dogfooding apps che-dev x6e0 p1 openshiftapps com-2021 02 02-15_27_48

When /projects/tested_extension/**/*test.js files were generated we can run them by using the command from utility Theia plu-gin:
screenshot-che-dogfooding apps che-dev x6e0 p1 openshiftapps com-2021 02 02-15_28_41
The result of tests execution was entered into /projects/test.log file.

TODO

The next my step is to automate this flow and run tests when some of the vsix url from che-theia-plugins.yaml will be changed. For this I need:

  • Analyze somehow which extension is going to be updated and get source's url
  • Generate a new devfile with a project from the task1, with a tested plug-in and utility plug-in to collect and run tests
  • In the workspace build the extension's source code and run tests (make it automatically).

@ericwill ericwill mentioned this issue Feb 4, 2021
35 tasks
@svor
Copy link
Contributor

svor commented Mar 3, 2021

@ericwill looks like the decision to grep tests from the extension which was cloned and built in /projects folder was wrong. Some execution of vscode API doesn't work as expected, for example vscode.extensions always returns undefined(that's why I've created an issue for that #19172), but for example vscode.workspace.* works as expected.
I've created a VSCode extension to check tests execution

apiVersion: 1.0.0
metadata:
  name: che-helloworld-test-sample
projects:
  - name: extension-tests-runner
    source:
      location: 'https://github.com/svor/extension-tests-runner.git'
      type: git
components:
  - mountSources: true
    memoryLimit: 3Gi
    type: dockerimage
    image: 'quay.io/eclipse/che-theia-dev:next'
    alias: che-dev
  - type: chePlugin
    reference: 'https://raw.githubusercontent.com/svor/extension-tests-runner/main/meta.yaml'
  - id: timonwong/shellcheck/latest
    type: chePlugin
  - id: eclipse/che-theia/next
    memoryLimit: 1024Mi
    type: cheEditor

And tried to execute the same tests from different places:

  1. From /projects/extension-tests-runner/out/test/suit/extension.test.js (Run VSCode Extension's Tests From /projects command)
  2. From the extension which is running in theia-ide container /tmp/vscode-unpacked/extension-tests-runner/out/test/suit/extension.test.js (Run VSCode Extension's Tests from extension command)

In the first case it was failed but in the second it was successfully finished.
So, needs to find another way how to execute extension's tests

@ericwill ericwill mentioned this issue Mar 18, 2021
46 tasks
@ericwill ericwill modified the milestones: 7.28, 7.29 Mar 24, 2021
@ericwill ericwill mentioned this issue Apr 8, 2021
42 tasks
@ericwill ericwill modified the milestones: 7.29, 7.30 Apr 14, 2021
@ericwill ericwill removed this from the 7.30 milestone May 4, 2021
@che-bot
Copy link
Contributor

che-bot commented Nov 4, 2021

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 4, 2021
@svor svor removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 4, 2021
@che-bot
Copy link
Contributor

che-bot commented May 3, 2022

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 3, 2022
@svor
Copy link
Contributor

svor commented May 3, 2022

/remove-lifecycle stale

@che-bot che-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 3, 2022
@che-bot
Copy link
Contributor

che-bot commented Oct 30, 2022

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 30, 2022
@svor svor removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2022
@che-bot
Copy link
Contributor

che-bot commented Apr 29, 2023

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 29, 2023
@che-bot che-bot closed this as completed May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. 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

8 participants