mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Fixing integration tests for sts (#1453)
* Fixing test pipeline * pwd * fixing script * fixing cwd * switch to bash * Cleaning up script and yml * Fixing script comment * Fixing the comments * Adding issue in the comment * Adding automatic password generator * Removing unncesary use statement * Fixing key * Printing var * Printing settings * Printing var * Fixed var * Fixed * Reverting some changes * Changing fetch variable to upper case * Fixing password logic * Debug * debug2 * debug * Making passwords secret * Fixing string null check * removed dirs * fixing var name * Fixing var * Printing vars to see if the enviornment is setup correctly * Printing versionkey * removing prints * Adding 2019 Instance key and updating template * fixing env variable * Fixing comment
This commit is contained in:
98
azure-pipelines/createBuildDirectories.sh
Executable file
98
azure-pipelines/createBuildDirectories.sh
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script creates the necessary directories that are required
|
||||
# for the the linux dotnet builds to work. This issue is caused due to a mismatch
|
||||
# in the casing for the localization directories between all the projects and the
|
||||
# nuget packages they are using. This not an issue in the windows because the dirs
|
||||
# are case insensitive.
|
||||
|
||||
|
||||
# To fix the issue, we need to make sure all the projects
|
||||
# and their referenced nuget packages follow the same letter casing for the
|
||||
# locailzation directories.
|
||||
|
||||
# The script need to run from the repo root
|
||||
|
||||
net6projectArray=(
|
||||
"./src/Microsoft.InsightsGenerator"
|
||||
"./src/Microsoft.Kusto.ServiceLayer"
|
||||
"./src/Microsoft.SqlTools.Credentials"
|
||||
"./src/Microsoft.SqlTools.Hosting"
|
||||
"./src/Microsoft.SqlTools.ResourceProvider"
|
||||
"./src/Microsoft.SqlTools.ResourceProvider.Core"
|
||||
"./src/Microsoft.SqlTools.ResourceProvider.DefaultImpl"
|
||||
"./src/Microsoft.SqlTools.ServiceLayer"
|
||||
"./test/Microsoft.InsightsGenerator.UnitTests"
|
||||
"./test/Microsoft.Kusto.ServiceLayer.UnitTests"
|
||||
"./test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.IntegrationTests"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.PerfTests"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.Test.Common"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.TestDriver"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.TestDriver.Tests"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig"
|
||||
"./test/Microsoft.SqlTools.ServiceLayer.UnitTests"
|
||||
"./test/Microsoft.SqlTools.Test.CompletionExtension"
|
||||
)
|
||||
|
||||
netStandard2ProjectArray=(
|
||||
"./src/Microsoft.SqlTools.ManagedBatchParser"
|
||||
)
|
||||
|
||||
# Please update the framework vars when updating target framework for the projects
|
||||
framework6="/bin/Debug/net6.0/"
|
||||
framework2="/bin/Debug/netstandard2.1/"
|
||||
|
||||
requiredLocDirectories=(
|
||||
"cs"
|
||||
"cs-CZ"
|
||||
"de"
|
||||
"de-DE"
|
||||
"es"
|
||||
"es-ES"
|
||||
"fr"
|
||||
"fr-FR"
|
||||
"hu-HU"
|
||||
"it"
|
||||
"it-IT"
|
||||
"ja"
|
||||
"ja-JP"
|
||||
"ko"
|
||||
"ko-KR"
|
||||
"nl-NL"
|
||||
"pl"
|
||||
"pl-PL"
|
||||
"pt-br"
|
||||
"pt-PT"
|
||||
"ru"
|
||||
"ru-RU"
|
||||
"sv-SE"
|
||||
"tr"
|
||||
"tr-TR"
|
||||
"zh-HANS"
|
||||
"zh-hans"
|
||||
"zh-HANT"
|
||||
"zh-hant"
|
||||
)
|
||||
|
||||
for i in "${net6projectArray[@]}"
|
||||
do
|
||||
:
|
||||
for k in "${requiredLocDirectories[@]}"
|
||||
do
|
||||
:
|
||||
output=`mkdir -v -p $i$framework6$k`
|
||||
echo $output
|
||||
done
|
||||
done
|
||||
|
||||
for i in "${netStandard2ProjectArray[@]}"
|
||||
do
|
||||
:
|
||||
for k in "${requiredLocDirectories[@]}"
|
||||
do
|
||||
:
|
||||
output=`mkdir -v -p $i$framework2$k`
|
||||
echo $output
|
||||
done
|
||||
done
|
||||
@@ -1,56 +1,72 @@
|
||||
pool:
|
||||
name: SqlToolsTestAgentPool
|
||||
demands: VisualStudio_16.0
|
||||
name: ads-build-1es-hosted-pool
|
||||
demands:
|
||||
- ImageOverride -equals ADS-Linux_Image
|
||||
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
displayName: 'Download secure file'
|
||||
|
||||
- task: DockerInstaller@0
|
||||
displayName: Installing Docker
|
||||
inputs:
|
||||
secureFile: 'testsettings.json'
|
||||
dockerVersion: 17.09.0-ce
|
||||
releaseType: stable
|
||||
|
||||
- task: VisualStudioTestPlatformInstaller@1
|
||||
displayName: 'Visual Studio Test Platform Installer'
|
||||
inputs:
|
||||
versionSelector: latestStable
|
||||
- script: docker pull mcr.microsoft.com/mssql/server:2019-latest
|
||||
displayName: Pull MSSQL Docker Image
|
||||
|
||||
- bash: echo "##vso[task.setvariable variable=defaultSql2019_password;issecret=true]Test-$(Build.BuildNumber)-$(Get-Date -format yyyyMMdd-Hmmss)"
|
||||
displayName: Generate password for test server
|
||||
|
||||
- script: 'docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=$(defaultSql2019_password)"
|
||||
-e "MSSQL_AGENT_ENABLED=True"
|
||||
-p 1433:1433 --name sql1 -h sql1
|
||||
-d mcr.microsoft.com/mssql/server:2019-latest'
|
||||
displayName: Starting Server in Docker Container
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: 'Use .NET Core sdk '
|
||||
displayName: Use .NET Core SDK
|
||||
inputs:
|
||||
useGlobalJson: true
|
||||
|
||||
- task: Bash@3
|
||||
displayName: Creating Loc Directories Expected By Dotnet Build
|
||||
inputs:
|
||||
filePath: ./azure-pipelines/createBuildDirectories.sh
|
||||
|
||||
- task: NuGetAuthenticate@0
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: 'dotnet build'
|
||||
displayName: Building Test Environment
|
||||
inputs:
|
||||
projects: '**/Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj'
|
||||
|
||||
- task: DownloadSecureFile@1
|
||||
displayName: Download Test Environment Configuration
|
||||
name: testEnvironmentPath
|
||||
inputs:
|
||||
secureFile: 'SQLConnectionInstances.xml'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Setting Up Test Environment
|
||||
inputs:
|
||||
command: run
|
||||
projects: '**/Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj'
|
||||
arguments: $(testEnvironmentPath.secureFilePath)
|
||||
testRunTitle: 'Setting tests'
|
||||
env:
|
||||
defaultSql2019_password: '$(defaultSql2019_password)'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Building Integration Tests
|
||||
inputs:
|
||||
projects: '**/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj'
|
||||
arguments: '/p:CodeCoverageBuild=true'
|
||||
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Copy testsettings file to bin'
|
||||
inputs:
|
||||
SourceFolder: '$(Agent.TempDirectory)'
|
||||
Contents: '**\testsettings.json'
|
||||
TargetFolder: '$(Build.SourcesDirectory)\test\Microsoft.SqlTools.ServiceLayer.IntegrationTests\bin\Debug\net6.0'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: 'Run integration tests'
|
||||
displayName: Running Integration Tests
|
||||
inputs:
|
||||
command: test
|
||||
projects: '**/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj'
|
||||
arguments: '--no-build'
|
||||
testRunTitle: 'SqlToolsService Integration Tests'
|
||||
enabled: false
|
||||
|
||||
- task: VSTest@2
|
||||
displayName: 'Run integration tests with code coverage'
|
||||
inputs:
|
||||
testAssemblyVer2: '**/bin/Debug/**/Microsoft.SqlTools.ServiceLayer.IntegrationTests.dll'
|
||||
vsTestVersion: toolsInstaller
|
||||
runSettingsFile: 'azure-pipelines/testrun.runsettings'
|
||||
codeCoverageEnabled: true
|
||||
testRunTitle: 'SqlToolsService Integration Tests'
|
||||
rerunFailedTests: true
|
||||
rerunFailedThreshold: 15
|
||||
rerunMaxAttempts: 1
|
||||
continueOnError: true
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
public const string DefaultSqlPdwInstanceKey = "defaultSqlPdw";
|
||||
public const string DefaultSqlAzureV12InstanceKey = "defaultSqlAzureV12";
|
||||
public const string DefaultSql2016InstanceKey = "defaultSql2016";
|
||||
public const string DefaultSql2019InstanceKey = "defaultSql2019";
|
||||
public const string DefaultSqlvNextInstanceKey = "defaultSqlvNext";
|
||||
|
||||
private TestConnectionProfileService()
|
||||
@@ -71,6 +72,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
get { return GetInstance(DefaultSql2016InstanceKey); }
|
||||
}
|
||||
|
||||
public static InstanceInfo DefaultSql2019
|
||||
{
|
||||
get { return GetInstance(DefaultSql2019InstanceKey); }
|
||||
}
|
||||
|
||||
public static InstanceInfo DefaultSqlvNext
|
||||
{
|
||||
get { return GetInstance(DefaultSqlvNextInstanceKey); }
|
||||
@@ -87,7 +93,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
return instanceInfo;
|
||||
}
|
||||
|
||||
public ConnectParams GetConnectionParameters(string key = DefaultSql2016InstanceKey, string databaseName = null)
|
||||
public ConnectParams GetConnectionParameters(string key = DefaultSql2019InstanceKey, string databaseName = null)
|
||||
{
|
||||
InstanceInfo instanceInfo = GetInstance(key);
|
||||
if (instanceInfo != null)
|
||||
@@ -170,7 +176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
|
||||
private static string ConvertServerTypeToVersionKey(TestServerType serverType)
|
||||
{
|
||||
return serverType == TestServerType.OnPrem ? DefaultSql2016InstanceKey : DefaultSqlAzureV12InstanceKey;
|
||||
return serverType == TestServerType.OnPrem ? DefaultSql2019InstanceKey : DefaultSqlAzureV12InstanceKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
|
||||
{
|
||||
@@ -94,22 +94,25 @@ namespace Microsoft.SqlTools.ServiceLayer.TestEnvConfig
|
||||
|
||||
private static void SaveSettings(string settingFile)
|
||||
{
|
||||
|
||||
var xdoc = XDocument.Load(settingFile);
|
||||
var settings =
|
||||
from setting in xdoc.Descendants("Instance")
|
||||
select new InstanceInfo(setting.Attribute("VersionKey").Value) // VersionKey is required
|
||||
List<InstanceInfo> settings = new List<InstanceInfo>();
|
||||
|
||||
foreach (var setting in xdoc.Descendants("Instance"))
|
||||
{
|
||||
var passwordEnvVariableValue = Environment.GetEnvironmentVariable((setting.Attribute("VersionKey").Value + "_password"));
|
||||
|
||||
settings.Add(new InstanceInfo(setting.Attribute("VersionKey").Value)
|
||||
{
|
||||
ServerName = setting.Element("DataSource").Value, // DataSource is required
|
||||
ConnectTimeoutAsString = (string)setting.Element("ConnectTimeout"), //ConnectTimeout is optional
|
||||
User = (string)setting.Element("UserId"), // UserID is optional
|
||||
Password = (string)setting.Element("Password"),
|
||||
Password = string.IsNullOrEmpty(passwordEnvVariableValue) ? (string)setting.Element("Password") : passwordEnvVariableValue,
|
||||
RemoteSharePath = (string)setting.Element("RemoteShare"), // RemoteShare is optional
|
||||
AuthenticationType = string.IsNullOrEmpty((string)setting.Element("UserId")) ? AuthenticationType.Integrated : AuthenticationType.SqlLogin
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
TestConfigPersistenceHelper.Write(settings);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Instances>
|
||||
<Instance VersionKey="defaultSql2019">
|
||||
<DataSource>[server name]</DataSource>
|
||||
<UserId>[user name for SQL authentication]</UserId>
|
||||
<Password>[password for SQL authentication]</Password>
|
||||
</Instance>
|
||||
<Instance VersionKey="defaultSql2016">
|
||||
<DataSource>[server name]</DataSource>
|
||||
<UserId>[user name for SQL authentication]</UserId>
|
||||
|
||||
Reference in New Issue
Block a user