mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-08 01:28:29 -05:00
Ledger Objects Representation in Object Explorer (#1615)
* support for ledger objects in OE * generated sr files * update versionKey to sql 2022 in test env config * more 2019 to 2022 updates * add sql2022 instead of replacing * missed filter on table * add logging * more logging * adding Script160Compat options for sql2022 Co-authored-by: Alan Ren <alanren@microsoft.com>
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -471,7 +472,28 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
|
||||
if (!string.IsNullOrEmpty(baseline))
|
||||
{
|
||||
string actual = stringBuilder.ToString();
|
||||
Assert.That(actual, Is.EqualTo(baseline), $"Baseline comparison for {baselineFileName} failed");
|
||||
|
||||
// write output to a bin directory for easier comparison
|
||||
string outputRegeneratedFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||
@"ObjectExplorerServiceTests\Baselines\Regenerated");
|
||||
string outputRegeneratedFilePath = Path.Combine(outputRegeneratedFolder, baselineFileName);
|
||||
string msg = "";
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(outputRegeneratedFolder);
|
||||
File.WriteAllText(outputRegeneratedFilePath, actual);
|
||||
msg = $"Generated output written to :\t{outputRegeneratedFilePath}\n\t" +
|
||||
$"Baseline output located at :\t{GetBaseLineFile(baselineFileName)}";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//We don't want to fail the test completely if we failed to write the regenerated baseline
|
||||
//(especially if the test passed).
|
||||
msg = $"Errors also occurred while attempting to write the new baseline file {outputRegeneratedFilePath} : {e.Message}";
|
||||
}
|
||||
|
||||
Assert.That(actual, Is.EqualTo(baseline), $"Baseline comparison for {baselineFileName} failed\n\t" + msg);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
if (!string.IsNullOrEmpty(instance.Password))
|
||||
{
|
||||
|
||||
|
||||
if (!credentialService.SaveCredential(instance))
|
||||
{
|
||||
Console.WriteLine("Failed to store the password for server: " + instance.ServerName);
|
||||
}
|
||||
|
||||
|
||||
instance.Password = null; //Make sure the password is not stored in sqlConnectionSettings.json
|
||||
instance.AuthenticationType = AuthenticationType.SqlLogin;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
instance.AuthenticationType = AuthenticationType.Integrated;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine("The SQL connection instances will be written to " + DefaultSettingFileName);
|
||||
string jsonContent = JsonConvert.SerializeObject(connectionSetting);
|
||||
|
||||
@@ -133,8 +133,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
testServerNameFilePath = FileUtils.TestServerNamesDefaultFileName;
|
||||
}
|
||||
Console.WriteLine($"Test server name file path: {testServerNameFilePath}");
|
||||
string testServerNamesFileContent = string.IsNullOrEmpty(testServerNameFilePath) ? string.Empty : File.ReadAllText(testServerNameFilePath);
|
||||
|
||||
Console.WriteLine($"Test server name file content: {testServerNamesFileContent}");
|
||||
return testServerNamesFileContent;
|
||||
}
|
||||
|
||||
@@ -171,7 +172,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
}
|
||||
|
||||
string settingsFileContents = string.IsNullOrEmpty(settingsFileName) ? string.Empty : File.ReadAllText(settingsFileName);
|
||||
|
||||
Console.WriteLine($"SQL Connection settings file content: {settingsFileContents}");
|
||||
return settingsFileContents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
public const string DefaultSqlAzureV12InstanceKey = "defaultSqlAzureV12";
|
||||
public const string DefaultSql2016InstanceKey = "defaultSql2016";
|
||||
public const string DefaultSql2019InstanceKey = "defaultSql2019";
|
||||
public const string DefaultSql2022InstanceKey = "defaultSql2022";
|
||||
public const string DefaultSqlvNextInstanceKey = "defaultSqlvNext";
|
||||
|
||||
private TestConnectionProfileService()
|
||||
@@ -72,11 +73,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
get { return GetInstance(DefaultSql2016InstanceKey); }
|
||||
}
|
||||
|
||||
public static InstanceInfo DefaultSql2019
|
||||
public static InstanceInfo DefaultSql2019
|
||||
{
|
||||
get { return GetInstance(DefaultSql2019InstanceKey); }
|
||||
}
|
||||
|
||||
public static InstanceInfo DefaultSql2022
|
||||
{
|
||||
get { return GetInstance(DefaultSql2022InstanceKey); }
|
||||
}
|
||||
|
||||
public static InstanceInfo DefaultSqlvNext
|
||||
{
|
||||
get { return GetInstance(DefaultSqlvNextInstanceKey); }
|
||||
@@ -93,7 +99,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
return instanceInfo;
|
||||
}
|
||||
|
||||
public ConnectParams GetConnectionParameters(string key = DefaultSql2019InstanceKey, string databaseName = null)
|
||||
public ConnectParams GetConnectionParameters(string key = DefaultSql2022InstanceKey, string databaseName = null)
|
||||
{
|
||||
InstanceInfo instanceInfo = GetInstance(key);
|
||||
if (instanceInfo != null)
|
||||
@@ -111,7 +117,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
public ConnectParams GetConnectionParameters(TestServerType serverType = TestServerType.OnPrem, string databaseName = null)
|
||||
{
|
||||
string key = ConvertServerTypeToVersionKey(serverType);
|
||||
return GetConnectionParameters(key, databaseName);
|
||||
return GetConnectionParameters(key, databaseName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,7 +140,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
foreach (var serverIdentity in testServers)
|
||||
{
|
||||
var instance = settings != null ? settings.GetConnectionProfile(serverIdentity.ProfileName, serverIdentity.ServerName) : null;
|
||||
if (instance.ServerType == TestServerType.None)
|
||||
if (instance?.ServerType == TestServerType.None)
|
||||
{
|
||||
instance.ServerType = serverIdentity.ServerType;
|
||||
AddInstance(instance);
|
||||
@@ -149,7 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.True(false, "Fail to load the SQL connection instances. error: " + ex.Message);
|
||||
}
|
||||
@@ -157,6 +163,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
|
||||
private static void AddInstance(InstanceInfo instance)
|
||||
{
|
||||
Console.WriteLine($"Checking whether instance should be added to connections cache, server type: {instance.ServerType.ToString()}, version key: {instance.VersionKey}");
|
||||
if (instance != null && (instance.ServerType != TestServerType.None || !string.IsNullOrEmpty(instance.VersionKey)))
|
||||
{
|
||||
TestServerType serverType = instance.ServerType == TestServerType.None ? TestServerType.OnPrem : instance.ServerType; //Default to onPrem
|
||||
@@ -170,13 +177,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
instance.Password = credential.Password;
|
||||
}
|
||||
connectionProfilesCache.Add(versionKey, instance);
|
||||
Console.WriteLine("Instance added.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Instance already in the cache.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Instance skipped.");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ConvertServerTypeToVersionKey(TestServerType serverType)
|
||||
{
|
||||
return serverType == TestServerType.OnPrem ? DefaultSql2019InstanceKey : DefaultSqlAzureV12InstanceKey;
|
||||
return serverType == TestServerType.OnPrem ? DefaultSql2022InstanceKey : DefaultSqlAzureV12InstanceKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -51,6 +51,59 @@ NodeType: Index Label: NonClusteredIndex-Login (Non-Unique, Non-Clustered) SubTy
|
||||
NodeType: Index Label: PK_Employee_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
||||
NodeType: Statistic Label: NonClusteredIndex-Login SubType: Status:
|
||||
NodeType: Statistic Label: PK_Employee_BusinessEntityID SubType: Status:
|
||||
NodeType: Table Label: HumanResources.Employee_Ledger (Updatable Ledger) SubType:Ledger Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationLevel (Computed, smallint, null) SubType: Status:
|
||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||
NodeType: Column Label: BirthDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: MaritalStatus (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: Gender (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: HireDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: VacationHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: SickLeaveHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
||||
NodeType: HistoryTable Label: HumanResources.Employee_Ledger_History (History) SubType:LedgerHistory Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationLevel (smallint, null) SubType: Status:
|
||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||
NodeType: Column Label: BirthDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: MaritalStatus (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: Gender (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: HireDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: VacationHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: SickLeaveHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_end_transaction_id (bigint, null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_end_sequence_number (bigint, null) SubType: Status:
|
||||
NodeType: Table Label: HumanResources.Employee_Ledger_AppendOnly (Append-Only Ledger) SubType:Ledger Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationLevel (Computed, smallint, null) SubType: Status:
|
||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||
NodeType: Column Label: BirthDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: MaritalStatus (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: Gender (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: HireDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: SalariedFlag (Flag(bit), not null) SubType: Status:
|
||||
NodeType: Column Label: VacationHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: SickLeaveHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: CurrentFlag (Flag(bit), not null) SubType: Status:
|
||||
NodeType: Column Label: rowguid (uniqueidentifier, not null) SubType: Status:
|
||||
NodeType: Column Label: ModifiedDate (datetime, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_transaction_id (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_start_sequence_number (bigint, not null) SubType: Status:
|
||||
NodeType: Table Label: HumanResources.Employee_Temporal (System-Versioned) SubType:Temporal Status:
|
||||
NodeType: Column Label: BusinessEntityID (PK, int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
@@ -107,6 +160,44 @@ NodeType: Constraint Label: DF_Person_ModifiedDate SubType: Status:
|
||||
NodeType: Trigger Label: TableTrigger SubType: Status:
|
||||
NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
||||
NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status:
|
||||
NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationLevel (smallint, null) SubType: Status:
|
||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||
NodeType: Column Label: BirthDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: MaritalStatus (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: Gender (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: HireDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: SalariedFlag (Flag(bit), not null) SubType: Status:
|
||||
NodeType: Column Label: VacationHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: SickLeaveHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: CurrentFlag (Flag(bit), not null) SubType: Status:
|
||||
NodeType: Column Label: rowguid (uniqueidentifier, not null) SubType: Status:
|
||||
NodeType: Column Label: ModifiedDate (datetime, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_transaction_id (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_sequence_number (bigint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
||||
NodeType: View Label: HumanResources.Employee_Ledger_Ledger (Ledger) SubType:Ledger Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||
NodeType: Column Label: OrganizationLevel (smallint, null) SubType: Status:
|
||||
NodeType: Column Label: JobTitle (nvarchar(50), not null) SubType: Status:
|
||||
NodeType: Column Label: BirthDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: MaritalStatus (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: Gender (nchar(1), not null) SubType: Status:
|
||||
NodeType: Column Label: HireDate (date, not null) SubType: Status:
|
||||
NodeType: Column Label: VacationHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: SickLeaveHours (smallint, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
||||
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
||||
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
||||
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
||||
NodeType: View Label: HumanResources.vEmployee SubType: Status:
|
||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||
NodeType: Column Label: Title (nvarchar(8), null) SubType: Status:
|
||||
|
||||
Binary file not shown.
@@ -94,9 +94,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
|
||||
|
||||
private static void SaveSettings(string settingFile)
|
||||
{
|
||||
Console.WriteLine($"settings file content: {File.ReadAllText(settingFile)}");
|
||||
var xdoc = XDocument.Load(settingFile);
|
||||
List<InstanceInfo> settings = new List<InstanceInfo>();
|
||||
|
||||
foreach (var setting in xdoc.Descendants("Instance"))
|
||||
{
|
||||
var passwordEnvVariableValue = Environment.GetEnvironmentVariable((setting.Attribute("VersionKey").Value + "_password"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Instances>
|
||||
<Instance VersionKey="defaultSql2019">
|
||||
<Instance VersionKey="defaultSql2022">
|
||||
<DataSource>[server name]</DataSource>
|
||||
<UserId>[user name for SQL authentication]</UserId>
|
||||
<Password>[password for SQL authentication]</Password>
|
||||
|
||||
Reference in New Issue
Block a user