Alanren/integration setup (#4871)

* automate the setup and use akv to store values

* update readme.md

* get rid of the save to file part

* update readme

* add more messages

* fix the error

* fix some errors

* fix the readme
This commit is contained in:
Alan Ren
2019-04-08 15:11:38 -07:00
committed by GitHub
parent acc27d0829
commit e6faef27ab
11 changed files with 1095 additions and 578 deletions

View File

@@ -12,7 +12,7 @@ import * as vscode from 'vscode';
import { context } from './testContext';
import { sqlNotebookContent, writeNotebookToFile, sqlKernelMetadata, getFileName, pySparkNotebookContent, pySpark3KernelMetadata, pythonKernelMetadata, sqlNotebookMultipleCellsContent } from './notebook.util';
import { getBdcServer } from './testConfig';
import { connectToServer } from './utils';
import { connectToServer, getConfigValue, EnvironmentVariable_PYTHON_PATH } from './utils';
import * as fs from 'fs';
if (context.RunTest) {
@@ -99,7 +99,7 @@ if (context.RunTest) {
async function openNotebook(content: azdata.nb.INotebookContents, kernelMetadata: any, testName: string, runAllCells?: boolean): Promise<azdata.nb.NotebookEditor> {
let notebookConfig = vscode.workspace.getConfiguration('notebook');
notebookConfig.update('pythonPath', process.env.PYTHON_TEST_PATH, 1);
notebookConfig.update('pythonPath', getConfigValue(EnvironmentVariable_PYTHON_PATH), 1);
let server = await getBdcServer();
await connectToServer(server, 6000);
let pythonNotebook = Object.assign({}, content, { metadata: kernelMetadata });

View File

@@ -9,6 +9,18 @@ import 'mocha';
import * as vscode from 'vscode';
import { context } from './testContext';
import assert = require('assert');
import { getConfigValue, EnvironmentVariable_BDC_SERVER, EnvironmentVariable_BDC_USERNAME, EnvironmentVariable_BDC_PASSWORD, EnvironmentVariable_AZURE_PASSWORD, EnvironmentVariable_AZURE_SERVER, EnvironmentVariable_AZURE_USERNAME, EnvironmentVariable_STANDALONE_PASSWORD, EnvironmentVariable_STANDALONE_SERVER, EnvironmentVariable_STANDALONE_USERNAME, EnvironmentVariable_PYTHON_PATH } from './utils';
assert(getConfigValue(EnvironmentVariable_BDC_SERVER) !== undefined &&
getConfigValue(EnvironmentVariable_BDC_USERNAME) !== undefined &&
getConfigValue(EnvironmentVariable_BDC_PASSWORD) !== undefined &&
getConfigValue(EnvironmentVariable_AZURE_PASSWORD) !== undefined &&
getConfigValue(EnvironmentVariable_AZURE_SERVER) !== undefined &&
getConfigValue(EnvironmentVariable_AZURE_USERNAME) !== undefined &&
getConfigValue(EnvironmentVariable_STANDALONE_PASSWORD) !== undefined &&
getConfigValue(EnvironmentVariable_STANDALONE_SERVER) !== undefined &&
getConfigValue(EnvironmentVariable_STANDALONE_USERNAME) !== undefined &&
getConfigValue(EnvironmentVariable_PYTHON_PATH) !== undefined, 'Required environment variables are not set, if you see this error in the build pipeline, make sure the environment variables are set properly in the build definition, otherwise for local dev environment make sure you follow the instructions in the readme file.');
if (!context.RunTest) {
suite('integration test setup', () => {
@@ -18,31 +30,5 @@ if (!context.RunTest) {
//Reload the window, this is required for some changes made by the 'test.setupIntegrationTest' to work
await vscode.commands.executeCommand('workbench.action.reloadWindow');
});
test('test setup verify BDC instance variables', async function () {
console.log(`BDC_BACKEND_HOSTNAME: '${process.env.BDC_BACKEND_HOSTNAME}', BDC_BACKEND_USERNAME: '${process.env.BDC_BACKEND_USERNAME}'`);
console.log(`PYTHON_TEST_PATH: '${process.env.PYTHON_TEST_PATH}'`);
assert(process.env.BDC_BACKEND_HOSTNAME !== undefined &&
process.env.BDC_BACKEND_USERNAME !== undefined &&
process.env.BDC_BACKEND_PWD !== undefined &&
process.env.PYTHON_TEST_PATH !== undefined, 'Test setup requirs BDC_BACKEND_HOSTNAME, BDC_BACKEND_USERNAME, BDC_BACKEND_PWD, and PYTHON_TEST_PATH must be set using ./scripts/setbackenvariables.sh or .\\scripts\\setbackendvaraibles.bat');
console.log('BDC instance variables are verified.');
});
test('test setup verify standalone instance variables', async function () {
console.log(`STANDALONE_SQL: '${process.env.STANDALONE_SQL}', STANDALONE_SQL_USERNAME: '${process.env.STANDALONE_SQL_USERNAME}'`);
assert(process.env.STANDALONE_SQL !== undefined &&
process.env.STANDALONE_SQL_USERNAME !== undefined &&
process.env.STANDALONE_SQL_PWD !== undefined, 'Test setup requirs STANDALONE_SQL, STANDALONE_SQL_USERNAME and STANDALONE_SQL_PWD must be set using ./scripts/setbackenvariables.sh or .\\scripts\\setbackendvaraibles.bat');
console.log('Standalone instance variables are verified.');
});
test('test setup verify azure instance variables', async function () {
console.log(`AZURE_SQL: '${process.env.AZURE_SQL}', AZURE_SQL_USERNAME: '${process.env.AZURE_SQL_USERNAME}'`);
assert(process.env.AZURE_SQL !== undefined &&
process.env.AZURE_SQL_USERNAME !== undefined &&
process.env.AZURE_SQL_PWD !== undefined, 'Test setup requirs AZURE_SQL, AZURE_SQL_USERNAME and AZURE_SQL_PWD must be set using ./scripts/setbackenvariables.sh or .\\scripts\\setbackendvaraibles.bat');
console.log('Azure instance variables are verified.');
});
});
}

View File

@@ -1,3 +1,5 @@
import { getConfigValue, EnvironmentVariable_STANDALONE_SERVER, EnvironmentVariable_STANDALONE_USERNAME, EnvironmentVariable_STANDALONE_PASSWORD, EnvironmentVariable_AZURE_SERVER, EnvironmentVariable_AZURE_USERNAME, EnvironmentVariable_AZURE_PASSWORD, EnvironmentVariable_BDC_SERVER, EnvironmentVariable_BDC_USERNAME, EnvironmentVariable_BDC_PASSWORD } from './utils';
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
@@ -59,29 +61,29 @@ export class TestServerProfile {
var TestingServers: TestServerProfile[] = [
new TestServerProfile(
{
serverName: process.env.STANDALONE_SQL,
userName: process.env.STANDALONE_SQL_USERNAME,
password: process.env.STANDALONE_SQL_PWD,
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'
}),
new TestServerProfile(
{
serverName: process.env.AZURE_SQL,
userName: process.env.AZURE_SQL_USERNAME,
password: process.env.AZURE_SQL_PWD,
authenticationType: AuthenticationType.SqlLogin,
database: 'master',
provider: ConnectionProvider.SQLServer,
version: '2012'
{
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'
}),
new TestServerProfile(
{
serverName: process.env.BDC_BACKEND_HOSTNAME,
userName: process.env.BDC_BACKEND_USERNAME,
password: process.env.BDC_BACKEND_PWD,
serverName: getConfigValue(EnvironmentVariable_BDC_SERVER),
userName: getConfigValue(EnvironmentVariable_BDC_USERNAME),
password: getConfigValue(EnvironmentVariable_BDC_PASSWORD),
authenticationType: AuthenticationType.SqlLogin,
database: 'master',
provider: ConnectionProvider.SQLServer,

View File

@@ -35,4 +35,19 @@ export async function connectToServer(server: TestServerProfile, timeout: number
export async function ensureConnectionViewOpened() {
await vscode.commands.executeCommand('dataExplorer.servers.focus');
}
}
export function getConfigValue(name: string): string {
return process.env[name];
}
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';