@@ -280,6 +280,7 @@ suite('Jupyter Execution', async () => {
280
280
} ) ;
281
281
282
282
teardown ( ( ) => {
283
+ reset ( fileSystem ) ;
283
284
return cleanupDisposables ( ) ;
284
285
} ) ;
285
286
@@ -439,7 +440,7 @@ suite('Jupyter Execution', async () => {
439
440
. returns ( ( ) => result ) ;
440
441
}
441
442
442
- function setupWorkingPythonService ( service : TypeMoq . IMock < IPythonExecutionService > , notebookStdErr ?: string [ ] ) {
443
+ function setupWorkingPythonService ( service : TypeMoq . IMock < IPythonExecutionService > , notebookStdErr ?: string [ ] , runInDocker ?: boolean ) {
443
444
setupPythonService ( service , 'ipykernel' , [ '--version' ] , Promise . resolve ( { stdout : '1.1.1.1' } ) ) ;
444
445
setupPythonService ( service , 'jupyter' , [ 'nbconvert' , '--version' ] , Promise . resolve ( { stdout : '1.1.1.1' } ) ) ;
445
446
setupPythonService ( service , 'jupyter' , [ 'notebook' , '--version' ] , Promise . resolve ( { stdout : '1.1.1.1' } ) ) ;
@@ -462,8 +463,8 @@ suite('Jupyter Execution', async () => {
462
463
const getServerInfoPath = path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' , 'datascience' , 'getServerInfo.py' ) ;
463
464
setupPythonService ( service , undefined , [ getServerInfoPath ] , Promise . resolve ( { stdout : 'failure to get server infos' } ) ) ;
464
465
setupPythonServiceExecObservable ( service , 'jupyter' , [ 'kernelspec' , 'list' ] , [ ] , [ ] ) ;
465
- setupPythonServiceExecObservable ( service , 'jupyter' , [ 'notebook' , '--no-browser ', / - - n o t e b o o k - d i r = . * / , / - - c o n f i g = . * / , '--NotebookApp.iopub_data_rate_limit=10000000000.0' ] , [ ] , notebookStdErr ? notebookStdErr : [ 'http://localhost:8888/?token=198' ] ) ;
466
-
466
+ const dockerArgs = runInDocker ? [ '--ip ', '127.0.0.1' ] : [ ] ;
467
+ setupPythonServiceExecObservable ( service , 'jupyter' , [ 'notebook' , '--no-browser' , / - - n o t e b o o k - d i r = . * / , / - - c o n f i g = . * / , '--NotebookApp.iopub_data_rate_limit=10000000000.0' , ... dockerArgs ] , [ ] , notebookStdErr ? notebookStdErr : [ 'http://localhost:8888/?token=198' ] ) ;
467
468
}
468
469
469
470
function setupMissingKernelPythonService ( service : TypeMoq . IMock < IPythonExecutionService > , notebookStdErr ?: string [ ] ) {
@@ -528,6 +529,9 @@ suite('Jupyter Execution', async () => {
528
529
}
529
530
530
531
function createExecution ( activeInterpreter : PythonInterpreter , notebookStdErr ?: string [ ] , skipSearch ?: boolean ) : JupyterExecutionFactory {
532
+ return createExecutionAndReturnProcessService ( activeInterpreter , notebookStdErr , skipSearch ) . jupyterExecutionFactory ;
533
+ }
534
+ function createExecutionAndReturnProcessService ( activeInterpreter : PythonInterpreter , notebookStdErr ?: string [ ] , skipSearch ?: boolean , runInDocker ?: boolean ) : { workingPythonExecutionService : TypeMoq . IMock < IPythonExecutionService > ; jupyterExecutionFactory : JupyterExecutionFactory } {
531
535
// Setup defaults
532
536
when ( interpreterService . onDidChangeInterpreter ) . thenReturn ( dummyEvent . event ) ;
533
537
when ( interpreterService . getActiveInterpreter ( ) ) . thenResolve ( activeInterpreter ) ;
@@ -536,10 +540,12 @@ suite('Jupyter Execution', async () => {
536
540
when ( interpreterService . getInterpreterDetails ( match ( '/foo/baz/python.exe' ) ) ) . thenResolve ( missingKernelPython ) ;
537
541
when ( interpreterService . getInterpreterDetails ( match ( '/bar/baz/python.exe' ) ) ) . thenResolve ( missingNotebookPython ) ;
538
542
when ( interpreterService . getInterpreterDetails ( argThat ( o => ! o . includes || ! o . includes ( 'python' ) ) ) ) . thenReject ( 'Unknown interpreter' ) ;
539
-
543
+ if ( runInDocker ) {
544
+ when ( fileSystem . readFile ( '/proc/self/cgroup' ) ) . thenResolve ( 'hello docker world' ) ;
545
+ }
540
546
// Create our working python and process service.
541
547
const workingService = createTypeMoq < IPythonExecutionService > ( 'working' ) ;
542
- setupWorkingPythonService ( workingService , notebookStdErr ) ;
548
+ setupWorkingPythonService ( workingService , notebookStdErr , runInDocker ) ;
543
549
const missingKernelService = createTypeMoq < IPythonExecutionService > ( 'missingKernel' ) ;
544
550
setupMissingKernelPythonService ( missingKernelService , notebookStdErr ) ;
545
551
const missingNotebookService = createTypeMoq < IPythonExecutionService > ( 'missingNotebook' ) ;
@@ -686,6 +692,19 @@ suite('Jupyter Execution', async () => {
686
692
await assert . isFulfilled ( execution . connectToNotebookServer ( ) , 'Should be able to start a server' ) ;
687
693
} ) . timeout ( 10000 ) ;
688
694
695
+ test ( 'Includes correct args for running in docker' , async ( ) => {
696
+ const { workingPythonExecutionService, jupyterExecutionFactory} = createExecutionAndReturnProcessService ( workingPython , undefined , undefined , true ) ;
697
+ when ( executionFactory . createDaemon ( deepEqual ( { daemonModule : PythonDaemonModule , pythonPath : workingPython . path } ) ) ) . thenResolve ( workingPythonExecutionService . object ) ;
698
+
699
+ await assert . eventually . equal ( jupyterExecutionFactory . isNotebookSupported ( ) , true , 'Notebook not supported' ) ;
700
+ await assert . eventually . equal ( jupyterExecutionFactory . isImportSupported ( ) , true , 'Import not supported' ) ;
701
+ await assert . eventually . equal ( jupyterExecutionFactory . isKernelSpecSupported ( ) , true , 'Kernel Spec not supported' ) ;
702
+ await assert . eventually . equal ( jupyterExecutionFactory . isKernelCreateSupported ( ) , true , 'Kernel Create not supported' ) ;
703
+ const usableInterpreter = await jupyterExecutionFactory . getUsableJupyterPython ( ) ;
704
+ assert . isOk ( usableInterpreter , 'Usable interpreter not found' ) ;
705
+ await assert . isFulfilled ( jupyterExecutionFactory . connectToNotebookServer ( ) , 'Should be able to start a server' ) ;
706
+ } ) . timeout ( 10000 ) ;
707
+
689
708
test ( 'Failing notebook throws exception' , async ( ) => {
690
709
const execution = createExecution ( missingNotebookPython ) ;
691
710
when ( interpreterService . getInterpreters ( ) ) . thenResolve ( [ missingNotebookPython ] ) ;
0 commit comments