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

Test Run Error When Using Latest Zowe Extension Version #3277

Open
sujatha2206 opened this issue Oct 25, 2024 · 18 comments
Open

Test Run Error When Using Latest Zowe Extension Version #3277

sujatha2206 opened this issue Oct 25, 2024 · 18 comments
Labels
bug Something isn't working needs more info

Comments

@sujatha2206
Copy link

sujatha2206 commented Oct 25, 2024

Describe the bug

I am creating a test setup for my extension.My extension depends on the Zowe Explorer extension. When I use zowe: [email protected], my tests run successfully. However, when I use the latest version, the tests do not run, and I receive the following error:

Failed to run tests: TestRunFailedError: Test run failed with code 1 at ChildProcess.onProcessClosed (C:\Users\ctron\out\runTest.js:110:24)

To Reproduce

Steps to Reproduce the Behavior:

Go to the extension(IBM ZopenDebug) that depends on the Zowe extension.
Create a test setup using VS Code APIs: @vscode/test-cli and @vscode/test-electron (see: Testing Extensions).
Run: npm run test, whether using the test CLI or the advanced runner.
Observe the error: Failed to run tests: TestRunFailedError: Test run failed with code 1 at ChildProcess.onProcessClosed (C:\Users\ctron\out\runTest.js:110:24).

Expected behavior

The test cases should run successfully.

Screenshots
image

Desktop (please complete the following information):

  • OS:Windows
  • Zowe Explorer Version:3.2.0
  • (Optional) Zowe CLI Version:
  • (Optional) Are you using Secure Credential Store?
Copy link

Thank you for creating a bug report.
We will investigate the bug and evaluate its impact on the product.
If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.

@sujatha2206
Copy link
Author

Let me know If you need any further information

@traeok
Copy link
Member

traeok commented Oct 30, 2024

Hi @sujatha2206,

Thanks for the bug report. I have a couple questions before moving forward with reproducing the issue:

  1. Has your extension been updated to support Zowe Explorer v3? If your extension can run tests successfully alongside Zowe Explorer v2.18.0, but the same extension version fails with v3, you might need to update your extension to be compatible with v3. See this wiki page for more information on how to upgrade to v3: https://github.com/zowe/zowe-explorer-vscode/wiki/v3-Changes-for-Users-and-Extenders
  2. In the attached error message, I see two errors coming from VS Code. Can you try passing the arguments mentioned in the errors to VS Code (as part of your test command) so that we can get more context on the error?
    --trace-deprecation
    --force-node-api-uncaught-exceptions-policy=true

Thanks!

@sujatha2206
Copy link
Author

Hi @traeok
1.My extension updated to latest zowe version,my development environment is working fine.
2. I have added the arguments, but it still started the VSCode instance and then exited immediately.
image

@traeok
Copy link
Member

traeok commented Oct 30, 2024

Thanks for the quick follow up. I'm working on reproducing this issue with a sample extension and will move forward from there.

One more quick question: Do you happen to have Zowe v1 profiles in place for your project, but without an available team config? It's possible that Zowe Explorer is reloading the window to handle an upgrade scenario from v1 -> v3 - unfortunately this can't be avoided since a reload is needed when upgrading from v1 to v3, but it's one possible reason why the extension is exiting. If this is the case, I would recommend setting up a team config and removing your v1 profiles to avoid this reload.

@sujatha2206
Copy link
Author

sujatha2206 commented Oct 30, 2024

Thanks for your quick response, I am working on testing my extension, but initially, it opens the VSCode instance and then immediately closes. If this is a profile issue, how is our development working fine?

Note: My initial test case only involves getting the Zowe extension. If this were a profile issue, at least the first test case should run, right?

@traeok
Copy link
Member

traeok commented Oct 30, 2024

Sorry if I've caused any confusion - the reason I mention this is because in Zowe Explorer, we do a reload of the window if a user is migrating from v1 to v3. This can be triggered when we detect v1 profiles, but no team configuration was detected and a v1 setting is present in your VS Code environment.

Given the additional context (that your test case involves getting the Zowe extension), this may not be the cause of the issue. I'm actively working on reproducing the issue and will follow up with my results. Thanks!

@sujatha2206
Copy link
Author

