mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Revert "Rollback migration changes" (#1099)
* Revert "Revert "Initial migration service changes for assessment support (#1093)" (#1098)"
This reverts commit e96c0064ad.
* Move SQL Tools Service last in Main project list
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
<PackageReference Update="Microsoft.SqlServer.DACFx" Version="150.4926.2-preview" GeneratePathProperty="true" />
|
||||
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="8.0.2" />
|
||||
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="8.1.2"/>
|
||||
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="1.0.280-preview" />
|
||||
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20201001.204" />
|
||||
|
||||
<PackageReference Update="Moq" Version="4.8.2" />
|
||||
<PackageReference Update="NUnit" Version="3.12.0" />
|
||||
|
||||
Binary file not shown.
@@ -21,8 +21,8 @@
|
||||
"MainProjects": [
|
||||
"Microsoft.SqlTools.Credentials",
|
||||
"Microsoft.SqlTools.ResourceProvider",
|
||||
"Microsoft.SqlTools.ServiceLayer",
|
||||
"Microsoft.Kusto.ServiceLayer"
|
||||
"Microsoft.Kusto.ServiceLayer",
|
||||
"Microsoft.SqlTools.ServiceLayer"
|
||||
],
|
||||
"PackageProjects": [
|
||||
"Microsoft.SqlTools.CoreServices",
|
||||
|
||||
@@ -17,19 +17,20 @@ using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
|
||||
using Microsoft.SqlTools.ServiceLayer.EditData;
|
||||
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.ServerConfigurations;
|
||||
using Microsoft.SqlTools.ServiceLayer.InsightsGenerator;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageExtensibility;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.Metadata;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration;
|
||||
using Microsoft.SqlTools.ServiceLayer.Profiler;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.SchemaCompare;
|
||||
using Microsoft.SqlTools.ServiceLayer.Scripting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Security;
|
||||
using Microsoft.SqlTools.ServiceLayer.ServerConfigurations;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlAssessment;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||
using Microsoft.SqlTools.ServiceLayer.InsightsGenerator;
|
||||
using Microsoft.SqlTools.ServiceLayer.NotebookConvert;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer
|
||||
@@ -145,6 +146,9 @@ namespace Microsoft.SqlTools.ServiceLayer
|
||||
|
||||
InsightsGeneratorService.Instance.InitializeService(serviceHost);
|
||||
serviceProvider.RegisterSingleService(InsightsGeneratorService.Instance);
|
||||
|
||||
MigrationService.Instance.InitializeService(serviceHost);
|
||||
serviceProvider.RegisterSingleService(MigrationService.Instance);
|
||||
|
||||
InitializeHostedServices(serviceProvider, serviceHost);
|
||||
serviceHost.ServiceProvider = serviceProvider;
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
<PackageReference Include="Microsoft.SqlServer.DACFx" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Assessment" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Migration.Assessment" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="**/obj/**/*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
|
||||
<ProjectReference Include="../Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj" />
|
||||
@@ -39,6 +39,10 @@
|
||||
<Content Include="$(PkgMicrosoft_SqlServer_DacFx)\lib\netstandard2.0\Microsoft.Data.Tools.Schema.SqlTasks.targets">
|
||||
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include=".\Migration\Metadata\**">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<EmbeddedResource Include="ObjectExplorer\SmoModel\TreeNodeDefinition.xml" />
|
||||
<EmbeddedResource Include="Localization\sr.resx" />
|
||||
<None Include="Localization\sr.strings" />
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlServer.Management.Assessment;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item returned by SQL Assessment RPC methods
|
||||
/// </summary>
|
||||
public class ImpactedObjectInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ImpactDetail { get; set; }
|
||||
public string ObjectType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlServer.Management.Assessment;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes an item returned by SQL Assessment RPC methods
|
||||
/// </summary>
|
||||
public class MigrationAssessmentInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets assessment ruleset version.
|
||||
/// </summary>
|
||||
public string RulesetVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets assessment ruleset name
|
||||
/// </summary>
|
||||
public string RulesetName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets assessed target's type.
|
||||
/// Supported values: 1 - server, 2 - database.
|
||||
/// </summary>
|
||||
public SqlObjectType TargetType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the assessed object's name.
|
||||
/// </summary>
|
||||
public string TargetName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets check's ID.
|
||||
/// </summary>
|
||||
public string CheckId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets tags assigned to this item.
|
||||
/// </summary>
|
||||
public string[] Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a display name for this item.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a brief description of the item's purpose.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="string"/> containing
|
||||
/// an link to a page providing detailed explanation
|
||||
/// of the best practice.
|
||||
/// </summary>
|
||||
public string HelpLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="string"/> indicating
|
||||
/// severity level assigned to this items.
|
||||
/// Values are: "Information", "Warning", "Critical".
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public string AppliesToMigrationTargetPlatform { get; set; }
|
||||
|
||||
public string IssueCategory { get; set; }
|
||||
|
||||
public ImpactedObjectInfo[] ImpactedObjects { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
||||
{
|
||||
public class MigrationAssessmentsParams
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
}
|
||||
|
||||
public class MigrationAssessmentResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection of assessment results.
|
||||
/// </summary>
|
||||
public List<MigrationAssessmentInfo> Items { get; } = new List<MigrationAssessmentInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating
|
||||
/// if assessment operation was successful.
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an status message for the operation.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retreive metadata for the table described in the TableMetadataParams value
|
||||
/// </summary>
|
||||
public class MigrationAssessmentsRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<MigrationAssessmentsParams, MigrationAssessmentResult> Type =
|
||||
RequestType<MigrationAssessmentsParams, MigrationAssessmentResult>.Create("migration/getassessments");
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"Name": "Migration Assessment Feature Metadata",
|
||||
"SchemaVersion": "0.1",
|
||||
"Version": "0.1",
|
||||
"Checks": [
|
||||
{
|
||||
"target": {},
|
||||
"id": "LinkedServer",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Linked server functionality",
|
||||
"description": "Linked servers enable the SQL Server Database Engine to execute commands against OLE DB data sources outside of the instance of SQL Server.",
|
||||
"message": "Linked servers enable the SQL Server Database Engine to execute commands against OLE DB data sources outside of the instance of SQL Server.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=872319",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "Filestream",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Filestream",
|
||||
"description": "The Filestream feature allows you to store unstructured data such as text documents, images, and videos in NTFS file system.",
|
||||
"message": "The Filestream feature allows you to store unstructured data such as text documents, images, and videos in NTFS file system.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=872319",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "MultipleLogFiles",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Multiple log files",
|
||||
"description": "SQL Server allows a database to log to multiple files. This database has multiple log files.",
|
||||
"message": "SQL Server allows a database to log to multiple files. This database has multiple log files.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=872319",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "ServiceBroker",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Service broker",
|
||||
"description": "SQL Server Service Broker provides native support for messaging and queuing applications in the SQL Server Database Engine.",
|
||||
"message": "SQL Server Service Broker provides native support for messaging and queuing applications in the SQL Server Database Engine.",
|
||||
"helpLink": "https://aka.ms/service-bus-messaging",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "SysDatabases",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "System databases features",
|
||||
"description": "Collecting source databases features from sys.databases",
|
||||
"message": "Collecting source databases features from sys.databases",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "UnsupportedObjectTypes",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Unsupported object types",
|
||||
"description": "Collecting unsupported objects from sys.objects",
|
||||
"message": "Collecting unsupported objects from sys.objects",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "AgentJobs",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Agent jobs",
|
||||
"description": "SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks, which are called jobs in SQL Server.",
|
||||
"message": "SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks, which are called jobs in SQL Server.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838286",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "Configurations",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "System configurations",
|
||||
"description": "SQL Server provides several types of encryption that help protect sensitive data, including Transparent Data Encryption (TDE), Column Level Encryption (CLE), and Backup Encryption. In all of these cases, in this traditional key hierarchy, the data is encrypted using a symmetric data encryption key (DEK). The symmetric data encryption key is further protected by encrypting it with a hierarchy of keys stored in SQL Server. Instead of this model, the alternative is the EKM Provider Model. Using the EKM provider architecture enables SQL Server to protect the data encryption keys by using an asymmetric key stored outside of SQL Server in an external cryptographic provider. This model adds an additional layer of security and separates the management of keys and data.",
|
||||
"message": "SQL Server provides several types of encryption that help protect sensitive data, including Transparent Data Encryption (TDE), Column Level Encryption (CLE), and Backup Encryption. In all of these cases, in this traditional key hierarchy, the data is encrypted using a symmetric data encryption key (DEK). The symmetric data encryption key is further protected by encrypting it with a hierarchy of keys stored in SQL Server. Instead of this model, the alternative is the EKM Provider Model. Using the EKM provider architecture enables SQL Server to protect the data encryption keys by using an asymmetric key stored outside of SQL Server in an external cryptographic provider. This model adds an additional layer of security and separates the management of keys and data.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838286",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "DatabaseFilesMaxCountLimitation",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Databse files max count limitation",
|
||||
"description": "Max number of database files per Managed Instance in general purpose is up to 280, unless the instance storage size(max 2TB - 8TB) and Azure premium Disk storage allocation space limit has been reached.",
|
||||
"message": "Max number of database files per Managed Instance in general purpose is up to 280, unless the instance storage size(max 2TB - 8TB) and Azure premium Disk storage allocation space limit has been reached.",
|
||||
"helpLink": "https://aka.ms/mi-resource-limits",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "DatabaseMails",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Databse mails",
|
||||
"description": "",
|
||||
"message": "",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "DataCollection",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Data collection",
|
||||
"description": "The data collector is a component of SQL Server that collects different sets of data. Data collection either runs constantly or on a user-defined schedule. The data collector stores the collected data in a relational database known as the management data warehouse.",
|
||||
"message": "The data collector is a component of SQL Server that collects different sets of data. Data collection either runs constantly or on a user-defined schedule. The data collector stores the collected data in a relational database known as the management data warehouse.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838301",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "InstalledServices",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Installed services",
|
||||
"description": "Query the info of installed services like SSAS, SSRS, browser service, stream insight, RServices, MDS, DQS, certificate.",
|
||||
"message": "Query the info of installed services like SSAS, SSRS, browser service, stream insight, RServices, MDS, DQS, certificate.",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "MaintenancePlans",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Maintenance plans",
|
||||
"description": "SQL Server maintenance plans are used to automate various database administration tasks, including backups, database integrity checks, or database statistics updates, at specified intervals.",
|
||||
"message": "SQL Server maintenance plans are used to automate various database administration tasks, including backups, database integrity checks, or database statistics updates, at specified intervals.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838279",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "UserDefinedErrorMessages",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "User defined error messages",
|
||||
"description": "The sp_addmessage system stored procedure lets you add error messages to SQL Server that can be referenced in code. This is helpful for standardized error messages that will be used throughout your application, especially if they need to be able to support multiple languages, but not so much for ad-hoc error messages. But this feature is not supported in Azure SQL Database.",
|
||||
"message": "The sp_addmessage system stored procedure lets you add error messages to SQL Server that can be referenced in code. This is helpful for standardized error messages that will be used throughout your application, especially if they need to be able to support multiple languages, but not so much for ad-hoc error messages. But this feature is not supported in Azure SQL Database.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838295",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "PolicyBasedManagement",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Policy-Based Management",
|
||||
"description": "Policy-Based Management is a policy-based system for managing one or more instances of SQL Server. It is used to create conditions that contain condition expressions and then create policies that apply the conditions to database target objects.",
|
||||
"message": "Policy-Based Management is a policy-based system for managing one or more instances of SQL Server. It is used to create conditions that contain condition expressions and then create policies that apply the conditions to database target objects.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838285",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "ServerAudits",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Server audits",
|
||||
"description": "Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine. SQL Server audit lets you create server audits, which can contain server audit specifications for server level events, and database audit specifications for database level events.",
|
||||
"message": "Auditing an instance of the SQL Server Database Engine or an individual database involves tracking and logging events that occur on the Database Engine. SQL Server audit lets you create server audits, which can contain server audit specifications for server level events, and database audit specifications for database level events.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=872319",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "ServerCredentials",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Server credentials",
|
||||
"description": "A credential is a record that contains the authentication information (credentials) required to connect to a resource outside SQL Server.",
|
||||
"message": "A credential is a record that contains the authentication information (credentials) required to connect to a resource outside SQL Server.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838290",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "ServerProperties",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Server properties",
|
||||
"description": "Collects SERVERPROPERTIES like IsClustered, IsIntegratedSecurityOnly, IsPolyBaseInstalled and IsBufferPoolExtensionEnabled.",
|
||||
"message": "Collects SERVERPROPERTIES like IsClustered, IsIntegratedSecurityOnly, IsPolyBaseInstalled and IsBufferPoolExtensionEnabled.",
|
||||
"helpLink": "https://go.microsoft.com/fwlink/?linkid=838290",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "ServerTriggers",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Server scoped triggers",
|
||||
"description": "A trigger is a special kind of stored procedure that executes in response to certain action on a table like insertion, deletion or updating of data.",
|
||||
"message": "A trigger is a special kind of stored procedure that executes in response to certain action on a table like insertion, deletion or updating of data.",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "TraceFlags",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Trace flags",
|
||||
"description": "Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior. Trace flags are frequently used to diagnose performance issues or to debug stored procedures or complex computer systems.",
|
||||
"message": "Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior. Trace flags are frequently used to diagnose performance issues or to debug stored procedures or complex computer systems.",
|
||||
"helpLink": "",
|
||||
"level": "Critical"
|
||||
},
|
||||
{
|
||||
"target": {},
|
||||
"id": "TSqlScript",
|
||||
"tags": [ "Feature" ],
|
||||
"displayName": "Analyzing TSQL script",
|
||||
"description": "Collect TSQL scripts and using TSqlScriptDom to analyze the scripts",
|
||||
"level": "Critical"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlServer.Management.Assessment;
|
||||
using Microsoft.SqlServer.Management.Assessment.Checks;
|
||||
using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.Models;
|
||||
using Microsoft.SqlServer.Migration.Assessment.Common.Engine;
|
||||
using Microsoft.SqlServer.Migration.Assessment.Common.Models;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlAssessment;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlAssessment.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Migration
|
||||
{
|
||||
/// <summary>
|
||||
/// Main class for Migration Service functionality
|
||||
/// </summary>
|
||||
public sealed class MigrationService : IDisposable
|
||||
{
|
||||
private static ConnectionService connectionService = null;
|
||||
|
||||
private static readonly Lazy<MigrationService> instance = new Lazy<MigrationService>(() => new MigrationService());
|
||||
|
||||
private bool disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new MigrationService instance with default parameters
|
||||
/// </summary>
|
||||
public MigrationService()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the singleton instance object
|
||||
/// </summary>
|
||||
public static MigrationService Instance
|
||||
{
|
||||
get { return instance.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only
|
||||
/// </summary>
|
||||
internal static ConnectionService ConnectionService
|
||||
{
|
||||
get
|
||||
{
|
||||
if (connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
return connectionService;
|
||||
}
|
||||
set
|
||||
{
|
||||
connectionService = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Engine"/> used to run assessment operations.
|
||||
/// </summary>
|
||||
internal Engine Engine { get; } = new Engine();
|
||||
|
||||
/// <summary>
|
||||
/// Service host object for sending/receiving requests/events.
|
||||
/// Internal for testing purposes.
|
||||
/// </summary>
|
||||
internal IProtocolEndpoint ServiceHost
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Migration Service instance
|
||||
/// </summary>
|
||||
public void InitializeService(ServiceHost serviceHost)
|
||||
{
|
||||
this.ServiceHost = serviceHost;
|
||||
this.ServiceHost.SetRequestHandler(MigrationAssessmentsRequest.Type, HandleMigrationAssessmentsRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle request to start a migration session
|
||||
/// </summary>
|
||||
internal async Task HandleMigrationAssessmentsRequest(
|
||||
MigrationAssessmentsParams parameters,
|
||||
RequestContext<MigrationAssessmentResult> requestContext)
|
||||
{
|
||||
string randomUri = Guid.NewGuid().ToString();
|
||||
try
|
||||
{
|
||||
// get connection
|
||||
if (!ConnectionService.TryFindConnection(parameters.OwnerUri, out var connInfo))
|
||||
{
|
||||
await requestContext.SendError("Could not find migration connection");
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectParams connectParams = new ConnectParams
|
||||
{
|
||||
OwnerUri = randomUri,
|
||||
Connection = connInfo.ConnectionDetails,
|
||||
Type = ConnectionType.Default
|
||||
};
|
||||
|
||||
await ConnectionService.Connect(connectParams);
|
||||
|
||||
var connection = await ConnectionService.Instance.GetOrOpenConnection(randomUri, ConnectionType.Default);
|
||||
|
||||
var serverInfo = ReliableConnectionHelper.GetServerVersion(connection);
|
||||
var hostInfo = ReliableConnectionHelper.GetServerHostInfo(connection);
|
||||
|
||||
var server = new SqlObjectLocator
|
||||
{
|
||||
Connection = connection,
|
||||
EngineEdition = SqlAssessmentService.GetEngineEdition(serverInfo.EngineEditionId),
|
||||
Name = serverInfo.ServerName,
|
||||
ServerName = serverInfo.ServerName,
|
||||
Type = SqlObjectType.Server,
|
||||
Urn = serverInfo.ServerName,
|
||||
Version = Version.Parse(serverInfo.ServerVersion),
|
||||
Platform = hostInfo.Platform
|
||||
};
|
||||
|
||||
var db = SqlAssessmentService.GetDatabaseLocator(server, connection.Database);
|
||||
|
||||
var results = await GetAssessmentItems(server);
|
||||
var result = new MigrationAssessmentResult();
|
||||
result.Items.AddRange(results);
|
||||
await requestContext.SendResult(result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ConnectionService.Disconnect(new DisconnectParams { OwnerUri = randomUri, Type = null });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class AssessmentRequest : IAssessmentRequest
|
||||
{
|
||||
private readonly Check[] checks = null;
|
||||
|
||||
public AssessmentRequest(ISqlObjectLocator locator)
|
||||
{
|
||||
Target = locator ?? throw new ArgumentNullException(nameof(locator));
|
||||
}
|
||||
|
||||
public EvaluationContext<object> EvaluationContext { get; }
|
||||
|
||||
public ISqlObjectLocator Target { get; }
|
||||
|
||||
public IEnumerable<Check> Checks
|
||||
{
|
||||
get
|
||||
{
|
||||
return checks;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetData(string column, out object value)
|
||||
{
|
||||
return EvaluationContext.TryGetData(column, out value);
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<List<MigrationAssessmentInfo>> GetAssessmentItems(SqlObjectLocator target)
|
||||
{
|
||||
DmaEngine engine = new DmaEngine(target);
|
||||
var assessmentResults = await engine.GetTargetAssessmentResultsList();
|
||||
|
||||
var result = new List<MigrationAssessmentInfo>();
|
||||
foreach (var r in assessmentResults)
|
||||
{
|
||||
var migrationResult = r as ISqlMigrationAssessmentResult;
|
||||
if (migrationResult == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var targetName = !string.IsNullOrWhiteSpace(migrationResult.DatabaseName)
|
||||
? $"{target.ServerName}:{migrationResult.DatabaseName}"
|
||||
: target.Name;
|
||||
|
||||
var item = new MigrationAssessmentInfo()
|
||||
{
|
||||
CheckId = r.Check.Id,
|
||||
Description = r.Check.Description,
|
||||
DisplayName = r.Check.DisplayName,
|
||||
HelpLink = r.Check.HelpLink,
|
||||
Level = r.Check.Level.ToString(),
|
||||
TargetName = targetName,
|
||||
Tags = r.Check.Tags.ToArray(),
|
||||
TargetType = target.Type,
|
||||
RulesetName = Engine.Configuration.DefaultRuleset.Name,
|
||||
RulesetVersion = Engine.Configuration.DefaultRuleset.Version.ToString(),
|
||||
Message = r.Message,
|
||||
AppliesToMigrationTargetPlatform = migrationResult.AppliesToMigrationTargetPlatform.ToString(),
|
||||
IssueCategory = "Category_Unknown"
|
||||
};
|
||||
|
||||
if (migrationResult.ImpactedObjects != null)
|
||||
{
|
||||
ImpactedObjectInfo[] impactedObjects = new ImpactedObjectInfo[migrationResult.ImpactedObjects.Count];
|
||||
for (int i = 0; i < migrationResult.ImpactedObjects.Count; ++i)
|
||||
{
|
||||
var impactedObject = new ImpactedObjectInfo()
|
||||
{
|
||||
Name = migrationResult.ImpactedObjects[i].Name,
|
||||
ImpactDetail = migrationResult.ImpactedObjects[i].ImpactDetail,
|
||||
ObjectType = migrationResult.ImpactedObjects[i].ObjectType
|
||||
};
|
||||
impactedObjects[i] = impactedObject;
|
||||
}
|
||||
item.ImpactedObjects = impactedObjects;
|
||||
}
|
||||
|
||||
result.Add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the Migration Service
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Remove=".\Agent\NotebookResources\TestNotebook.ipynb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include=".\Agent\NotebookResources\TestNotebook.ipynb" />
|
||||
</ItemGroup>
|
||||
<Content Include="..\..\src\Microsoft.SqlTools.ServiceLayer\Migration\Metadata\**">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration;
|
||||
using Microsoft.SqlTools.ServiceLayer.Migration.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlAssessment.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Migration
|
||||
{
|
||||
public class MigrationgentServiceTests
|
||||
{
|
||||
[Test]
|
||||
public async Task TestHandleMigrationAssessmentRequest()
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
||||
|
||||
var requestParams = new MigrationAssessmentsParams()
|
||||
{
|
||||
OwnerUri = connectionResult.ConnectionInfo.OwnerUri
|
||||
};
|
||||
|
||||
var requestContext = new Mock<RequestContext<MigrationAssessmentResult>>();
|
||||
|
||||
MigrationService service = new MigrationService();
|
||||
await service.HandleMigrationAssessmentsRequest(requestParams, requestContext.Object);
|
||||
requestContext.VerifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user