Repository navigation
Improve the perf of functional tests running with real jupyter #10242
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6893530
Improve the perf of subsequent tests by caching interpreters
rchiodo cb7516e
Add back the nightly flake
rchiodo 830a430
Remove coverage
rchiodo fafb47a
Add news entry
rchiodo 2b3376b
Use a static map to allow promise to be cleared on new interpreters (…
rchiodo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ./out/test/**/*.functional.test.js | ||
| --require=out/test/unittests.js | ||
| --exclude=out/**/*.jsx | ||
| --ui=tdd | ||
| --recursive | ||
| --colors | ||
| --exit | ||
| --timeout=180000 | ||
| --reporter spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # Nightly build | ||
|
|
||
| name: '$(Year:yyyy).$(Month).0.$(BuildID)-nightly-flake' | ||
|
|
||
| # Not the CI build, see `vscode-python-nightly-flake-ci.yaml`. | ||
| trigger: none | ||
|
|
||
| # Not the PR build for merges to master and release. | ||
| pr: none | ||
|
|
||
| schedules: | ||
| - cron: "0 8 * * 1-5" | ||
| # Daily midnight PST build, runs Monday - Friday always | ||
| displayName: Nightly Flake build | ||
| branches: | ||
| include: | ||
| - master | ||
| - release* | ||
| always: true | ||
|
|
||
| # Variables that are available for the entire pipeline. | ||
| variables: | ||
| - template: templates/globals.yml | ||
|
|
||
| stages: | ||
| - stage: Build | ||
| jobs: | ||
| - template: templates/jobs/build_compile.yml | ||
|
|
||
| # Each item in each matrix has a number of possible values it may | ||
| # define. They are detailed in templates/test_phases.yml. The only | ||
| # required value is "TestsToRun". | ||
|
|
||
| - stage: Linux | ||
| dependsOn: | ||
| - Build | ||
| jobs: | ||
| - job: 'Py3x' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'ubuntu-16.04' | ||
| steps: | ||
| - template: templates/test_phases.yml | ||
|
|
||
| - job: 'Py36' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| PythonVersion: '3.6' | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'ubuntu-16.04' | ||
| steps: | ||
| - template: templates/test_phases.yml | ||
|
|
||
| - stage: Mac | ||
| dependsOn: | ||
| - Build | ||
| jobs: | ||
| - job: 'Py3x' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'macos-10.13' | ||
| steps: | ||
| - template: templates/test_phases.yml | ||
|
|
||
| - job: 'Py36' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| PythonVersion: '3.6' | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'macos-10.13' | ||
| steps: | ||
| - template: templates/test_phases.yml | ||
|
|
||
| - stage: Windows | ||
| dependsOn: | ||
| - Build | ||
| jobs: | ||
| - job: 'Py3x' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'vs2017-win2016' | ||
| steps: | ||
| - template: templates/test_phases.yml | ||
|
|
||
| - job: 'Py36' | ||
| dependsOn: [] | ||
| timeoutInMinutes: 120 | ||
| strategy: | ||
| matrix: | ||
| 'Functional': | ||
| PythonVersion: '3.6' | ||
| TestsToRun: 'testfunctional' | ||
| NeedsPythonTestReqs: true | ||
| NeedsPythonFunctionalReqs: true | ||
| VSCODE_PYTHON_ROLLING: true | ||
| pool: | ||
| vmImage: 'vs2017-win2016' | ||
| steps: | ||
| - template: templates/test_phases.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Functional tests using real jupyter can take 30-90 seconds each. Most of this time is searching for interpreters. Cache the interpreter search. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import { | |
| Event, | ||
| EventEmitter, | ||
| FileSystemWatcher, | ||
| Memento, | ||
| Uri, | ||
| WorkspaceConfiguration, | ||
| WorkspaceFolder, | ||
|
|
@@ -99,7 +100,6 @@ import { | |
| } from '../../client/common/installer/productPath'; | ||
| import { ProductService } from '../../client/common/installer/productService'; | ||
| import { IInstallationChannelManager, IProductPathService, IProductService } from '../../client/common/installer/types'; | ||
| import { PersistentStateFactory } from '../../client/common/persistentState'; | ||
| import { IS_WINDOWS } from '../../client/common/platform/constants'; | ||
| import { PathUtils } from '../../client/common/platform/pathUtils'; | ||
| import { RegistryImplementation } from '../../client/common/platform/registry'; | ||
|
|
@@ -130,6 +130,7 @@ import { | |
| } from '../../client/common/terminal/types'; | ||
| import { | ||
| BANNER_NAME_LS_SURVEY, | ||
| GLOBAL_MEMENTO, | ||
| IAsyncDisposableRegistry, | ||
| IConfigurationService, | ||
| ICryptoUtils, | ||
|
|
@@ -139,12 +140,14 @@ import { | |
| IExtensionContext, | ||
| IExtensions, | ||
| IInstaller, | ||
| IMemento, | ||
| IOutputChannel, | ||
| IPathUtils, | ||
| IPersistentStateFactory, | ||
| IPythonExtensionBanner, | ||
| IsWindows, | ||
| ProductType | ||
| ProductType, | ||
| WORKSPACE_MEMENTO | ||
| } from '../../client/common/types'; | ||
| import { Deferred, sleep } from '../../client/common/utils/async'; | ||
| import { noop } from '../../client/common/utils/misc'; | ||
|
|
@@ -333,6 +336,7 @@ import { MockWorkspaceConfiguration } from './mockWorkspaceConfig'; | |
| import { blurWindow, createMessageEvent } from './reactHelpers'; | ||
| import { TestInteractiveWindowProvider } from './testInteractiveWindowProvider'; | ||
| import { TestNativeEditorProvider } from './testNativeEditorProvider'; | ||
| import { TestPersistentStateFactory } from './testPersistentStateFactory'; | ||
|
|
||
| export class DataScienceIocContainer extends UnitTestIocContainer { | ||
| public webPanelListener: IWebPanelMessageListener | undefined; | ||
|
|
@@ -914,7 +918,15 @@ export class DataScienceIocContainer extends UnitTestIocContainer { | |
| IInterpreterVersionService, | ||
| InterpreterVersionService | ||
| ); | ||
| this.serviceManager.addSingleton<IPersistentStateFactory>(IPersistentStateFactory, PersistentStateFactory); | ||
|
|
||
| const globalStorage = this.serviceManager.get<Memento>(IMemento, GLOBAL_MEMENTO); | ||
| const localStorage = this.serviceManager.get<Memento>(IMemento, WORKSPACE_MEMENTO); | ||
|
|
||
| // Create a custom persistent state factory that remembers specific things between tests | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems kinda risky, hope this doesn't break anything. Guess we'll find out in our tests. |
||
| this.serviceManager.addSingletonInstance<IPersistentStateFactory>( | ||
| IPersistentStateFactory, | ||
| new TestPersistentStateFactory(globalStorage, localStorage) | ||
| ); | ||
| this.serviceManager.addSingletonInstance<IInterpreterDisplay>(IInterpreterDisplay, interpreterDisplay.object); | ||
|
|
||
| this.serviceManager.addSingleton<IPythonPathUpdaterServiceFactory>( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { Memento } from 'vscode'; | ||
| import { PersistentStateFactory } from '../../client/common/persistentState'; | ||
| import { IPersistentState, IPersistentStateFactory } from '../../client/common/types'; | ||
|
|
||
| const PrefixesToStore = ['INTERPRETERS_CACHE']; | ||
|
|
||
| // tslint:disable-next-line: no-any | ||
| const persistedState = new Map<string, any>(); | ||
|
|
||
| class TestPersistentState<T> implements IPersistentState<T> { | ||
| constructor(private key: string, defaultValue?: T | undefined) { | ||
| if (defaultValue) { | ||
| persistedState.set(key, defaultValue); | ||
| } | ||
| } | ||
| public get value(): T { | ||
| return persistedState.get(this.key); | ||
| } | ||
| public async updateValue(value: T): Promise<void> { | ||
| persistedState.set(this.key, value); | ||
| } | ||
| } | ||
|
|
||
| // This class is used to make certain values persist across tests. | ||
| export class TestPersistentStateFactory implements IPersistentStateFactory { | ||
| private realStateFactory: PersistentStateFactory; | ||
| constructor(globalState: Memento, localState: Memento) { | ||
| this.realStateFactory = new PersistentStateFactory(globalState, localState); | ||
| } | ||
|
|
||
| public createGlobalPersistentState<T>( | ||
| key: string, | ||
| defaultValue?: T | undefined, | ||
| expiryDurationMs?: number | undefined | ||
| ): IPersistentState<T> { | ||
| if (PrefixesToStore.find(p => key.startsWith(p))) { | ||
| return new TestPersistentState(key, defaultValue); | ||
| } | ||
|
|
||
| return this.realStateFactory.createGlobalPersistentState(key, defaultValue, expiryDurationMs); | ||
| } | ||
| public createWorkspacePersistentState<T>( | ||
| key: string, | ||
| defaultValue?: T | undefined, | ||
| expiryDurationMs?: number | undefined | ||
| ): IPersistentState<T> { | ||
| if (PrefixesToStore.find(p => key.startsWith(p))) { | ||
| return new TestPersistentState(key, defaultValue); | ||
| } | ||
|
|
||
| return this.realStateFactory.createWorkspacePersistentState(key, defaultValue, expiryDurationMs); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these checking for Array here specifically? If there was a refactor where .getCachedInterpreters returned a class wrapping the array list of Interpreters we would want to return that.