Added more logging for python installation and remove dup test in the other suite (#5106)

This commit is contained in:
Yurong He
2019-04-18 11:24:12 -07:00
committed by GitHub
parent 6222d8c977
commit a2a5fe3bee

View File

@@ -7,35 +7,15 @@
import * as should from 'should';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import * as tempWrite from 'temp-write';
import * as assert from 'assert';
import 'mocha';
import { JupyterController } from '../jupyter/jupyterController';
import { INotebook, CellTypes } from '../contracts/content';
import JupyterServerInstallation from '../jupyter/jupyterServerInstallation';
describe('Notebook Extension Integration Tests', function () {
describe('Notebook Extension Python Installation', function () {
this.timeout(600000);
let expectedNotebookContent: INotebook = {
cells: [{
cell_type: CellTypes.Code,
source: '1+1',
metadata: { language: 'python' },
execution_count: 1
}],
metadata: {
'kernelspec': {
'name': 'pyspark3kernel',
'display_name': 'PySpark3'
}
},
nbformat: 4,
nbformat_minor: 2
};
let installComplete = false;
let pythonInstallDir = process.env.PYTHON_TEST_PATH;
let jupyterController: JupyterController;
@@ -46,41 +26,26 @@ describe('Notebook Extension Integration Tests', function () {
while (true) {
notebookExtension = vscode.extensions.getExtension('Microsoft.notebook');
if (notebookExtension && notebookExtension.isActive) {
console.log('Microsoft.notebook is active');
break;
} else {
console.log('Microsoft.notebook is not active');
await new Promise(resolve => { setTimeout(resolve, 1000); });
}
}
jupyterController = notebookExtension.exports.getJupyterController() as JupyterController;
console.log('Start Jupyter Installation');
await jupyterController.jupyterInstallation.startInstallProcess(false, pythonInstallDir);
installComplete = true;
console.log('Jupyter Installation is done');
});
it('Should connect to local notebook server with result 2', async function () {
it('Verify Python Installation', async function () {
should(installComplete).be.true('Python setup did not complete.');
let jupyterPath = JupyterServerInstallation.getPythonInstallPath(jupyterController.jupyterInstallation.apiWrapper);
console.log(`Expected python path: '${pythonInstallDir}'; actual: '${jupyterPath}'`);
should(JupyterServerInstallation.getPythonInstallPath(jupyterController.jupyterInstallation.apiWrapper)).be.equal(pythonInstallDir);
let pythonNotebook = Object.assign({}, expectedNotebookContent, { metadata: { kernelspec: { name: 'python3', display_name: 'Python 3' } } });
let uri = writeNotebookToFile(pythonNotebook);
let notebook = await azdata.nb.showNotebookDocument(uri);
should(notebook.document.cells).have.length(1);
let ran = await notebook.runCell(notebook.document.cells[0]);
should(ran).be.true('Notebook runCell failed');
let cellOutputs = notebook.document.cells[0].contents.outputs;
should(cellOutputs).have.length(1);
let result = (<azdata.nb.IExecuteResult>cellOutputs[0]).data['text/plain'];
should(result).equal('2');
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
});
});
function writeNotebookToFile(pythonNotebook: INotebook): vscode.Uri {
let notebookContentString = JSON.stringify(pythonNotebook);
let localFile = tempWrite.sync(notebookContentString, 'notebook.ipynb');
let uri = vscode.Uri.file(localFile);
return uri;
}