Add azure and standalone instance config to environment variables (#4745)

* change to fs to write file

* change random range to 1 to 100

* Added more env variables check as well

* Add azure and standalone env variables

* Add Azure instance to unblock mac pipeline testing

* Fixed some merge issue and improve delete file

* Added standalone test only run on windows
This commit is contained in:
Yurong He
2019-03-29 20:14:44 -07:00
committed by GitHub
parent ddbd8033f9
commit a4c2463b2f
6 changed files with 94 additions and 30 deletions

View File

@@ -17,24 +17,25 @@ import { connectToServer } from './utils';
import * as fs from 'fs';
if (context.RunTest) {
suite('Notebook integration test suite', () => {
suite('Notebook integration test suite', function() {
test('Sql NB test', async function () {
console.log('Start Sql NB test');
let testName = this.test.title;
console.log(`Start "${testName}"`);
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata);
const expectedOutput0 = '(1 row affected)';
let cellOutputs = notebook.document.cells[0].contents.outputs;
console.log('Got cell outputs');
assert(cellOutputs.length === 3, `Expected length: 3, Acutal: '${cellOutputs.length}'`);
assert(cellOutputs.length === 3, `Expected length: 3, Actual: ${cellOutputs.length}`);
let actualOutput0 = (<azdata.nb.IDisplayData>cellOutputs[0]).data['text/html'];
console.log('Got first output');
assert(actualOutput0 === expectedOutput0, `Expected row count: '${expectedOutput0}', Acutal: '${actualOutput0}'`);
assert(actualOutput0 === expectedOutput0, `Expected row count: ${expectedOutput0}, Actual: ${actualOutput0}`);
let actualOutput2 = (<azdata.nb.IExecuteResult>cellOutputs[2]).data['application/vnd.dataresource+json'].data[0];
assert(actualOutput2[0] === '1', `Expected result: 1, Acutal: '${actualOutput2[0]}'`);
assert(actualOutput2[0] === '1', `Expected result: 1, Actual: '${actualOutput2[0]}'`);
if (fs.existsSync(notebook.document.fileName)) {
fs.unlink(notebook.document.fileName);
fs.unlinkSync(notebook.document.fileName);
}
console.log('Sql NB done');
console.log(`"${testName}" done`);
});
// test('Python3 notebook test', async function () {
@@ -43,7 +44,7 @@ if (context.RunTest) {
// let cellOutputs = notebook.document.cells[0].contents.outputs;
// console.log('Got cell outputs');
// let result = (<azdata.nb.IExecuteResult>cellOutputs[0]).data['text/plain'];
// assert(result === '2', `Expected: 2, Acutal: '${result}'`);
// assert(result === '2', `Expected: 2, Actual: ${result}`);
// console.log('Python3 NB done');
// });
@@ -56,7 +57,7 @@ if (context.RunTest) {
// let clearedOutputs = await notebook.clearAllOutputs();
// let cells = notebook.document.cells;
// cells.forEach(cell => {
// assert(cell.contents && cell.contents.outputs && cell.contents.outputs.length === 0, `Expected Output: 0, Acutal: '${cell.contents.outputs.length}'`);
// assert(cell.contents && cell.contents.outputs && cell.contents.outputs.length === 0, `Expected Output: 0, Actual: '${cell.contents.outputs.length}'`);
// });
// assert(clearedOutputs, 'Outputs of all the code cells from Python notebook should be cleared');
// console.log("After clearing cell outputs");
@@ -88,7 +89,7 @@ if (context.RunTest) {
// let notebook = await openNotebook(pySparkNotebookContent, pySpark3KernelMetadata);
// let cellOutputs = notebook.document.cells[0].contents.outputs;
// let sparkResult = (<azdata.nb.IStreamResult>cellOutputs[3]).text;
// assert(sparkResult === '2', `Expected: 2, Acutal: '${sparkResult}'`);
// assert(sparkResult === '2', `Expected: 2, Actual: ${sparkResult}`);
// });
});
}

View File

@@ -8,27 +8,31 @@
import 'mocha';
import * as azdata from 'azdata';
import { context } from './testContext';
import { getDefaultTestingServer, getBdcServer, TestServerProfile } from './testConfig';
import { getBdcServer, TestServerProfile, getAzureServer, getStandaloneServer } from './testConfig';
import { connectToServer } from './utils';
import assert = require('assert');
if (context.RunTest) {
suite('Object Explorer integration suite', () => {
test('BDC instance node label test', async function () {
assert(process.env.BDC_BACKEND_HOSTNAME !== undefined &&
process.env.BDC_BACKEND_USERNAME !== undefined &&
process.env.BDC_BACKEND_PWD !== undefined, 'BDC_BACKEND_HOSTNAME, BDC_BACKEND_USERNAME, BDC_BACKEND_PWD must be set using ./scripts/setbackenvariables.sh or .\\scripts\\setbackendvaraibles.bat');
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects', 'Data Services'];
let server = await getBdcServer();
await VerifyOeNode(server, 6000, expectedNodeLabel);
});
test('Standard alone instance node label test', async function () {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects'];
let server = await getDefaultTestingServer();
if (process.platform === 'win32') {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects'];
let server = await getStandaloneServer();
await VerifyOeNode(server, 3000, expectedNodeLabel);
}
});
test('Azure SQL DB instance node label test', async function () {
const expectedNodeLabel = ['Databases', 'Security'];
let server = await getAzureServer();
await VerifyOeNode(server, 3000, expectedNodeLabel);
});
test('context menu test', async function () {
let server = await getDefaultTestingServer();
let server = await getAzureServer();
await connectToServer(server, 3000);
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
@@ -64,6 +68,6 @@ async function VerifyOeNode(server: TestServerProfile, timeout: number, expected
assert(childeren.length === expectedNodeLable.length, `Expecting node count: ${expectedNodeLable.length}, Actual: ${childeren.length}`);
childeren.forEach(c => actualNodeLable.push(c.label));
assert(expectedNodeLable.toLocaleString() === actualNodeLable.toLocaleString(), `Expected node label: "$'${expectedNodeLable}", Actual: "${actualNodeLable}"`);
assert(expectedNodeLable.toLocaleString() === actualNodeLable.toLocaleString(), `Expected node label: "${expectedNodeLable}", Actual: "${actualNodeLable}"`);
}

View File

@@ -17,13 +17,32 @@ if (!context.RunTest) {
await vscode.commands.executeCommand('test.setupIntegrationTest');
//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.STANDALONE_SQL_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.PYTHON_TEST_PATH, 'BDC_BACKEND_HOSTNAME, BDC_BACKEND_USERNAME, BDC_BACKEND_PWD must be set using ./scripts/setbackenvariables.sh or .\\scripts\\setbackendvaraibles.bat');
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

@@ -59,7 +59,7 @@ export class TestServerProfile {
var TestingServers: TestServerProfile[] = [
new TestServerProfile(
{
serverName: 'SQLTOOLS2017-3',
serverName: process.env.STANDALONE_SQL,
userName: process.env.STANDALONE_SQL_USERNAME,
password: process.env.STANDALONE_SQL_PWD,
authenticationType: AuthenticationType.SqlLogin,
@@ -67,6 +67,16 @@ var TestingServers: TestServerProfile[] = [
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'
}),
new TestServerProfile(
{
serverName: process.env.BDC_BACKEND_HOSTNAME,
@@ -93,6 +103,16 @@ export async function getDefaultTestingServer(): Promise<TestServerProfile> {
return servers[0];
}
export async function getAzureServer(): Promise<TestServerProfile> {
let servers = await getTestingServers();
return servers.filter(s => s.version === '2012')[0];
}
export async function getStandaloneServer(): Promise<TestServerProfile> {
let servers = await getTestingServers();
return servers.filter(s => s.version === '2017')[0];
}
export async function getBdcServer(): Promise<TestServerProfile> {
let servers = await getTestingServers();
return servers.filter(s => s.version === '2019')[0];