Skip to content

Commit 2303e98

Browse files
authored
Fix nightly failures for remote and new registration test. (microsoft#13289)
* Fix nightly failures for remote and new registration test. * Fix unit test failure from using new method * Fix hygiene
1 parent cdf55e9 commit 2303e98

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/client/datascience/jupyter/jupyterSession.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33
'use strict';
44
import type { ContentsManager, Kernel, ServerConnection, Session, SessionManager } from '@jupyterlab/services';
5+
import * as path from 'path';
56
import * as uuid from 'uuid/v4';
67
import { CancellationToken } from 'vscode-jsonrpc';
78
import { Cancellation } from '../../common/cancellation';
@@ -136,8 +137,12 @@ export class JupyterSession extends BaseJupyterSession {
136137
contentsManager: ContentsManager,
137138
cancelToken?: CancellationToken
138139
): Promise<ISessionWithSocket> {
139-
// Create a temporary notebook for this session.
140-
const backingFile = await contentsManager.newUntitled({ type: 'notebook' });
140+
// Create a temporary notebook for this session. Each needs a unique name (otherwise we get the same session every time)
141+
let backingFile = await contentsManager.newUntitled({ type: 'notebook' });
142+
backingFile = await contentsManager.rename(
143+
backingFile.path,
144+
`${path.dirname(backingFile.path)}/t-${uuid()}.ipynb` // Note, the docs say the path uses UNIX delimiters.
145+
);
141146

142147
// Create our session options using this temporary notebook and our connection info
143148
const options: Session.IOptions = {

src/test/datascience/jupyter/jupyterSession.unit.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ suite('DataScience - JupyterSession', () => {
9999
const nbFile = 'file path';
100100
// tslint:disable-next-line: no-any
101101
when(contentsManager.newUntitled(deepEqual({ type: 'notebook' }))).thenResolve({ path: nbFile } as any);
102+
// tslint:disable-next-line: no-any
103+
when(contentsManager.rename(anything(), anything())).thenResolve({ path: nbFile } as any);
102104
when(contentsManager.delete(anything())).thenResolve();
103105
when(sessionManager.startNew(anything())).thenResolve(instance(session));
104106
kernelSpec.setup((k) => k.name).returns(() => 'some name');

src/test/datascience/jupyterUriProviderRegistration.functional.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ suite(`DataScience JupyterServerUriProvider tests`, () => {
8888

8989
setup(async () => {
9090
ioc = new DataScienceIocContainer();
91+
// Force to always be a mock run. Real will try to connect to the dummy URI
92+
ioc.shouldMockJupyter = true;
9193
ioc.registerDataScienceTypes(false);
9294
ioc.serviceManager.rebindInstance<IExtensions>(IExtensions, new UriMockExtensions(ioc));
9395
return ioc.activate();

0 commit comments

Comments
 (0)