mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Alanren/integration test (#3657)
* add an extension for integration tests * setup ads before running test * test setup * test cases * bash script * shorter temp folder name * code cleanup * add commented out original code * fix test error * test result path * rename results file * change file path * report smoke test results * test stablize * test stablization and configurable test servers * fix smoke test error * connection provider * simplify the integration test script * add comment * fix tslint error * address PR comments * add temp log to check whether the environment variable is already set * remove temp log * move api definition to testapi typing file * exclude integration tests extension * address comments
This commit is contained in:
77
extensions/integration-tests/src/main.ts
Normal file
77
extensions/integration-tests/src/main.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import * as vscode from 'vscode';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { normalize, join } from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const TEST_SETUP_COMPLETED_TEXT: string = 'Test Setup Completed';
|
||||
const EXTENSION_LOADED_TEXT: string = 'Test Extension Loaded';
|
||||
const ALL_EXTENSION_LOADED_TEXT: string = 'All Extensions Loaded';
|
||||
|
||||
var statusBarItemTimer: NodeJS.Timer;
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
var statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
vscode.commands.registerCommand('test.setupIntegrationTest', async () => {
|
||||
let extensionInstallersFolder = normalize(join(__dirname, '../extensionInstallers'));
|
||||
let installers = fs.readdirSync(extensionInstallersFolder);
|
||||
for (let i = 0; i < installers.length; i++) {
|
||||
if (installers[i].endsWith('.vsix')) {
|
||||
let installerFullPath = join(extensionInstallersFolder, installers[i]);
|
||||
await sqlops.extensions.install(installerFullPath);
|
||||
}
|
||||
}
|
||||
await setConfiguration('workbench.enablePreviewFeatures', true);
|
||||
await setConfiguration('workbench.showConnectDialogOnStartup', false);
|
||||
await setConfiguration('test.testSetupCompleted', true);
|
||||
showStatusBarItem(statusBarItem, TEST_SETUP_COMPLETED_TEXT);
|
||||
});
|
||||
|
||||
vscode.commands.registerCommand('test.waitForExtensionsToLoad', async () => {
|
||||
let expectedExtensions = ['Microsoft.agent', 'Microsoft.import', 'Microsoft.mssql', 'Microsoft.profiler'];
|
||||
do {
|
||||
let extensions = vscode.extensions.all.filter(ext => { return expectedExtensions.indexOf(ext.id) !== -1; });
|
||||
|
||||
let isReady = true;
|
||||
for (let i = 0; i < extensions.length; i++) {
|
||||
let extension = extensions[i];
|
||||
isReady = isReady && extension.isActive;
|
||||
if (!isReady) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isReady) {
|
||||
showStatusBarItem(statusBarItem, ALL_EXTENSION_LOADED_TEXT);
|
||||
break;
|
||||
} else {
|
||||
await new Promise(resolve => { setTimeout(resolve, 1000); });
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
});
|
||||
showStatusBarItem(statusBarItem, EXTENSION_LOADED_TEXT);
|
||||
}
|
||||
|
||||
function showStatusBarItem(statusBarItem: vscode.StatusBarItem, text: string) {
|
||||
statusBarItem.text = text;
|
||||
statusBarItem.tooltip = text;
|
||||
statusBarItem.show();
|
||||
clearTimeout(statusBarItemTimer);
|
||||
statusBarItemTimer = setTimeout(function () {
|
||||
statusBarItem.hide();
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
export function deactivate(): void {
|
||||
|
||||
}
|
||||
|
||||
async function setConfiguration(name: string, value: any) {
|
||||
await vscode.workspace.getConfiguration().update(name, value, true);
|
||||
}
|
||||
Reference in New Issue
Block a user