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

Faster ci tests #11867

Merged
merged 32 commits into from
Nov 3, 2022
Merged

Faster ci tests #11867

merged 32 commits into from
Nov 3, 2022

Conversation

DonJayamanne
Copy link
Contributor

@DonJayamanne DonJayamanne commented Nov 2, 2022

Summary

1. The goal is to have a certain set of Jobs that MUST pass for PRs

These jobs will run the following tests:

  • Tests without any @ in name of the test
  • Tests with the text @mandatory in the tests,

2. Almost all tests have been grouped into individual groups

I've added the following tags to describe each group, some of the include

  • @mandatory
    • Tests with these in their titles will always be executed in the mandatory job. expected to ALWAYS pass
    • The idea behind this is to give the author of the PR confidence about their changes.
    • E.g. if I were to update some code in README.md, then I don't need to worry about anythign at all, except for the mandatory test.
    • I have included a few basic tests into this category, such as one debugger test, one IW test, one kernel test & the like.
    • This way we don't need to run 20 kernel tests or 10 IW tests or 5 debugger test,
    • @mandatory tests are analogous to smoke tests
  • @kernelCore
    • Used to categorize tests for core functionality of kernels, starting & execution of kernels.
    • If one were to make changes to Kernel code they can focus on the mandatory tests to pass as well as Kernel tests.
    • I.e. I can ignore variable viewer, I can ignore debugger test, etc.
  • @iw - Interactive window
  • @debugger - Debugger tests
  • @webView - Web View tests, such as plot viewer
  • @lsp - Language services, such as code completion, hover provider, etc
  • @kernelPicker - Kernel Picker tests
  • @kernelInstall - Tests for installation of ipykernel, etc
  • @python - Testing actiavtion of python envs, conda, etc
  • @jupyter - Testing starting of Jupyter servers
  • @widgets - Widget tests
  • @export - Import/export tests

Todo:

  • Convert integration tests into unit tests where possible, I've converted quite a few that were unncessary
  • Remove unnecessary integration tests
  • Make the tests faster
  • Its upto each engineer to run their tests in different envionments, e.g. if we think we need to test Debugger in Web, then its upto the maintainer of that code to ensure we add a CI job for that particular environment in the matrix as follows:
          - jupyterConnection: remote
            python: python
            pythonVersion: '3.10'
            os: ubuntu-latest
            tags: '@debugger'

jupyter: [raw, local]
python: [nonConda, conda]
pythonVersion: ['3.9', '3.10']
jupyter: [raw]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its upto maintainers of the code to have different test matrices for each area
We only run all tests in zmq and run specific tests in remote, jupyter, conda, etc

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

Merging #11867 (a7c5469) into main (7d63d42) will decrease coverage by 1%.
The diff coverage is 66%.

❗ Current head a7c5469 differs from pull request most recent head 1878b02. Consider uploading reports for the commit 1878b02 to get more accurate results

@@           Coverage Diff           @@
##            main   #11867    +/-   ##
=======================================
- Coverage     63%      61%    -2%     
=======================================
  Files        490      491     +1     
  Lines      34454    34541    +87     
  Branches    5590     5600    +10     
=======================================
- Hits       21752    21265   -487     
- Misses     10635    11249   +614     
+ Partials    2067     2027    -40     
Impacted Files Coverage Δ
src/platform/interpreter/contracts.ts 100% <ø> (ø)
src/platform/api/pythonApi.ts 69% <52%> (-3%) ⬇️
src/kernels/execution/helpers.ts 62% <66%> (+1%) ⬆️
...lPythonAndRelatedNonPythonKernelSpecFinder.node.ts 71% <81%> (-4%) ⬇️
src/notebooks/controllers/controllerLoader.ts 92% <100%> (ø)
...otebooks/debugger/controllers/restartController.ts 10% <0%> (-75%) ⬇️
...ebooks/debugger/controllers/runByLineController.ts 13% <0%> (-68%) ⬇️
src/notebooks/debugger/kernelDebugAdapter.ts 20% <0%> (-65%) ⬇️
src/notebooks/debugger/protocolParser.node.ts 14% <0%> (-65%) ⬇️
src/notebooks/debugger/debuggingManager.ts 30% <0%> (-50%) ⬇️
... and 72 more

@DonJayamanne DonJayamanne force-pushed the fasterCITests branch 14 times, most recently from 592e135 to 1f96e81 Compare November 2, 2022 23:25
import { KernelProcess } from './kernelProcess.node';
import { PortAttributesProviders } from '../port/portAttributeProvider.node';

