mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
* Fix the launch of backup dialog in server context scenario * Adding wait to ensure sc tasks complete before test exits
This commit is contained in:
@@ -57,24 +57,24 @@ class SchemaCompareTester {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const operationId = 'testOperationId_' + now.getTime().toString();
|
const operationId = 'testOperationId_' + now.getTime().toString();
|
||||||
|
|
||||||
let source: azdata.SchemaCompareEndpointInfo = {
|
let source: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
||||||
packageFilePath: dacpac1,
|
packageFilePath: dacpac1,
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: '',
|
serverName: '',
|
||||||
databaseName: '',
|
databaseName: '',
|
||||||
ownerUri: '',
|
ownerUri: '',
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
let target: azdata.SchemaCompareEndpointInfo = {
|
let target: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
||||||
packageFilePath: dacpac2,
|
packageFilePath: dacpac2,
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: '',
|
serverName: '',
|
||||||
databaseName: '',
|
databaseName: '',
|
||||||
ownerUri: '',
|
ownerUri: '',
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
let schemaCompareResult = await schemaCompareService.schemaCompare(operationId, source, target, azdata.TaskExecutionMode.execute, null);
|
let schemaCompareResult = await schemaCompareService.schemaCompare(operationId, source, target, azdata.TaskExecutionMode.execute, null);
|
||||||
this.assertSchemaCompareResult(schemaCompareResult, operationId);
|
this.assertSchemaCompareResult(schemaCompareResult, operationId);
|
||||||
@@ -111,24 +111,24 @@ class SchemaCompareTester {
|
|||||||
|
|
||||||
assert(schemaCompareService, 'Schema Compare Service Provider is not available');
|
assert(schemaCompareService, 'Schema Compare Service Provider is not available');
|
||||||
|
|
||||||
let source: azdata.SchemaCompareEndpointInfo = {
|
let source: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Database,
|
endpointType: azdata.SchemaCompareEndpointType.Database,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: server.serverName,
|
serverName: server.serverName,
|
||||||
databaseName: sourceDB,
|
databaseName: sourceDB,
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
let target: azdata.SchemaCompareEndpointInfo = {
|
let target: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Database,
|
endpointType: azdata.SchemaCompareEndpointType.Database,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: server.serverName,
|
serverName: server.serverName,
|
||||||
databaseName: targetDB,
|
databaseName: targetDB,
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
let schemaCompareResult = await schemaCompareService.schemaCompare(operationId, source, target, azdata.TaskExecutionMode.execute, null);
|
let schemaCompareResult = await schemaCompareService.schemaCompare(operationId, source, target, azdata.TaskExecutionMode.execute, null);
|
||||||
this.assertSchemaCompareResult(schemaCompareResult, operationId);
|
this.assertSchemaCompareResult(schemaCompareResult, operationId);
|
||||||
@@ -168,24 +168,24 @@ class SchemaCompareTester {
|
|||||||
|
|
||||||
assert(result.success === true, 'Deploy database 2 (target) should succeed');
|
assert(result.success === true, 'Deploy database 2 (target) should succeed');
|
||||||
|
|
||||||
let source: azdata.SchemaCompareEndpointInfo = {
|
let source: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
|
||||||
packageFilePath: dacpac1,
|
packageFilePath: dacpac1,
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: '',
|
serverName: '',
|
||||||
databaseName: '',
|
databaseName: '',
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
let target: azdata.SchemaCompareEndpointInfo = {
|
let target: azdata.SchemaCompareEndpointInfo = {
|
||||||
endpointType: azdata.SchemaCompareEndpointType.Database,
|
endpointType: azdata.SchemaCompareEndpointType.Database,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
serverDisplayName: '',
|
serverDisplayName: '',
|
||||||
serverName: server.serverName,
|
serverName: server.serverName,
|
||||||
databaseName: targetDB,
|
databaseName: targetDB,
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(schemaCompareService, 'Schema Compare Service Provider is not available');
|
assert(schemaCompareService, 'Schema Compare Service Provider is not available');
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class SchemaCompareTester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertSchemaCompareResult(schemaCompareResult: azdata.SchemaCompareResult, operationId : string): void {
|
private assertSchemaCompareResult(schemaCompareResult: azdata.SchemaCompareResult, operationId: string): void {
|
||||||
assert(schemaCompareResult.areEqual === false, `Expected: the schemas are not to be equal Actual: Equal`);
|
assert(schemaCompareResult.areEqual === false, `Expected: the schemas are not to be equal Actual: Equal`);
|
||||||
assert(schemaCompareResult.errorMessage === null, `Expected: there should be no error. Actual Error message: "${schemaCompareResult.errorMessage}"`);
|
assert(schemaCompareResult.errorMessage === null, `Expected: there should be no error. Actual Error message: "${schemaCompareResult.errorMessage}"`);
|
||||||
assert(schemaCompareResult.success === true, `Expected: success in schema compare, Actual: Failure`);
|
assert(schemaCompareResult.success === true, `Expected: success in schema compare, Actual: Failure`);
|
||||||
@@ -221,5 +221,24 @@ class SchemaCompareTester {
|
|||||||
});
|
});
|
||||||
assert(foundTask, 'Could not find Script task');
|
assert(foundTask, 'Could not find Script task');
|
||||||
assert(foundTask.isCancelable, 'The task should be cancellable');
|
assert(foundTask.isCancelable, 'The task should be cancellable');
|
||||||
|
|
||||||
|
if (foundTask.status !== azdata.TaskStatus.Succeeded) {
|
||||||
|
// wait for all tasks completion before exiting test and cleaning up db otherwise tasks fail
|
||||||
|
let retry = 10;
|
||||||
|
let allCompleted = false;
|
||||||
|
while (retry > 0 && !allCompleted) {
|
||||||
|
retry--;
|
||||||
|
await utils.sleep(1000);
|
||||||
|
allCompleted = true;
|
||||||
|
let tasks = await taskService.getAllTasks({ listActiveTasksOnly: true });
|
||||||
|
tasks.tasks.forEach(t => {
|
||||||
|
if (t.status !== azdata.TaskStatus.Succeeded) {
|
||||||
|
allCompleted = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
assert(tasks !== null && tasks.tasks.length > 0, 'Tasks should still show in list. This is to ensure that the tasks actually complete.');
|
||||||
|
assert(allCompleted === true, 'All tasks should be completed.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,6 +257,10 @@ export class BackupAction extends Task {
|
|||||||
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
||||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.commandNotSupported', 'Backup command is not supported for Azure SQL databases.'));
|
return accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.commandNotSupported', 'Backup command is not supported for Azure SQL databases.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!profile.databaseName && profile.providerName === mssqlProviderName) {
|
||||||
|
return accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.commandNotSupportedForServer', 'Backup command is not supported in Server Context. Please select a Database and try again.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskUtilities.showBackup(
|
TaskUtilities.showBackup(
|
||||||
@@ -300,6 +304,10 @@ export class RestoreAction extends Task {
|
|||||||
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
if (serverInfo && serverInfo.isCloud && profile.providerName === mssqlProviderName) {
|
||||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.commandNotSupported', 'Restore command is not supported for Azure SQL databases.'));
|
return accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.commandNotSupported', 'Restore command is not supported for Azure SQL databases.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!profile.databaseName && profile.providerName === mssqlProviderName) {
|
||||||
|
return accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.commandNotSupportedForServer', 'Restore command is not supported in Server Context. Please select a Database and try again.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskUtilities.showRestore(
|
TaskUtilities.showRestore(
|
||||||
|
|||||||
Reference in New Issue
Block a user