Exclude Spark notebook kernels when running on SAW devices. (#11416)

This commit is contained in:
Cory Rivera
2020-07-20 12:36:40 -07:00
committed by GitHub
parent 26f833f728
commit 047c51921b
9 changed files with 93 additions and 19 deletions

View File

@@ -506,21 +506,24 @@
"displayName": "PySpark", "displayName": "PySpark",
"connectionProviderIds": [ "connectionProviderIds": [
"MSSQL" "MSSQL"
] ],
"blockedOnSAW": true
}, },
{ {
"name": "sparkkernel", "name": "sparkkernel",
"displayName": "Spark | Scala", "displayName": "Spark | Scala",
"connectionProviderIds": [ "connectionProviderIds": [
"MSSQL" "MSSQL"
] ],
"blockedOnSAW": true
}, },
{ {
"name": "sparkrkernel", "name": "sparkrkernel",
"displayName": "Spark | R", "displayName": "Spark | R",
"connectionProviderIds": [ "connectionProviderIds": [
"MSSQL" "MSSQL"
] ],
"blockedOnSAW": true
}, },
{ {
"name": "python3", "name": "python3",

View File

@@ -36,6 +36,10 @@ declare module 'azdata' {
*/ */
setTrusted(state: boolean); setTrusted(state: boolean);
} }
export interface IStandardKernel {
readonly blockedOnSAW?: boolean;
}
} }
export type SqlDbType = 'BigInt' | 'Binary' | 'Bit' | 'Char' | 'DateTime' | 'Decimal' export type SqlDbType = 'BigInt' | 'Binary' | 'Bit' | 'Char' | 'DateTime' | 'Decimal'

View File

