Disable one test and add a new utility function (#7486)

Skip problematic tests
This commit is contained in:
Amir Omidi
2019-10-02 21:59:40 -07:00
committed by GitHub
parent 08b78c3ca5
commit 575d1c8543
2 changed files with 44 additions and 20 deletions

View File

@@ -9,29 +9,29 @@ import 'mocha';
import * as azdata from 'azdata';
import { context } from './testContext';
import { getBdcServer, TestServerProfile, getAzureServer, getStandaloneServer } from './testConfig';
import { connectToServer, createDB, deleteDB, DefaultConnectTimeoutInMs } from './utils';
import { connectToServer, createDB, deleteDB, DefaultConnectTimeoutInMs, asyncTimeout } from './utils';
import assert = require('assert');
import { stressify } from 'adstest';
if (context.RunTest) {
suite('Object Explorer integration suite', () => {
test('BDC instance node label test', async function () {
await (new ObjectExplorerTester()).bdcNodeLabelTest();
return await (new ObjectExplorerTester()).bdcNodeLabelTest();
});
test('Standalone instance node label test', async function () {
await (new ObjectExplorerTester()).standaloneNodeLabelTest();
return await (new ObjectExplorerTester()).standaloneNodeLabelTest();
});
test('Azure SQL DB instance node label test', async function () {
await (new ObjectExplorerTester()).sqlDbNodeLabelTest();
test.skip('Azure SQL DB instance node label test', async function () {
return await (new ObjectExplorerTester()).sqlDbNodeLabelTest();
});
test('BDC instance context menu test', async function () {
await (new ObjectExplorerTester()).bdcContextMenuTest();
return await (new ObjectExplorerTester()).bdcContextMenuTest();
});
test('Azure SQL DB context menu test', async function () {
await (new ObjectExplorerTester()).sqlDbContextMenuTest();
return await (new ObjectExplorerTester()).sqlDbContextMenuTest();
});
test.skip('Standalone database context menu test', async function () {
await (new ObjectExplorerTester()).standaloneContextMenuTest();
return await (new ObjectExplorerTester()).standaloneContextMenuTest();
});
});
}
@@ -43,7 +43,7 @@ class ObjectExplorerTester {
async bdcNodeLabelTest(): Promise<void> {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects'];
const server = await getBdcServer();
await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
return await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
}
@stressify({ dop: ObjectExplorerTester.ParallelCount })
@@ -51,7 +51,7 @@ class ObjectExplorerTester {
if (process.platform === 'win32') {
const expectedNodeLabel = ['Databases', 'Security', 'Server Objects'];
const server = await getStandaloneServer();
await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
return await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
}
}
@@ -59,14 +59,14 @@ class ObjectExplorerTester {
async sqlDbNodeLabelTest(): Promise<void> {
const expectedNodeLabel = ['Databases', 'Security'];
const server = await getAzureServer();
await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
return await this.verifyOeNode(server, DefaultConnectTimeoutInMs, expectedNodeLabel);
}
@stressify({ dop: ObjectExplorerTester.ParallelCount })
async sqlDbContextMenuTest(): Promise<void> {
const server = await getAzureServer();
const expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
await this.verifyContextMenu(server, expectedActions);
return await this.verifyContextMenu(server, expectedActions);
}
@stressify({ dop: ObjectExplorerTester.ParallelCount })
@@ -80,7 +80,7 @@ class ObjectExplorerTester {
else {
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Refresh', 'Backup', 'Restore', 'Data-tier Application wizard', 'Schema Compare', 'Import wizard'];
}
await this.verifyDBContextMenu(server, DefaultConnectTimeoutInMs, expectedActions);
return await this.verifyDBContextMenu(server, DefaultConnectTimeoutInMs, expectedActions);
}
@stressify({ dop: ObjectExplorerTester.ParallelCount })
@@ -94,7 +94,7 @@ class ObjectExplorerTester {
else {
expectedActions = ['Manage', 'New Query', 'New Notebook', 'Disconnect', 'Delete Connection', 'Refresh', 'Data-tier Application wizard', 'Launch Profiler'];
}
await this.verifyContextMenu(server, expectedActions);
return await this.verifyContextMenu(server, expectedActions);
}
async verifyContextMenu(server: TestServerProfile, expectedActions: string[]): Promise<void> {
@@ -110,7 +110,7 @@ class ObjectExplorerTester {
const expectedString = expectedActions.join(',');
const actualString = actions.join(',');
assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
return assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
}
async verifyOeNode(server: TestServerProfile, timeout: number, expectedNodeLabel: string[]): Promise<void> {
@@ -122,11 +122,18 @@ class ObjectExplorerTester {
assert(index !== -1, `Failed to find server: "${server.serverName}" in OE tree`);
// TODO: #7146 HDFS isn't always filled in by the call to getChildren since it's loaded asynchronously. To avoid this test being flaky just removing
// the node for now if it exists until a proper fix can be made.
const children = (await nodes[index].getChildren()).filter(c => c.label !== 'HDFS');
const actualLabelsString = children.map(c => c.label).join(',');
const expectedLabelString = expectedNodeLabel.join(',');
assert(expectedNodeLabel.length === children.length && expectedLabelString === actualLabelsString, `Expected node label: "${expectedLabelString}", Actual: "${actualLabelsString}"`);
let children: azdata.objectexplorer.ObjectExplorerNode[];
try {
children = await asyncTimeout(nodes[index].getChildren(), timeout);
} catch (e) {
return assert.fail('getChildren() timed out...', e);
}
const nonHDFSChildren = children.filter(c => c.label !== 'HDFS');
const actualLabelsString = nonHDFSChildren.map(c => c.label).join(',');
const expectedLabelString = expectedNodeLabel.join(',');
return assert(expectedNodeLabel.length === nonHDFSChildren.length && expectedLabelString === actualLabelsString, `Expected node label: "${expectedLabelString}", Actual: "${actualLabelsString}"`);
}
async verifyDBContextMenu(server: TestServerProfile, timeoutinMS: number, expectedActions: string[]): Promise<void> {
@@ -157,7 +164,7 @@ class ObjectExplorerTester {
const expectedString = expectedActions.join(',');
const actualString = actions.join(',');
assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
return assert(expectedActions.length === actions.length && expectedString === actualString, `Expected actions: "${expectedString}", Actual actions: "${actualString}"`);
}
finally {
await deleteDB(server, dbName, ownerUri);

View File

@@ -54,6 +54,23 @@ export async function connectToServer(server: TestServerProfile, timeout: number
return result.connectionId;
}
export class PromiseCancelledError extends Error { }
/**
* Wait for a promise to resolve but timeout after a certain amount of time.
* It will throw CancelledError when it fails.
* @param p promise to wait on
* @param timeout time to wait
*/
export async function asyncTimeout<T>(p: Thenable<T>, timeout: number): Promise<(T | undefined)> {
const timeoutPromise = new Promise<T>((done, reject) => {
setTimeout(() => {
reject(new PromiseCancelledError('Promise did not resolve in time'));
}, timeout);
});
return Promise.race([p, timeoutPromise]);
}
export async function pollTimeout(predicate: () => Thenable<boolean>, intervalDelay: number, timeoutTime: number): Promise<boolean> {
let interval: NodeJS.Timer;
return new Promise(pollOver => {