mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
fix unstable tests (#8799)
* fix tests * mark dac test unstable * import export bac * remove rel tag * Update dacpac.test.ts * bump sts and enable dac tests
This commit is contained in:
@@ -45,7 +45,7 @@ if (isTestSetupCompleted()) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create CMS Server @UNSTABLE@ @REL@', async function () {
|
test('Create CMS Server', async function () {
|
||||||
// Should fail
|
// Should fail
|
||||||
await utils.assertThrowsAsync(
|
await utils.assertThrowsAsync(
|
||||||
async () => await cmsService.createCmsServer(undefined, 'test_description', undefined, ownerUri),
|
async () => await cmsService.createCmsServer(undefined, 'test_description', undefined, ownerUri),
|
||||||
@@ -66,7 +66,7 @@ if (isTestSetupCompleted()) {
|
|||||||
await cmsService.createCmsServer(TEST_CMS_NAME, 'test_description', connection, ownerUri);
|
await cmsService.createCmsServer(TEST_CMS_NAME, 'test_description', connection, ownerUri);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Add and delete registered group to/from CMS server @UNSTABLE@ @REL@', async function () {
|
test('Add and delete registered group to/from CMS server', async function () {
|
||||||
await utils.assertThrowsAsync(
|
await utils.assertThrowsAsync(
|
||||||
async () => await cmsService.addServerGroup(ownerUri, '', undefined, 'test_description'),
|
async () => await cmsService.addServerGroup(ownerUri, '', undefined, 'test_description'),
|
||||||
'Cannot add a server group without a name');
|
'Cannot add a server group without a name');
|
||||||
@@ -95,7 +95,7 @@ if (isTestSetupCompleted()) {
|
|||||||
`The server group ${TEST_CMS_GROUP} was not removed successfully. Groups : [${cmsResources.registeredServerGroups.map(g => g.name).join(', ')}]`);
|
`The server group ${TEST_CMS_GROUP} was not removed successfully. Groups : [${cmsResources.registeredServerGroups.map(g => g.name).join(', ')}]`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Add and delete registered server to/from CMS server @UNSTABLE@ @REL@', async function () {
|
test('Add and delete registered server to/from CMS server', async function () {
|
||||||
|
|
||||||
await utils.assertThrowsAsync(
|
await utils.assertThrowsAsync(
|
||||||
async () => cmsService.addRegisteredServer(ownerUri, '', undefined, 'test_description', undefined),
|
async () => cmsService.addRegisteredServer(ownerUri, '', undefined, 'test_description', undefined),
|
||||||
@@ -128,7 +128,7 @@ if (isTestSetupCompleted()) {
|
|||||||
assert(deleteResult === true, `Registered server ${TEST_CMS_SERVER} was not removed correctly`);
|
assert(deleteResult === true, `Registered server ${TEST_CMS_SERVER} was not removed correctly`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Add and delete registered server to/from server group @UNSTABLE@ @REL@', async function () {
|
test('Add and delete registered server to/from server group', async function () {
|
||||||
|
|
||||||
// Should create a server group
|
// Should create a server group
|
||||||
let result = await cmsService.addServerGroup(ownerUri, '', TEST_CMS_GROUP, 'test_description');
|
let result = await cmsService.addServerGroup(ownerUri, '', TEST_CMS_GROUP, 'test_description');
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ if (isTestSetupCompleted()) {
|
|||||||
console.log(`Start dacpac tests`);
|
console.log(`Start dacpac tests`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Deploy and extract dacpac @UNSTABLE@ @REL@', async function () {
|
test('Deploy and extract dacpac', async function () {
|
||||||
const server = await getStandaloneServer();
|
const server = await getStandaloneServer();
|
||||||
await utils.connectToServer(server);
|
await utils.connectToServer(server);
|
||||||
|
|
||||||
@@ -41,8 +41,17 @@ if (isTestSetupCompleted()) {
|
|||||||
// Deploy dacpac
|
// Deploy dacpac
|
||||||
const deployResult = await dacfxService.deployDacpac(dacpac1, databaseName, false, ownerUri, azdata.TaskExecutionMode.execute);
|
const deployResult = await dacfxService.deployDacpac(dacpac1, databaseName, false, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
||||||
await utils.assertTableCreationResult(databaseName, 'dbo', 'Table1', ownerUri, retryCount);
|
const dbConnectionId = await utils.connectToServer({
|
||||||
await utils.assertTableCreationResult(databaseName, 'dbo', 'Table2', ownerUri, retryCount);
|
serverName: server.serverName,
|
||||||
|
database: databaseName,
|
||||||
|
userName: server.userName,
|
||||||
|
password: server.password,
|
||||||
|
authenticationTypeName: server.authenticationTypeName,
|
||||||
|
providerName: server.providerName
|
||||||
|
});
|
||||||
|
const dbConnectionOwnerUri = await azdata.connection.getUriForConnection(dbConnectionId);
|
||||||
|
await utils.assertTableCreationResult('dbo', 'Table1', dbConnectionOwnerUri, retryCount);
|
||||||
|
await utils.assertTableCreationResult('dbo', 'Table2', dbConnectionOwnerUri, retryCount);
|
||||||
assert(deployResult.success === true && deployResult.errorMessage === '', `Deploy dacpac should succeed Expected: there should be no error. Actual Error message: "${deployResult.errorMessage}"`);
|
assert(deployResult.success === true && deployResult.errorMessage === '', `Deploy dacpac should succeed Expected: there should be no error. Actual Error message: "${deployResult.errorMessage}"`);
|
||||||
|
|
||||||
// Extract dacpac
|
// Extract dacpac
|
||||||
@@ -64,7 +73,7 @@ if (isTestSetupCompleted()) {
|
|||||||
// Tracking bug https://github.com/microsoft/azuredatastudio/issues/7323
|
// Tracking bug https://github.com/microsoft/azuredatastudio/issues/7323
|
||||||
|
|
||||||
const bacpac1: string = path.join(__dirname, '..', 'testData', 'Database1.bacpac');
|
const bacpac1: string = path.join(__dirname, '..', 'testData', 'Database1.bacpac');
|
||||||
test('Import and export bacpac @UNSTABLE@', async function () {
|
test('Import and export bacpac', async function () {
|
||||||
const server = await getStandaloneServer();
|
const server = await getStandaloneServer();
|
||||||
await utils.connectToServer(server);
|
await utils.connectToServer(server);
|
||||||
|
|
||||||
@@ -81,8 +90,17 @@ if (isTestSetupCompleted()) {
|
|||||||
// Import bacpac
|
// Import bacpac
|
||||||
const importResult = await dacfxService.importBacpac(bacpac1, databaseName, ownerUri, azdata.TaskExecutionMode.execute);
|
const importResult = await dacfxService.importBacpac(bacpac1, databaseName, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
||||||
await utils.assertTableCreationResult(databaseName, 'dbo', 'Table1', ownerUri, retryCount, true);
|
const dbConnectionId = await utils.connectToServer({
|
||||||
await utils.assertTableCreationResult(databaseName, 'dbo', 'Table2', ownerUri, retryCount, true);
|
serverName: server.serverName,
|
||||||
|
database: databaseName,
|
||||||
|
userName: server.userName,
|
||||||
|
password: server.password,
|
||||||
|
authenticationTypeName: server.authenticationTypeName,
|
||||||
|
providerName: server.providerName
|
||||||
|
});
|
||||||
|
const dbConnectionOwnerUri = await azdata.connection.getUriForConnection(dbConnectionId);
|
||||||
|
await utils.assertTableCreationResult('dbo', 'Table1', dbConnectionOwnerUri, retryCount, true);
|
||||||
|
await utils.assertTableCreationResult('dbo', 'Table2', dbConnectionOwnerUri, retryCount, true);
|
||||||
assert(importResult.success === true && importResult.errorMessage === '', `Expected: Import bacpac should succeed and there should be no error. Actual Error message: "${importResult.errorMessage}"`);
|
assert(importResult.success === true && importResult.errorMessage === '', `Expected: Import bacpac should succeed and there should be no error. Actual Error message: "${importResult.errorMessage}"`);
|
||||||
|
|
||||||
// Export bacpac
|
// Export bacpac
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ if (isTestSetupCompleted()) {
|
|||||||
test.skip('BDC instance context menu test', async function () {
|
test.skip('BDC instance context menu test', async function () {
|
||||||
return await (new ObjectExplorerTester()).bdcContextMenuTest();
|
return await (new ObjectExplorerTester()).bdcContextMenuTest();
|
||||||
});
|
});
|
||||||
test('Azure SQL DB context menu test @UNSTABLE@', async function () {
|
test('Azure SQL DB context menu test', async function () {
|
||||||
return await (new ObjectExplorerTester()).sqlDbContextMenuTest();
|
return await (new ObjectExplorerTester()).sqlDbContextMenuTest();
|
||||||
});
|
});
|
||||||
test('Standalone database context menu test @UNSTABLE@', async function () {
|
test('Standalone database context menu test', async function () {
|
||||||
return await (new ObjectExplorerTester()).standaloneContextMenuTest();
|
return await (new ObjectExplorerTester()).standaloneContextMenuTest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -152,7 +152,7 @@ class ObjectExplorerTester {
|
|||||||
const serverNode = nodes[index];
|
const serverNode = nodes[index];
|
||||||
const 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 === 'Databases', `Expected Databases node. Actual ${children[0].label}`);
|
||||||
const databasesFolder = children[0];
|
const databasesFolder = children[0];
|
||||||
|
|
||||||
const databases = await databasesFolder.getChildren();
|
const databases = await databasesFolder.getChildren();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if (isTestSetupCompleted()) {
|
|||||||
test('Schema compare dacpac to dacpac comparison and scmp', async function () {
|
test('Schema compare dacpac to dacpac comparison and scmp', async function () {
|
||||||
await schemaCompareTester.SchemaCompareDacpacToDacpac();
|
await schemaCompareTester.SchemaCompareDacpacToDacpac();
|
||||||
});
|
});
|
||||||
test('Schema compare database to database comparison, script generation, and scmp @UNSTABLE@', async function () {
|
test('Schema compare database to database comparison, script generation, and scmp', async function () {
|
||||||
await schemaCompareTester.SchemaCompareDatabaseToDatabase();
|
await schemaCompareTester.SchemaCompareDatabaseToDatabase();
|
||||||
});
|
});
|
||||||
// TODO: figure out why this is failing with Error: This editor is not connected to a database Parameter name: OwnerUri
|
// TODO: figure out why this is failing with Error: This editor is not connected to a database Parameter name: OwnerUri
|
||||||
|
|||||||
@@ -67,7 +67,15 @@ export const EnvironmentVariable_STANDALONE_SERVER_2019: string = 'STANDALONE_SQ
|
|||||||
export const EnvironmentVariable_STANDALONE_USERNAME_2019: string = 'STANDALONE_SQL_USERNAME_2019';
|
export const EnvironmentVariable_STANDALONE_USERNAME_2019: string = 'STANDALONE_SQL_USERNAME_2019';
|
||||||
export const EnvironmentVariable_STANDALONE_PASSWORD_2019: string = 'STANDALONE_SQL_PWD_2019';
|
export const EnvironmentVariable_STANDALONE_PASSWORD_2019: string = 'STANDALONE_SQL_PWD_2019';
|
||||||
|
|
||||||
export class TestServerProfile {
|
export interface TestConnectionInfo {
|
||||||
|
readonly serverName: string;
|
||||||
|
readonly database: string;
|
||||||
|
readonly userName: string;
|
||||||
|
readonly password: string;
|
||||||
|
readonly providerName: string;
|
||||||
|
readonly authenticationTypeName: string;
|
||||||
|
}
|
||||||
|
export class TestServerProfile implements TestConnectionInfo {
|
||||||
constructor(private _profile: ITestServerProfile) { }
|
constructor(private _profile: ITestServerProfile) { }
|
||||||
public get serverName(): string { return this._profile.serverName; }
|
public get serverName(): string { return this._profile.serverName; }
|
||||||
public get userName(): string { return this._profile.userName; }
|
public get userName(): string { return this._profile.userName; }
|
||||||
|
|||||||
@@ -7,26 +7,26 @@ import * as assert from 'assert';
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { TestServerProfile } from './testConfig';
|
import { TestServerProfile, TestConnectionInfo } from './testConfig';
|
||||||
import { isNullOrUndefined } from 'util';
|
import { isNullOrUndefined } from 'util';
|
||||||
|
|
||||||
// default server connection timeout
|
// default server connection timeout
|
||||||
export const DefaultConnectTimeoutInMs: number = 10000;
|
export const DefaultConnectTimeoutInMs: number = 10000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param server test connection profile
|
* @param connectionInfo test connection profile
|
||||||
* @param timeout optional timeout parameter
|
* @param timeout optional timeout parameter
|
||||||
* Returns connection id for a new connection
|
* Returns connection id for a new connection
|
||||||
*/
|
*/
|
||||||
export async function connectToServer(server: TestServerProfile, timeout: number = DefaultConnectTimeoutInMs): Promise<string> {
|
export async function connectToServer(connectionInfo: TestConnectionInfo, timeout: number = DefaultConnectTimeoutInMs): Promise<string> {
|
||||||
let connectionProfile: azdata.IConnectionProfile = {
|
let connectionProfile: azdata.IConnectionProfile = {
|
||||||
serverName: server.serverName,
|
serverName: connectionInfo.serverName,
|
||||||
databaseName: server.database,
|
databaseName: connectionInfo.database,
|
||||||
authenticationType: server.authenticationTypeName,
|
authenticationType: connectionInfo.authenticationTypeName,
|
||||||
providerName: server.providerName,
|
providerName: connectionInfo.providerName,
|
||||||
connectionName: '',
|
connectionName: '',
|
||||||
userName: server.userName,
|
userName: connectionInfo.userName,
|
||||||
password: server.password,
|
password: connectionInfo.password,
|
||||||
savePassword: false,
|
savePassword: false,
|
||||||
groupFullName: undefined,
|
groupFullName: undefined,
|
||||||
saveProfile: true,
|
saveProfile: true,
|
||||||
@@ -182,17 +182,23 @@ export async function assertDatabaseCreationResult(databaseName: string, ownerUr
|
|||||||
let result: azdata.SimpleExecuteResult;
|
let result: azdata.SimpleExecuteResult;
|
||||||
while (retryCount > 0) {
|
while (retryCount > 0) {
|
||||||
--retryCount;
|
--retryCount;
|
||||||
|
// add state=0 to the query to make sure the database is online
|
||||||
let query = `BEGIN TRY
|
const query = `BEGIN TRY
|
||||||
SELECT name FROM master.dbo.sysdatabases WHERE name='${databaseName}'
|
SELECT name FROM sys.databases WHERE name='${databaseName}' AND state=0
|
||||||
END TRY
|
END TRY
|
||||||
BEGIN CATCH
|
BEGIN CATCH
|
||||||
SELECT ERROR_MESSAGE() AS ErrorMessage;
|
SELECT ERROR_MESSAGE() AS ErrorMessage;
|
||||||
END CATCH`;
|
END CATCH`;
|
||||||
|
try {
|
||||||
result = await runQuery(query, ownerUri);
|
result = await runQuery(query, ownerUri);
|
||||||
if (result.rowCount > 0) {
|
if (result.rowCount > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// exception will be thrown by the SQL Tools Service if no results is returned
|
||||||
|
// ignore it.
|
||||||
|
}
|
||||||
|
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
}
|
}
|
||||||
@@ -222,7 +228,6 @@ export async function assertFileGenerationResult(filepath: string, retryCount: n
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param databaseName name of database where to look for table
|
|
||||||
* @param tableName table to look for
|
* @param tableName table to look for
|
||||||
* @param schema schema to look for
|
* @param schema schema to look for
|
||||||
* @param ownerUri owner uri
|
* @param ownerUri owner uri
|
||||||
@@ -230,12 +235,11 @@ export async function assertFileGenerationResult(filepath: string, retryCount: n
|
|||||||
* @param checkForData whether or not to check if the table has data
|
* @param checkForData whether or not to check if the table has data
|
||||||
* Checks for table existing
|
* Checks for table existing
|
||||||
*/
|
*/
|
||||||
export async function assertTableCreationResult(databaseName: string, schema: string, tableName: string, ownerUri: string, retryCount: number, checkForData?: boolean): Promise<void> {
|
export async function assertTableCreationResult(schema: string, tableName: string, ownerUri: string, retryCount: number, checkForData?: boolean): Promise<void> {
|
||||||
let result: azdata.SimpleExecuteResult;
|
let result: azdata.SimpleExecuteResult;
|
||||||
while (retryCount > 0) {
|
while (retryCount > 0) {
|
||||||
--retryCount;
|
--retryCount;
|
||||||
let query = `BEGIN TRY
|
let query = `BEGIN TRY
|
||||||
USE ${databaseName}
|
|
||||||
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '${schema}' AND TABLE_NAME = '${tableName}'
|
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '${schema}' AND TABLE_NAME = '${tableName}'
|
||||||
END TRY
|
END TRY
|
||||||
BEGIN CATCH
|
BEGIN CATCH
|
||||||
@@ -254,7 +258,6 @@ export async function assertTableCreationResult(databaseName: string, schema: st
|
|||||||
if (checkForData) {
|
if (checkForData) {
|
||||||
while (retryCount > 0) {
|
while (retryCount > 0) {
|
||||||
let query = `BEGIN TRY
|
let query = `BEGIN TRY
|
||||||
USE ${databaseName}
|
|
||||||
SELECT * FROM ${tableName}
|
SELECT * FROM ${tableName}
|
||||||
END TRY
|
END TRY
|
||||||
BEGIN CATCH
|
BEGIN CATCH
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||||
"version": "2.0.0-release.40",
|
"version": "2.0.0-release.42",
|
||||||
"downloadFileNames": {
|
"downloadFileNames": {
|
||||||
"Windows_86": "win-x86-netcoreapp2.2.zip",
|
"Windows_86": "win-x86-netcoreapp2.2.zip",
|
||||||
"Windows_64": "win-x64-netcoreapp2.2.zip",
|
"Windows_64": "win-x64-netcoreapp2.2.zip",
|
||||||
|
|||||||
Reference in New Issue
Block a user