fix the sqldb OE test (#6006)

This commit is contained in:
Alan Ren
2019-06-12 09:04:13 -07:00
committed by GitHub
parent d089d6642a
commit b0fdaedfdb

View File

@@ -42,7 +42,7 @@ class ObjectExplorerTester {
@stressify({ dop: ObjectExplorerTester.ParallelCount }) @stressify({ dop: ObjectExplorerTester.ParallelCount })
async bdcNodeLabelTest(): Promise<void> { async bdcNodeLabelTest(): Promise<void> {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects', 'Data Services']; const expectedNodeLabel = ['Databases', 'Security', 'Server Objects', 'Data Services'];
let server = await getBdcServer(); const server = await getBdcServer();
await this.verifyOeNode(server, 6000, expectedNodeLabel); await this.verifyOeNode(server, 6000, expectedNodeLabel);
} }
@@ -50,7 +50,7 @@ class ObjectExplorerTester {
async standaloneNodeLabelTest(): Promise<void> { async standaloneNodeLabelTest(): Promise<void> {
if (process.platform === 'win32') { if (process.platform === 'win32') {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects']; const expectedNodeLabel = ['Databases', 'Security', 'Server Objects'];
let server = await getStandaloneServer(); const server = await getStandaloneServer();
await this.verifyOeNode(server, 3000, expectedNodeLabel); await this.verifyOeNode(server, 3000, expectedNodeLabel);
} }
} }
@@ -58,28 +58,22 @@ class ObjectExplorerTester {
@stressify({ dop: ObjectExplorerTester.ParallelCount }) @stressify({ dop: ObjectExplorerTester.ParallelCount })
async sqlDbNodeLabelTest(): Promise<void> { async sqlDbNodeLabelTest(): Promise<void> {
const expectedNodeLabel = ['Databases', 'Security']; const expectedNodeLabel = ['Databases', 'Security'];
let server = await getAzureServer(); const server = await getAzureServer();
await this.verifyOeNode(server, 3000, expectedNodeLabel); await this.verifyOeNode(server, 3000, expectedNodeLabel);
} }
@stressify({ dop: ObjectExplorerTester.ParallelCount }) @stressify({ dop: ObjectExplorerTester.ParallelCount })
async sqlDbContextMenuTest(): Promise<void> { async sqlDbContextMenuTest(): Promise<void> {
let server = await getAzureServer(); const server = await getAzureServer();
let expectedActions: string[]; const expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
if (process.platform === 'win32') {
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler', 'Properties'];
}
else {
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
}
await this.verifyContextMenu(server, expectedActions); await this.verifyContextMenu(server, expectedActions);
} }
@stressify({ dop: ObjectExplorerTester.ParallelCount }) @stressify({ dop: ObjectExplorerTester.ParallelCount })
async standaloneContextMenuTest(): Promise<void> { async standaloneContextMenuTest(): Promise<void> {
let server = await getStandaloneServer(); const server = await getStandaloneServer();
let expectedActions: string[] = []; let expectedActions: string[] = [];
// Generate Scripts and Properties come from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
if (process.platform === 'win32') { if (process.platform === 'win32') {
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Backup', 'Restore', 'Refresh', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard', 'Generate Scripts...', 'Properties']; expectedActions = ['Manage', 'New Query', 'New Notebook', 'Backup', 'Restore', 'Refresh', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard', 'Generate Scripts...', 'Properties'];
} }
@@ -91,7 +85,7 @@ class ObjectExplorerTester {
@stressify({ dop: ObjectExplorerTester.ParallelCount }) @stressify({ dop: ObjectExplorerTester.ParallelCount })
async bdcContextMenuTest(): Promise<void> { async bdcContextMenuTest(): Promise<void> {
let server = await getBdcServer(); const server = await getBdcServer();
let expectedActions: string[]; let expectedActions: string[];
// Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms // Properties comes from the admin-tool-ext-win extension which is for Windows only, so the item won't show up on non-Win32 platforms
if (process.platform === 'win32') { if (process.platform === 'win32') {
@@ -105,29 +99,29 @@ class ObjectExplorerTester {
async verifyContextMenu(server: TestServerProfile, expectedActions: string[]): Promise<void> { async verifyContextMenu(server: TestServerProfile, expectedActions: string[]): Promise<void> {
await connectToServer(server, 3000); await connectToServer(server, 3000);
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes(); const nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`); assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
let index = nodes.findIndex(node => node.nodePath.includes(server.serverName)); const index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`); assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
let node = nodes[index]; const node = nodes[index];
let actions = await azdata.objectexplorer.getNodeActions(node.connectionId, node.nodePath); const actions = await azdata.objectexplorer.getNodeActions(node.connectionId, node.nodePath);
let expectedString = expectedActions.join(','); const expectedString = expectedActions.join(',');
const actualString = actions.join(','); const actualString = actions.join(',');
assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`); assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
} }
async verifyOeNode(server: TestServerProfile, timeout: number, expectedNodeLabel: string[]): Promise<void> { async verifyOeNode(server: TestServerProfile, timeout: number, expectedNodeLabel: string[]): Promise<void> {
await connectToServer(server, timeout); await connectToServer(server, timeout);
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes(); const nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`); assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
let index = nodes.findIndex(node => node.nodePath.includes(server.serverName)); const index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`); assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
let actualNodeLabel = []; const actualNodeLabel = [];
let children = await nodes[index].getChildren(); const children = await nodes[index].getChildren();
assert(children.length === expectedNodeLabel.length, `Expecting node count: ${expectedNodeLabel.length}, Actual: ${children.length}`); assert(children.length === expectedNodeLabel.length, `Expecting node count: ${expectedNodeLabel.length}, Actual: ${children.length}`);
children.forEach(c => actualNodeLabel.push(c.label)); children.forEach(c => actualNodeLabel.push(c.label));
@@ -138,27 +132,27 @@ class ObjectExplorerTester {
await connectToServer(server, timeoutinMS); await connectToServer(server, timeoutinMS);
let nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes(); const nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`); assert(nodes.length > 0, `Expecting at least one active connection, actual: ${nodes.length}`);
let index = nodes.findIndex(node => node.nodePath.includes(server.serverName)); const index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`); assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
let ownerUri = await azdata.connection.getUriForConnection(nodes[index].connectionId); const ownerUri = await azdata.connection.getUriForConnection(nodes[index].connectionId);
let dbName: string = 'ads_test_VerifyDBContextMenu_' + new Date().getTime().toString(); const dbName: string = 'ads_test_VerifyDBContextMenu_' + new Date().getTime().toString();
try { try {
await createDB(dbName, ownerUri); await createDB(dbName, ownerUri);
let serverNode = nodes[index]; const serverNode = nodes[index];
let children = await serverNode.getChildren(); const children = await serverNode.getChildren();
assert(children[0].label.toLocaleLowerCase === 'Databases'.toLocaleLowerCase, `Expected Databases node. Actual ${children[0].label}`); assert(children[0].label.toLocaleLowerCase === 'Databases'.toLocaleLowerCase, `Expected Databases node. Actual ${children[0].label}`);
let databasesFolder = children[0]; const databasesFolder = children[0];
let databases = await databasesFolder.getChildren(); const databases = await databasesFolder.getChildren();
assert(databases.length > 2, `No database present, can not test further`); // System Databses folder and at least one database assert(databases.length > 2, `No database present, can not test further`); // System Databses folder and at least one database
let actions = await azdata.objectexplorer.getNodeActions(databases[1].connectionId, databases[1].nodePath); const actions = await azdata.objectexplorer.getNodeActions(databases[1].connectionId, databases[1].nodePath);
const expectedString = expectedActions.join(','); const expectedString = expectedActions.join(',');
const actualString = actions.join(','); const actualString = actions.join(',');