sujatha2206 commented Oct 30, 2024

Thanks,But we don't have v1 profiles,profiles are being defined in team config,

@traeok
Copy link
Member

traeok commented Oct 30, 2024

@sujatha2206, quick question for clarification: does your extension depend on Zowe Explorer? or does it try to download Zowe Explorer when not installed?

When testing with an extension that depends on Zowe Explorer, I'm able to run tests alongside Zowe Explorer v3. I used the helloworld-test-example extension from VS Code's extension samples and added a line that prints the registered API types from Zowe Explorer API. When running the tests, I see the message that I added, my extension activates alongside Zowe Explorer and the test is successful.

const zeApi = vscode.extensions.getExtension("Zowe.vscode-extension-for-zowe")?.exports as Types.IApiRegisterClient;
vscode.window.showInformationMessage(zeApi.registeredApiTypes().join(" "));

Here's the notification in action, beside the "Start all tests" message in the sample test:
image

Here's the sample test, for reference:

suite('Extension Test Suite', () => {
	vscode.window.showInformationMessage('Start all tests.');

	test('Sample test', async () => {
		assert.strictEqual([1, 2, 3].indexOf(5), -1);
		assert.strictEqual([1, 2, 3].indexOf(0), -1);
                // sleep for 1sec so I can take a screenshot of the info messages
		await new Promise((resolve, _reject) => setTimeout(() => resolve(null), 1000));
	});
});

@sujatha2206
Copy link
Author

Our extension depends on zowe explorer.

@traeok
Copy link
Member

traeok commented Oct 30, 2024

I can push the modified sample extension to a personal repo, if you'd like to test how the VS Code test CLI behaves with the sample on your machine. As it currently stands, I'm unable to reproduce the error when using a sample extension that depends on Zowe Explorer v3 - I'm able to grab its exported API and use it as normal, as well as running its tests after it initializes. Maybe this is due to an unhandled error that occurs when running tests w/ the zopendebug extension during activation?

If you have any additional errors to provide from your debug console or terminal, that might help to reproduce the issue. Is it possible to add a sleep to your extension test code, in hopes of catching any additional errors in the VS Code window before it fails and exits?

@sujatha2206
Copy link
Author

Thanks I will look into it.please share a sample extension to my personal repo

@traeok
Copy link
Member

traeok commented Oct 30, 2024

Thanks I will look into it.please share a sample extension to my personal repo

Here is a commit with helloworld-test-sample updated to import and use ZE API: traeok/vscode-ext-samples@535b54d

If you clone the test-sample branch in this repo, you can try building the sample and running its tests:

git clone https://github.com/traeok/vscode-ext-samples.git -b test-sample
cd vscode-ext-samples/helloworld-test-sample
npm install && npm run compile && npm run test

@sujatha2206
Copy link
Author

@traeok one question If it is unhandled error how does it works in zowe 2.18 version

@traeok
Copy link
Member

traeok commented Oct 30, 2024

@sujatha2206,

If you are accessing the Zowe Explorer API using similar logic to the sample above, you should be able to use the API without issue, regardless of what Zowe Explorer version is installed. It's possible that logic during your extension's activation causes an issue with v3, specifically when running tests, but its not clear without additional context (such as a snippet of activation logic that uses the Zowe Explorer API).

If possible, please provide steps to reproduce the bug outside of the context of your extension. From my testing, I am unable to reproduce the issue with the sample Zowe Explorer extender. If I change the type import in the above sample to be compatible with v2 of Zowe Explorer API, the extension tests also pass with Zowe Explorer v2.18, suggesting that it could be an extension-specific issue.

@sujatha2206
Copy link
Author

sujatha2206 commented Oct 30, 2024

@traeok I have now disabled the Zowe extension, and I can see that some of my test cases are successful. This may be an integration issue with my extension and Zowe.
We will look into it.

@traeok
Copy link
Member

traeok commented Nov 7, 2024

Hi @sujatha2206,

I was just wondering if you had an update on whether you resolved your extension integration issue with Zowe Explorer v3?

Thanks!

@sujatha2206
Copy link
Author

HI @traeok issue is not resolved yet, we are still investigating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs more info
Projects
Status: New Issues
Development

No branches or pull requests

3 participants