@@ -10,7 +10,7 @@ import { NotebookService } from 'sql/workbench/services/notebook/browser/noteboo
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { TestLifecycleService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { CellContext } from 'sql/workbench/contrib/notebook/browser/cellViews/codeActions'; import { CellContext } from 'sql/workbench/contrib/notebook/browser/cellViews/codeActions';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService'; import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
@@ -19,6 +19,7 @@ import * as DOM from 'vs/base/browser/dom';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService'; import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
import { CellModel } from 'sql/workbench/services/notebook/browser/models/cell'; import { CellModel } from 'sql/workbench/services/notebook/browser/models/cell';
import { IProductService } from 'vs/platform/product/common/productService';
suite('CellToolbarActions', function (): void { suite('CellToolbarActions', function (): void {
suite('removeDuplicatedAndStartingSeparators', function (): void { suite('removeDuplicatedAndStartingSeparators', function (): void {
@@ -88,12 +89,24 @@ suite('CellToolbarActions', function (): void {
const contextMock = TypeMoq.Mock.ofType(CellContext); const contextMock = TypeMoq.Mock.ofType(CellContext);
const cellModelMock = TypeMoq.Mock.ofType(CellModel); const cellModelMock = TypeMoq.Mock.ofType(CellModel);
instantiationService.stub(IProductService, { quality: 'stable' });
suiteSetup(function (): void { suiteSetup(function (): void {
contextMock.setup(x => x.cell).returns(() => cellModelMock.object); contextMock.setup(x => x.cell).returns(() => cellModelMock.object);
const mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, instantiationService, new MockContextKeyService(), let notebookService = new NotebookService(
undefined, instantiationService, undefined, undefined, undefined, undefined, TestEnvironmentService); new TestLifecycleService(),
undefined,
undefined,
undefined,
instantiationService,
undefined,
undefined,
undefined,
new MockContextKeyService(),
instantiationService.get(IProductService)
);
instantiationService.stub(INotificationService, new TestNotificationService()); instantiationService.stub(INotificationService, new TestNotificationService());
instantiationService.stub(INotebookService, mockNotebookService.object); instantiationService.stub(INotebookService, notebookService);
instantiationService.stub(IContextMenuService, TypeMoq.Mock.ofType(ContextMenuService).object); instantiationService.stub(IContextMenuService, TypeMoq.Mock.ofType(ContextMenuService).object);
}); });

View File

@@ -31,6 +31,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { IEditor } from 'vs/editor/common/editorCommon'; import { IEditor } from 'vs/editor/common/editorCommon';
import { NotebookEditorStub } from 'sql/workbench/contrib/notebook/test/testCommon'; import { NotebookEditorStub } from 'sql/workbench/contrib/notebook/test/testCommon';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { IProductService } from 'vs/platform/product/common/productService';
suite('MarkdownTextTransformer', () => { suite('MarkdownTextTransformer', () => {
let markdownTextTransformer: MarkdownTextTransformer; let markdownTextTransformer: MarkdownTextTransformer;
@@ -53,8 +54,21 @@ suite('MarkdownTextTransformer', () => {
instantiationService.stub(IEnvironmentService, TestEnvironmentService); instantiationService.stub(IEnvironmentService, TestEnvironmentService);
instantiationService.stub(IStorageService, new TestStorageService()); instantiationService.stub(IStorageService, new TestStorageService());
mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, instantiationService, new MockContextKeyService(), instantiationService.stub(IProductService, { quality: 'stable' });
undefined, undefined, undefined, undefined, undefined, undefined, TestEnvironmentService);
let notebookService = new NotebookService(
new TestLifecycleService(),
undefined,
undefined,
undefined,
instantiationService,
undefined,
undefined,
undefined,
new MockContextKeyService(),
instantiationService.get(IProductService)
);
mockNotebookService = TypeMoq.Mock.ofInstance(notebookService);
cellModel = new CellModel(undefined, undefined, mockNotebookService.object); cellModel = new CellModel(undefined, undefined, mockNotebookService.object);
notebookEditor = new NotebookEditorStub({ cellGuid: cellModel.cellGuid, instantiationService: instantiationService }); notebookEditor = new NotebookEditorStub({ cellGuid: cellModel.cellGuid, instantiationService: instantiationService });

View File

@@ -57,6 +57,7 @@ import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/work
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput'; import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService'; import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices'; import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IProductService } from 'vs/platform/product/common/productService';
class NotebookModelStub extends stubs.NotebookModelStub { class NotebookModelStub extends stubs.NotebookModelStub {
private _cells: Array<ICellModel> = [new CellModel(undefined, undefined)]; private _cells: Array<ICellModel> = [new CellModel(undefined, undefined)];
@@ -681,6 +682,8 @@ function setupServices(arg: { workbenchThemeService?: WorkbenchThemeService, ins
instantiationService.stub(IExtensionManagementService, 'onUninstallExtension', uninstallEvent.event); instantiationService.stub(IExtensionManagementService, 'onUninstallExtension', uninstallEvent.event);
instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallEvent.event); instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallEvent.event);
instantiationService.stub(IProductService, { quality: 'stable' });
const extensionService = instantiationService.get(IExtensionService); const extensionService = instantiationService.get(IExtensionService);
const notebookService = new NotebookService( const notebookService = new NotebookService(
instantiationService.get(ILifecycleService), instantiationService.get(ILifecycleService),
@@ -691,7 +694,8 @@ function setupServices(arg: { workbenchThemeService?: WorkbenchThemeService, ins
instantiationService.get(IFileService), instantiationService.get(IFileService),
instantiationService.get(ILogService), instantiationService.get(ILogService),
queryManagementService, queryManagementService,
instantiationService.get(IContextKeyService) instantiationService.get(IContextKeyService),
instantiationService.get(IProductService)
); );
instantiationService.stub(INotebookService, notebookService); instantiationService.stub(INotebookService, notebookService);

View File

@@ -29,6 +29,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { ExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagementService'; import { ExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagementService';
import { TestFileService, TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestFileService, TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestExtensionService, TestStorageService } from 'vs/workbench/test/common/workbenchTestServices'; import { TestExtensionService, TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
import { IProductService } from 'vs/platform/product/common/productService';
/** /**
* class to mock azdata.nb.ServerManager object * class to mock azdata.nb.ServerManager object
@@ -107,6 +108,7 @@ suite('NotebookService:', function (): void {
let extensionServiceMock: TypeMoq.Mock<TestExtensionService>; let extensionServiceMock: TypeMoq.Mock<TestExtensionService>;
let testNo = 0; let testNo = 0;
let sandbox: sinon.SinonSandbox; let sandbox: sinon.SinonSandbox;
let productService: IProductService;
let installExtensionEmitter: Emitter<InstallExtensionEvent>, let installExtensionEmitter: Emitter<InstallExtensionEvent>,
didInstallExtensionEmitter: Emitter<DidInstallExtensionEvent>, didInstallExtensionEmitter: Emitter<DidInstallExtensionEvent>,
@@ -143,7 +145,10 @@ suite('NotebookService:', function (): void {
instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallExtensionEmitter.event); instantiationService.stub(IExtensionManagementService, 'onDidUninstallExtension', didUninstallExtensionEmitter.event);
extensionManagementService = instantiationService.get(IExtensionManagementService); extensionManagementService = instantiationService.get(IExtensionManagementService);
notebookService = new NotebookService(lifecycleService, storageService, extensionServiceMock.object, extensionManagementService, instantiationService, fileService, logServiceMock.object, queryManagementService, contextService); instantiationService.stub(IProductService, { quality: 'stable' });
productService = instantiationService.get(IProductService);
notebookService = new NotebookService(lifecycleService, storageService, extensionServiceMock.object, extensionManagementService, instantiationService, fileService, logServiceMock.object, queryManagementService, contextService, productService);
sandbox = sinon.sandbox.create(); sandbox = sinon.sandbox.create();
}); });
@@ -440,7 +445,7 @@ suite('NotebookService:', function (): void {
}; };
errorHandler.setUnexpectedErrorHandler(onUnexpectedErrorVerifier); errorHandler.setUnexpectedErrorHandler(onUnexpectedErrorVerifier);
// The following call throws an exception internally with queryManagementService parameter being undefined. // The following call throws an exception internally with queryManagementService parameter being undefined.
new NotebookService(lifecycleService, storageService, extensionService, extensionManagementService, instantiationService, fileService, logService, /* queryManagementService */ undefined, contextService); new NotebookService(lifecycleService, storageService, extensionService, extensionManagementService, instantiationService, fileService, logService, /* queryManagementService */ undefined, contextService, productService);
await unexpectedErrorPromise; await unexpectedErrorPromise;
assert.strictEqual(unexpectedErrorCalled, true, `onUnexpectedError must be have been raised when queryManagementService is undefined when calling NotebookService constructor`); assert.strictEqual(unexpectedErrorCalled, true, `onUnexpectedError must be have been raised when queryManagementService is undefined when calling NotebookService constructor`);
}); });

View File

@@ -28,7 +28,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager'; import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { TestEnvironmentService, TestLifecycleService, TestTextFileService, workbenchInstantiationService, TestTextFileEditorModelManager } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestLifecycleService, TestTextFileService, workbenchInstantiationService, TestTextFileEditorModelManager } from 'vs/workbench/test/browser/workbenchTestServices';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { nb } from 'azdata'; import { nb } from 'azdata';
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
@@ -40,6 +40,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { TestStorageService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices'; import { TestStorageService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService'; import { NullAdsTelemetryService } from 'sql/platform/telemetry/common/adsTelemetryService';
import { IProductService } from 'vs/platform/product/common/productService';
class ServiceAccessor { class ServiceAccessor {
@@ -74,6 +75,7 @@ suite('Notebook Editor Model', function (): void {
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0); memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
let testinstantiationService = new TestInstantiationService(); let testinstantiationService = new TestInstantiationService();
testinstantiationService.stub(IStorageService, new TestStorageService()); testinstantiationService.stub(IStorageService, new TestStorageService());
testinstantiationService.stub(IProductService, { quality: 'stable' });
const queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, const queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose,
undefined, // connection store undefined, // connection store
undefined, // connection status manager undefined, // connection status manager
@@ -107,9 +109,19 @@ suite('Notebook Editor Model', function (): void {
}, undefined, undefined); }, undefined, undefined);
}); });
let mockNotebookService: TypeMoq.Mock<NotebookService>; let notebookService = new NotebookService(
mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, instantiationService, new MockContextKeyService(), new TestLifecycleService(),
undefined, undefined, undefined, undefined, undefined, undefined, TestEnvironmentService); undefined,
undefined,
undefined,
instantiationService,
undefined,
undefined,
undefined,
new MockContextKeyService(),
testinstantiationService.get(IProductService)
);
let mockNotebookService = TypeMoq.Mock.ofInstance(notebookService);
mockNotebookService.setup(s => s.findNotebookEditor(TypeMoq.It.isAny())).returns(() => { mockNotebookService.setup(s => s.findNotebookEditor(TypeMoq.It.isAny())).returns(() => {
return { return {

View File

@@ -35,6 +35,7 @@ import { NotebookChangeType } from 'sql/workbench/services/notebook/common/contr
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces'; import { notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IProductService } from 'vs/platform/product/common/productService';
export interface NotebookProviderProperties { export interface NotebookProviderProperties {
provider: string; provider: string;
@@ -118,6 +119,7 @@ export class NotebookService extends Disposable implements INotebookService {
@ILogService private readonly _logService: ILogService, @ILogService private readonly _logService: ILogService,
@IQueryManagementService private readonly _queryManagementService: IQueryManagementService, @IQueryManagementService private readonly _queryManagementService: IQueryManagementService,
@IContextKeyService private contextKeyService: IContextKeyService, @IContextKeyService private contextKeyService: IContextKeyService,
@IProductService private readonly productService: IProductService
) { ) {
super(); super();
this._providersMemento = new Memento('notebookProviders', this._storageService); this._providersMemento = new Memento('notebookProviders', this._storageService);
@@ -264,6 +266,10 @@ export class NotebookService extends Disposable implements INotebookService {
} else { } else {
standardKernels.push(provider.standardKernels); standardKernels.push(provider.standardKernels);
} }
// Filter out unusable kernels when running on a SAW
if (this.productService.quality === 'saw') {
standardKernels = standardKernels.filter(kernel => !kernel.blockedOnSAW);
}
this._providerToStandardKernels.set(providerUpperCase, standardKernels); this._providerToStandardKernels.set(providerUpperCase, standardKernels);
} }

View File

@@ -15,10 +15,11 @@ import { NotebookService } from 'sql/workbench/services/notebook/browser/noteboo
import { INotebookProvider } from 'sql/workbench/services/notebook/browser/notebookService'; import { INotebookProvider } from 'sql/workbench/services/notebook/browser/notebookService';
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes'; import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager'; import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
import { TestLifecycleService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
import { ExtHostNotebookShape } from 'sql/workbench/api/common/sqlExtHost.protocol'; import { ExtHostNotebookShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IProductService } from 'vs/platform/product/common/productService';
suite('MainThreadNotebook Tests', () => { suite('MainThreadNotebook Tests', () => {
@@ -34,8 +35,20 @@ suite('MainThreadNotebook Tests', () => {
getProxy: proxyType => mockProxy.object getProxy: proxyType => mockProxy.object
}; };
const instantiationService = new TestInstantiationService(); const instantiationService = new TestInstantiationService();
mockNotebookService = TypeMoq.Mock.ofType(NotebookService, undefined, new TestLifecycleService(), undefined, undefined, undefined, instantiationService, new MockContextKeyService(), instantiationService.stub(IProductService, { quality: 'stable' });
undefined, undefined, undefined, undefined, undefined, undefined, TestEnvironmentService); let notebookService = new NotebookService(
new TestLifecycleService(),
undefined,
undefined,
undefined,
instantiationService,
undefined,
undefined,
undefined,
new MockContextKeyService(),
instantiationService.get(IProductService)
);
mockNotebookService = TypeMoq.Mock.ofInstance(notebookService);
notebookUri = URI.parse('file:/user/default/my.ipynb'); notebookUri = URI.parse('file:/user/default/my.ipynb');
mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object, instantiationService); mainThreadNotebook = new MainThreadNotebook(extContext, mockNotebookService.object, instantiationService);
}); });