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

Fix random failures on functional tests #14331

Merged
merged 10 commits into from
Oct 8, 2020
Merged

Conversation

rchiodo
Copy link

@rchiodo rchiodo commented Oct 8, 2020

For https://github.com/microsoft/vscode-python/issues/14290

Root cause was the port used by the kernels were overlapping.

Fixed this by using a file to keep track of ports in use (poor man's named mutex). File is cleaned up on exit and not disposed as dispose would be called in between each test.

Also added a python file to parse test log files. It has the following parameters:

--testoutput - parses the log looking for test lines (they all have ansi coloring) and prints them
--split - splits the testoutput file into multiple files based on process ids logged so you can debug test failures that are in parallel

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@rchiodo rchiodo self-assigned this Oct 8, 2020
@@ -45,7 +45,7 @@
"source.fixAll.eslint": true,
"source.fixAll.tslint": true
},
"python.languageServer": "Microsoft",
"python.languageServer": "Pylance",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to change this in the PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh probably not. I'll put it back

@codecov-io
Copy link

codecov-io commented Oct 8, 2020

Codecov Report

Merging #14331 into main will increase coverage by 0.13%.
The diff coverage is 63.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #14331      +/-   ##
==========================================
+ Coverage   59.75%   59.88%   +0.13%     
==========================================
  Files         697      709      +12     
  Lines       38649    39339     +690     
  Branches     5577     5700     +123     
==========================================
+ Hits        23094    23559     +465     
- Misses      14364    14539     +175     
- Partials     1191     1241      +50     
Impacted Files Coverage Δ
src/client/activation/common/activatorBase.ts 14.41% <0.00%> (+1.19%) ⬆️
...rc/client/activation/jedi/multiplexingActivator.ts 17.74% <0.00%> (ø)
src/client/activation/node/languageServerProxy.ts 26.58% <0.00%> (ø)
src/client/activation/refCountedLanguageServer.ts 41.30% <0.00%> (ø)
src/client/activation/types.ts 100.00% <ø> (ø)
src/client/common/process/baseDaemon.ts 21.76% <0.00%> (-0.53%) ⬇️
src/client/common/process/pythonDaemon.ts 14.28% <0.00%> (ø)
src/client/common/utils/localize.ts 96.24% <ø> (ø)
src/client/datascience/baseJupyterSession.ts 57.33% <ø> (+0.52%) ⬆️
.../datascience/interactive-common/interactiveBase.ts 5.78% <0.00%> (+<0.01%) ⬆️
... and 83 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c248197...688fb58. Read the comment docs.

@@ -49,18 +96,28 @@ export class KernelLauncher implements IKernelLauncher {
return kernelProcess;
}

private async getKernelConnection(): Promise<IKernelConnection> {
private async getPorts(): Promise<number[]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really minor, but maybe not the exact same name as the portfinder function that we are using? Or change the other one to portfinderGetPorts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@@ -177,14 +177,20 @@ export abstract class BasePythonDaemon {
return Object.keys(options).every((item) => daemonSupportedSpawnOptions.indexOf(item as any) >= 0);
}
protected sendRequestWithoutArgs<R, E, RO>(type: RequestType0<R, E, RO>): Thenable<R> {
return Promise.race([this.connection.sendRequest(type), this.connectionClosedDeferred.promise]);
if (this.proc && this.proc.exitCode === null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (this.proc && this.proc.exitCode === null) {
if (this.proc && typeof this.proc.exitCode !== 'number') {

Else if we have undefined, then above condition doesn't work. I feel that's better than hardcoding null.
Optional change requets

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api says it returns a number or null. Never undefined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just that usage of null is frowned upon & comparing against null isn't a good practice either.
I guess its old code that they can't remove..

public static async cleanupStartPort() {
try {
// Destroy the file
const port = await KernelLauncher.startPortPromise;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like this.
I thought we decided we'd only use such code for the tests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, all good, I can see it is

from pathlib import Path
import re

parser = argparse.ArgumentParser(description="Parse a test log into its parts")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logParser? Or the args?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is used (I mentioned it in the PR description) to split a test output file into synchronized parts so you can debug it.

@sonarcloud
Copy link

sonarcloud bot commented Oct 8, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rchiodo rchiodo merged commit 1a6aa56 into main Oct 8, 2020
@rchiodo rchiodo deleted the rchiodo/unmounted_test_failure branch October 8, 2020 23:33
luabud pushed a commit to luabud/vscode-python that referenced this pull request Oct 26, 2020
* Splitting test log

* Fix problem with kernels ports being reused

* Make kernel launcher port round robin only for testing

* Make formatters change only apply during testing

* Add news entry

* Apply black formatting

* Code review feedback and skip flakey remote password test

* Another flakey test

* More CR feedback

* Missed a spot
DonJayamanne pushed a commit that referenced this pull request Oct 30, 2020
* Fix two problems with escaping (#14228)

* Remove unneeded cell keys when exporting (#14241)

* Remove transient output when exporting from the interactive window

* Add news entry

* Test was failing with true jupyter (#14261)

* Potential fix for ipywidget flakiness (#14281)

* Try running tests with space in root path (#14113)

* Add test with a space (only works on flake)

* Push to insiders.yml only

* Remove test that doesn't really do anything

* REmove unused bits

* Change path to have unicode too

* Get test to run

* Set root path differently

* Valid dir

* A different way

* Another way

* Try creating the directory first

* Another try

* Only one env

* Pass parameters correctly

* Try without unicode

* Set working directory directly on xvfb actions

* Working-directory not workingDirectory

* Cached ts files output

* Remove test with space branch for insiders

* Update vscode-python-pr-validation.yaml (#14285)

REmove missing branch? Might make it work again

* Get rid of AZDO yamls. Not used anymore

* Dont run on push (#14307)

* Fix random failures on functional tests (#14331)

* Splitting test log

* Fix problem with kernels ports being reused

* Make kernel launcher port round robin only for testing

* Make formatters change only apply during testing

* Add news entry

* Apply black formatting

* Code review feedback and skip flakey remote password test

* Another flakey test

* More CR feedback

* Missed a spot

* More of the functional tests are failing (#14346)

* Splitting test log

* Fix problem with kernels ports being reused

* Make kernel launcher port round robin only for testing

* Make formatters change only apply during testing

* Add news entry

* Apply black formatting

* Code review feedback and skip flakey remote password test

* Another flakey test

* More CR feedback

* Missed a spot

* Some more log parser changes and try to get interrupt to be less flakey

* Fix interrupt killing kernel and add more logging for export

* More logging

* See if updating fixes the problem

* Dont delete temp files

* Upload webview output to figure out trust failure

* Add name to step

* Try another way to upload

* Upload doesn't seem to work

* Try a different way to upload

* Try without webview logging as this makes the test pass

* Try fixing test another way. Any logging is making the test pass

* Compile error

* Add more logging to figure out why raw kernel did not start (#14374)

* Some more logging

* Some more logging

* Move PR changes into pr.yml

* Fix multiprocessing problems with setting __file__ (#14376)

* Fix multiprocessing problems with setting __file__

* Update news entry

* Problem with wait for idle not propagating outwards

* Fix unnecessary ask for python extension install

* Don't error on warning for kernel install
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.

4 participants