suite('kernel Launcher', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted an integration test into unit test
Plan is to do this more often where possible

} else {
const env = await api.environments.resolveEnvironment(pythonPathOrPythonId);
return this.trackResolvedEnvironment(env, false);
traceWarning(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our CI tests fail, as python env haven't loaded completely and in our test code we try to get details of virtual envs which Python hasn't yet discovered

@@ -19,7 +19,7 @@ import { disposeAllDisposables } from '../../../platform/common/helpers';
import { IShowDataViewerFromVariablePanel } from '../../../messageTypes';

/* eslint-disable @typescript-eslint/no-explicit-any, no-invalid-this */
suite('DataScience - VSCode Notebook - (DataViewer)', function () {
suite('DataScience - VSCode Notebook - (DataViewer) @webview', function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tagging all tests so we can run specific tests

@DonJayamanne DonJayamanne marked this pull request as ready for review November 3, 2022 02:24
@@ -106,6 +106,9 @@ const config = {
typeof process.env.IS_PRE_RELEASE_VERSION_OF_JUPYTER_EXTENSION === 'string'
? process.env.IS_PRE_RELEASE_VERSION_OF_JUPYTER_EXTENSION
: 'true'
),
VSC_JUPYTER_CI_TEST_GREP: JSON.stringify(
typeof process.env.VSC_JUPYTER_CI_TEST_GREP === 'string' ? process.env.VSC_JUPYTER_CI_TEST_GREP : ''
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required to get grep working for Mocha in web tests.
No way to pass env variables into Mocha, but to inject them when building.

@@ -22,7 +22,7 @@ import { JupyterVariableDataProvider } from '../../../webviews/extension-side/da
import { IDataViewer, IDataViewerDataProvider } from '../../../webviews/extension-side/dataviewer/types';
import { MockMemento } from '../../mocks/mementos';

suite('DataScience - DataViewer', () => {
suite('DataViewer', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed all of the unencessary DataScience - prefixes

}
const interpreter = isWeb()
? undefined
: await waitForCondition(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Original code was incorrect, we cannot have interpreter in web.

@@ -38,6 +39,9 @@ suite('Kernel Event', function () {
let previousDisableJupyterAutoStartValue: boolean;
this.timeout(120_000);
suiteSetup(async function () {
if (isWeb()) {
return this.skip();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not required in web

@@ -23,7 +23,7 @@ const logsDir = path.join(ExtensionRootDir, 'logs');

async function captureScreenShot(name, res) {
const screenshot = require('screenshot-desktop');
fs.ensureDirSync(path.join(logsDir, name));
fs.ensureDirSync(logsDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix

const interpreter = await waitForCondition(
() => interpreterService.getActiveInterpreter(),
defaultNotebookTestTimeout,
'Active Interpreter is undefined.2'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to try and wait for Python extension to get the actiev interpreter.
Hacky work around for Python extnesion issue microsoft/vscode-python#20147
Doesn't seem to work always, but left this here.

Also added .2 suffix to identify where where things were failing, left this here

mocha.setup({
ui: 'tdd',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
reporter: CustomReporter as any
reporter: CustomReporter as any,
grep
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can now run specific tests in VS Code web as well

pythonVersion: '3.9'
webOrDesktop: 'web'
# Mandatory tests
- jupyterConnection: remote
Copy link
Member

Choose a reason for hiding this comment

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

@DonJayamanne can you give us a deep dive of how the include works with matrix? We now have 17 jobs and it's hard to know how each job is generated by reading the matrix, include and when clauses in the steps down below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when clauses in the steps down below.

Can you give me an example if thsi

Copy link
Member

Choose a reason for hiding this comment

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

I'm referring to https:/microsoft/vscode-jupyter/pull/11867/files#diff-063ca77e012f959eba648db60e6868875fd1e70e5f5ac081193d848f8d61ef32R633 the if clauses. It's not easy to know how a job is generated (which makes it hard to troubleshoot locally)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can also go through the new job list and each owner can check whether the prior steps are required for their tests and investigate how we can simplify each job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah yes, unfortunately thats because we need different CLIs to run each test,
E.g. running web tests and running standard tests require different CLIs, see run: npm run testWebExtension

@DonJayamanne DonJayamanne force-pushed the fasterCITests branch 4 times, most recently from b387076 to 8d0262d Compare November 3, 2022 22:30
@DonJayamanne DonJayamanne enabled auto-merge (squash) November 3, 2022 22:55
@DonJayamanne DonJayamanne merged commit 5ee34a0 into main Nov 3, 2022
@DonJayamanne DonJayamanne deleted the fasterCITests branch November 3, 2022 23:01
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