mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 17:22:55 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
51
test/automation/src/sql/connectionDialog.ts
Normal file
51
test/automation/src/sql/connectionDialog.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Code } from '../code';
|
||||
import { waitForNewDialog, clickDialogButton } from './sqlutils';
|
||||
import { TestServerProfile, AuthenticationType } from './testConfig';
|
||||
|
||||
const CONNECTION_DIALOG_TITLE = 'Connection';
|
||||
const CONNECTION_DIALOG_SELECTOR: string = '.modal-dialog .modal-content .modal-body .connection-dialog';
|
||||
const CONNECTION_DETAIL_CONTROL_SELECTOR: string = '.connection-provider-info .connection-table .connection-input';
|
||||
|
||||
const SERVER_INPUT_ARIA_LABEL = 'Server';
|
||||
const USERNAME_INPUT_ARIA_LABEL = 'User name';
|
||||
const PASSWORD_INPUT_ARIA_LABEL = 'Password';
|
||||
const AUTH_TYPE_ARIA_LABEL = 'Authentication type';
|
||||
|
||||
const CONNECT_BUTTON_ARIA_LABEL = 'Connect';
|
||||
|
||||
export class ConnectionDialog {
|
||||
|
||||
constructor(private code: Code) { }
|
||||
|
||||
async waitForConnectionDialog(): Promise<void> {
|
||||
await waitForNewDialog(this.code, CONNECTION_DIALOG_TITLE);
|
||||
}
|
||||
|
||||
async connect(profile: TestServerProfile): Promise<void> {
|
||||
await this.code.waitForSetValue(this.getInputCssSelector(SERVER_INPUT_ARIA_LABEL), profile.serverName);
|
||||
if (profile.authenticationType === AuthenticationType.SqlLogin) {
|
||||
await this.code.waitAndClick(this.getSelectCssSelector(AUTH_TYPE_ARIA_LABEL));
|
||||
await this.selectAuthType(profile.authenticationTypeDisplayName);
|
||||
await this.code.waitForSetValue(this.getInputCssSelector(USERNAME_INPUT_ARIA_LABEL), profile.userName);
|
||||
await this.code.waitForSetValue(this.getInputCssSelector(PASSWORD_INPUT_ARIA_LABEL), profile.password);
|
||||
}
|
||||
await clickDialogButton(this.code, CONNECT_BUTTON_ARIA_LABEL);
|
||||
}
|
||||
|
||||
private getInputCssSelector(ariaLabel: string): string {
|
||||
return `${CONNECTION_DIALOG_SELECTOR} ${CONNECTION_DETAIL_CONTROL_SELECTOR} .monaco-inputbox input[aria-label="${ariaLabel}"]`;
|
||||
}
|
||||
|
||||
private getSelectCssSelector(ariaLabel: string): string {
|
||||
return `${CONNECTION_DIALOG_SELECTOR} ${CONNECTION_DETAIL_CONTROL_SELECTOR} select[aria-label="${ariaLabel}"]`;
|
||||
}
|
||||
|
||||
private async selectAuthType(authType: string) {
|
||||
await this.code.waitAndClick(`.context-view.bottom.left .monaco-select-box-dropdown-container .select-box-dropdown-list-container .monaco-list .monaco-scrollable-element .monaco-list-rows .monaco-list-row div[aria-label="${authType}"][class*="option-text"]`);
|
||||
}
|
||||
}
|
||||
28
test/automation/src/sql/profiler.ts
Normal file
28
test/automation/src/sql/profiler.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Code } from '../code';
|
||||
import { QuickOpen } from '../quickopen';
|
||||
import { waitForNewDialog, clickDialogButton } from './sqlutils';
|
||||
|
||||
const NEW_SESSION_DIALOG_TITLE: string = 'Start New Profiler Session';
|
||||
|
||||
export class Profiler {
|
||||
|
||||
constructor(private code: Code, private quickopen: QuickOpen) { }
|
||||
|
||||
async launchProfiler(): Promise<void> {
|
||||
await this.quickopen.runCommand('Profiler: Launch Profiler');
|
||||
}
|
||||
|
||||
async waitForNewSessionDialog() {
|
||||
await waitForNewDialog(this.code, NEW_SESSION_DIALOG_TITLE);
|
||||
}
|
||||
|
||||
async waitForNewSessionDialogAndStart() {
|
||||
await this.waitForNewSessionDialog();
|
||||
await clickDialogButton(this.code, 'Start');
|
||||
}
|
||||
}
|
||||
54
test/automation/src/sql/queryEditors.ts
Normal file
54
test/automation/src/sql/queryEditors.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Editors } from '../editors';
|
||||
import { QuickOpen } from '../quickopen';
|
||||
import { Code } from '../code';
|
||||
import * as path from 'path';
|
||||
|
||||
export class QueryEditors extends Editors {
|
||||
|
||||
constructor(
|
||||
private vsCode: Code,
|
||||
private quickopen: QuickOpen
|
||||
) {
|
||||
super(vsCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified file - this correctly handles SQL files which are opened in a Query Editor window
|
||||
* @param filePath The full path of the file to open.
|
||||
*/
|
||||
async openFile(filePath: string): Promise<void> {
|
||||
await this.quickopen.openQuickOpen(filePath);
|
||||
|
||||
const fileBaseName = path.basename(filePath);
|
||||
await this.quickopen.waitForQuickOpenElements(names => names[0] === fileBaseName);
|
||||
await this.vsCode.dispatchKeybinding('enter');
|
||||
await this.waitForEditorFocus(fileBaseName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an active SQL Query Editor tab for the specified file. This is a modification of the editors.waitForActiveTab that
|
||||
* takes into account the connected status displayed in the title of Query Editors.
|
||||
* @param fileName The name of the file opened in the editor
|
||||
* @param isDirty Whether the file is dirty or not
|
||||
*/
|
||||
async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<void> {
|
||||
// For now assume all opened tabs are disconnected until we have a need to open connected tabs
|
||||
await this.vsCode.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName} - disconnected, tab"]`);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Waits for an active Query Editor for the specified file to have focus. This is a modification of the editors.waitForEditorFocus
|
||||
* that takes into account the connected status displayed in the title of Query Editors.
|
||||
* @param fileName The name of the file opened in the editor
|
||||
*/
|
||||
async waitForEditorFocus(fileName: string): Promise<void> {
|
||||
await this.waitForActiveTab(fileName);
|
||||
await super.waitForActiveEditor(fileName);
|
||||
}
|
||||
}
|
||||
14
test/automation/src/sql/sqlutils.ts
Normal file
14
test/automation/src/sql/sqlutils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Code } from '../code';
|
||||
|
||||
export async function waitForNewDialog(code: Code, title: string) {
|
||||
await code.waitForElement(`div[aria-label="${title}"][class="modal fade flyout-dialog"]`);
|
||||
}
|
||||
|
||||
export async function clickDialogButton(code: Code, title: string) {
|
||||
await code.waitAndClick(`.modal-dialog .modal-content .modal-footer .right-footer .footer-button a[aria-label="${title}"][aria-disabled="false"]`);
|
||||
}
|
||||
149
test/automation/src/sql/testConfig.ts
Normal file
149
test/automation/src/sql/testConfig.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
TODO: Due to a runtime error, I duplicated this file at these 2 locations:
|
||||
$/extensions/integration-test/src/testConfig.ts
|
||||
$/test/smoke/src/sql/testConfig.ts
|
||||
for now, make sure to keep both files in sync.
|
||||
*/
|
||||
|
||||
interface ITestServerProfile {
|
||||
serverName: string;
|
||||
userName: string;
|
||||
password: string;
|
||||
authenticationType: AuthenticationType;
|
||||
database: string;
|
||||
provider: ConnectionProvider;
|
||||
version: string;
|
||||
engineType: EngineType;
|
||||
}
|
||||
|
||||
interface INameDisplayNamePair {
|
||||
name: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export enum AuthenticationType {
|
||||
Windows,
|
||||
SqlLogin
|
||||
}
|
||||
|
||||
export enum ConnectionProvider {
|
||||
SQLServer
|
||||
}
|
||||
|
||||
export enum EngineType {
|
||||
Standalone,
|
||||
Azure,
|
||||
BigDataCluster
|
||||
}
|
||||
|
||||
let connectionProviderMapping: { [key: string]: any } = {};
|
||||
let authenticationTypeMapping: { [key: string]: any } = {};
|
||||
connectionProviderMapping[ConnectionProvider.SQLServer] = { name: 'MSSQL', displayName: 'Microsoft SQL Server' };
|
||||
|
||||
authenticationTypeMapping[AuthenticationType.SqlLogin] = { name: 'SqlLogin', displayName: 'SQL Login' };
|
||||
authenticationTypeMapping[AuthenticationType.Windows] = { name: 'Integrated', displayName: 'Windows Authentication' };
|
||||
|
||||
export function getConfigValue(name: string): string {
|
||||
let configValue = process.env[name];
|
||||
return configValue ? configValue.toString() : '';
|
||||
}
|
||||
|
||||
export const EnvironmentVariable_BDC_SERVER: string = 'BDC_BACKEND_HOSTNAME';
|
||||
export const EnvironmentVariable_BDC_USERNAME: string = 'BDC_BACKEND_USERNAME';
|
||||
export const EnvironmentVariable_BDC_PASSWORD: string = 'BDC_BACKEND_PWD';
|
||||
export const EnvironmentVariable_STANDALONE_SERVER: string = 'STANDALONE_SQL';
|
||||
export const EnvironmentVariable_STANDALONE_USERNAME: string = 'STANDALONE_SQL_USERNAME';
|
||||
export const EnvironmentVariable_STANDALONE_PASSWORD: string = 'STANDALONE_SQL_PWD';
|
||||
export const EnvironmentVariable_AZURE_SERVER: string = 'AZURE_SQL';
|
||||
export const EnvironmentVariable_AZURE_USERNAME: string = 'AZURE_SQL_USERNAME';
|
||||
export const EnvironmentVariable_AZURE_PASSWORD: string = 'AZURE_SQL_PWD';
|
||||
export const EnvironmentVariable_PYTHON_PATH: string = 'PYTHON_TEST_PATH';
|
||||
|
||||
export class TestServerProfile {
|
||||
constructor(private _profile: ITestServerProfile) { }
|
||||
public get serverName(): string { return this._profile.serverName; }
|
||||
public get userName(): string { return this._profile.userName; }
|
||||
public get password(): string { return this._profile.password; }
|
||||
public get database(): string { return this._profile.database; }
|
||||
public get version(): string { return this._profile.version; }
|
||||
public get provider(): ConnectionProvider { return this._profile.provider; }
|
||||
public get providerName(): string { return getEnumMappingEntry(connectionProviderMapping, this.provider).name; }
|
||||
public get providerDisplayName(): string { return getEnumMappingEntry(connectionProviderMapping, this.provider).displayName; }
|
||||
public get authenticationType(): AuthenticationType { return this._profile.authenticationType; }
|
||||
public get authenticationTypeName(): string { return getEnumMappingEntry(authenticationTypeMapping, this.authenticationType).name; }
|
||||
public get authenticationTypeDisplayName(): string { return getEnumMappingEntry(authenticationTypeMapping, this.authenticationType).displayName; }
|
||||
public get engineType(): EngineType { return this._profile.engineType; }
|
||||
}
|
||||
|
||||
let TestingServers: TestServerProfile[] = [
|
||||
new TestServerProfile(
|
||||
{
|
||||
serverName: getConfigValue(EnvironmentVariable_STANDALONE_SERVER),
|
||||
userName: getConfigValue(EnvironmentVariable_STANDALONE_USERNAME),
|
||||
password: getConfigValue(EnvironmentVariable_STANDALONE_PASSWORD),
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
database: 'master',
|
||||
provider: ConnectionProvider.SQLServer,
|
||||
version: '2017',
|
||||
engineType: EngineType.Standalone
|
||||
}),
|
||||
new TestServerProfile(
|
||||
{
|
||||
serverName: getConfigValue(EnvironmentVariable_AZURE_SERVER),
|
||||
userName: getConfigValue(EnvironmentVariable_AZURE_USERNAME),
|
||||
password: getConfigValue(EnvironmentVariable_AZURE_PASSWORD),
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
database: 'master',
|
||||
provider: ConnectionProvider.SQLServer,
|
||||
version: '2012',
|
||||
engineType: EngineType.Azure
|
||||
}),
|
||||
new TestServerProfile(
|
||||
{
|
||||
serverName: getConfigValue(EnvironmentVariable_BDC_SERVER),
|
||||
userName: getConfigValue(EnvironmentVariable_BDC_USERNAME),
|
||||
password: getConfigValue(EnvironmentVariable_BDC_PASSWORD),
|
||||
authenticationType: AuthenticationType.SqlLogin,
|
||||
database: 'master',
|
||||
provider: ConnectionProvider.SQLServer,
|
||||
version: '2019',
|
||||
engineType: EngineType.BigDataCluster
|
||||
})
|
||||
];
|
||||
|
||||
function getEnumMappingEntry(mapping: any, enumValue: any): INameDisplayNamePair {
|
||||
let entry = mapping[enumValue];
|
||||
if (entry) {
|
||||
return entry;
|
||||
} else {
|
||||
throw new Error(`Unknown enum type: ${enumValue.toString()}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAzureServer(): Promise<TestServerProfile> {
|
||||
let servers = await getTestingServers();
|
||||
return servers.filter(s => s.engineType === EngineType.Azure)[0];
|
||||
}
|
||||
|
||||
export async function getStandaloneServer(): Promise<TestServerProfile> {
|
||||
let servers = await getTestingServers();
|
||||
return servers.filter(s => s.version === '2017' && s.engineType === EngineType.Standalone)[0];
|
||||
}
|
||||
|
||||
export async function getBdcServer(): Promise<TestServerProfile> {
|
||||
let servers = await getTestingServers();
|
||||
return servers.filter(s => s.version === '2019' && s.engineType === EngineType.BigDataCluster)[0];
|
||||
}
|
||||
|
||||
export async function getTestingServers(): Promise<TestServerProfile[]> {
|
||||
let promise = new Promise<TestServerProfile[]>(resolve => {
|
||||
resolve(TestingServers);
|
||||
});
|
||||
await promise;
|
||||
return promise;
|
||||
}
|
||||
Reference in New Issue
Block a user