mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Smoke tests (#9814)
* move * add inital test; need basic sqllite connection * before sqlite * sqlite * add smoke tests * working tests * fix app names * fix quick open * fix smoke tests * add win32 smoke tests * fix smoke test * fix win32 smoke * no continue * continue on error * add vscode smokes * remove vscode tests * continue on error * allow sqlite to use relative paths * add linux smoke tests * fix build files * use dispatch instead of select * fix linux build again * fix darwin * get select working * try and use screen shots * screen shots * remove smoke tests linux * try vscodes sqlite * fix compile * fix webpack * fix deps * try this again * try force a rebuild * try npm rebuild * add sqlite to be rebuilt * distro * try vscode sqlite again * revert changes to driver and simplify edits * fix compile * fix imports * move sqlite out * remove unneeded change * add extensions path * fix web tests * no continue on error
This commit is contained in:
118
extensions/integration-tests/src/tests/dacpac.test.ts
Normal file
118
extensions/integration-tests/src/tests/dacpac.test.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'mocha';
|
||||
import * as azdata from 'azdata';
|
||||
import * as utils from '../utils';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as mssql from '../../../mssql';
|
||||
import * as vscode from 'vscode';
|
||||
import { isTestSetupCompleted } from '../testContext';
|
||||
import { getStandaloneServer } from '../testConfig';
|
||||
import * as assert from 'assert';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const retryCount = 24; // 2 minutes
|
||||
const dacpac1: string = path.join(__dirname, '../testData/Database1.dacpac');
|
||||
if (isTestSetupCompleted()) {
|
||||
suite('Dacpac integration test suite', () => {
|
||||
suiteSetup(async function () {
|
||||
await utils.sleep(5000); // To ensure the providers are registered.
|
||||
console.log(`Start dacpac tests`);
|
||||
});
|
||||
|
||||
test('Deploy and extract dacpac', async function () {
|
||||
const server = await getStandaloneServer();
|
||||
await utils.connectToServer(server);
|
||||
|
||||
const nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
||||
const index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
|
||||
const ownerUri = await azdata.connection.getUriForConnection(nodes[index].connectionId);
|
||||
const now = new Date();
|
||||
const databaseName = 'ADS_deployDacpac_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
const dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
|
||||
// Deploy dacpac
|
||||
const deployResult = await dacfxService.deployDacpac(dacpac1, databaseName, false, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
||||
const dbConnectionId = await utils.connectToServer({
|
||||
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}"`);
|
||||
|
||||
// Extract dacpac
|
||||
const folderPath = path.join(os.tmpdir(), 'DacFxTest');
|
||||
if (!(await promisify(fs.exists)(folderPath))) {
|
||||
await fs.promises.mkdir(folderPath);
|
||||
}
|
||||
const packageFilePath = path.join(folderPath, `${databaseName}.dacpac`);
|
||||
const extractResult = await dacfxService.extractDacpac(databaseName, packageFilePath, databaseName, '1.0.0.0', ownerUri, azdata.TaskExecutionMode.execute);
|
||||
await utils.assertFileGenerationResult(packageFilePath, retryCount);
|
||||
|
||||
assert(extractResult.success === true && extractResult.errorMessage === '', `Extract dacpac should succeed. Expected: there should be no error. Actual Error message: "${extractResult.errorMessage}"`);
|
||||
} finally {
|
||||
await utils.deleteDB(server, databaseName, ownerUri);
|
||||
}
|
||||
});
|
||||
|
||||
const bacpac1: string = path.join(__dirname, '..', 'testData', 'Database1.bacpac');
|
||||
test('Import and export bacpac', async function () {
|
||||
const server = await getStandaloneServer();
|
||||
await utils.connectToServer(server);
|
||||
|
||||
const nodes = <azdata.objectexplorer.ObjectExplorerNode[]>await azdata.objectexplorer.getActiveConnectionNodes();
|
||||
const index = nodes.findIndex(node => node.nodePath.includes(server.serverName));
|
||||
const ownerUri = await azdata.connection.getUriForConnection(nodes[index].connectionId);
|
||||
const now = new Date();
|
||||
const databaseName = 'ADS_importBacpac_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
let dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
|
||||
// Import bacpac
|
||||
const importResult = await dacfxService.importBacpac(bacpac1, databaseName, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
await utils.assertDatabaseCreationResult(databaseName, ownerUri, retryCount);
|
||||
const dbConnectionId = await utils.connectToServer({
|
||||
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}"`);
|
||||
|
||||
// Export bacpac
|
||||
const folderPath = path.join(os.tmpdir(), 'DacFxTest');
|
||||
if (!(await promisify(fs.exists)(folderPath))) {
|
||||
await fs.promises.mkdir(folderPath);
|
||||
}
|
||||
const packageFilePath = path.join(folderPath, `${databaseName}.bacpac`);
|
||||
const exportResult = await dacfxService.exportBacpac(databaseName, packageFilePath, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
await utils.assertFileGenerationResult(packageFilePath, retryCount);
|
||||
assert(exportResult.success === true && exportResult.errorMessage === '', `Expected: Export bacpac should succeed and there should be no error. Actual Error message: "${exportResult.errorMessage}"`);
|
||||
} finally {
|
||||
await utils.deleteDB(server, databaseName, ownerUri);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user