Skip to content

Commit f51ab74

Browse files
authored
Adding integration test runs for PRs (#2619)
* Inital integration test commit * Changing password format * Upodating global JSON location * trying this * removing working directory * building code * modern cake run * updated cake with built-in Xliff transformer * Slash direction changes * with SRGen * fixing cake tool install paths * No-oping .NET Framework version of XUnit if no tests target Framework * Adding log upload on failure * trying some path normalization * running precreation script * Adding missing project * handling release in addition to debug * normalizing lang variants * Not crashing when a late notification arrives to a completed queue. * Fixing some slash directions * adding logging * timeout on test step * Skipping problem test * commenting out NonTsql tests * debugging * Tracking disposal * lint error * Disposals * Skipping LangServiceTests for now * working on PR pipeline now * Platform independent nuget cli call * Comment for nuget CLI * Improving check * removing experimental flag * rename * Copying changes to ADO pipeline * default linux image * Slimming build step * Converting to pwsh * Removing mono from bootstrapper * Adding back RESX header comment and schema * Reverting the translated tags * Skipping broken tests * fixing slash direction * Some integration test fixes * fixing pipeline names * Removing dead xunit check * reverting changes from debugging lang service * PR feedback cleanup * more PR cleanup * moving xliff helpers to separate file * consolidating test name sanitization * Cleaning up changes * Updating comment * Cleaning up outdated comment * Adding back graceful handling of thread queue exit
1 parent 1218567 commit f51ab74

File tree

124 files changed

+18682
-9487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+18682
-9487
lines changed

.github/workflows/integration-test.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: Integration Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
push:
7+
branches:
8+
- main
9+
- release/*
10+
pull_request:
11+
branches:
12+
- main
13+
- release/*
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
actions: read
19+
checks: write
20+
21+
jobs:
22+
integration-tests:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Setup .NET SDK
30+
uses: actions/setup-dotnet@v4
31+
with:
32+
global-json-file: global.json
33+
34+
- name: Generate SQL authentication password
35+
shell: pwsh
36+
run: |
37+
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.ToCharArray()
38+
$passwordBody = -join (1..24 | ForEach-Object { $chars[(Get-Random -Maximum $chars.Length)] })
39+
$sqlPassword = "A1!b$passwordBody" # 'A1!' prefix is to meet password complexity requirements for SQL
40+
Write-Output "::add-mask::$sqlPassword"
41+
Add-Content -Path $env:GITHUB_ENV -Value "SQL_PASSWORD=$sqlPassword"
42+
Add-Content -Path $env:GITHUB_ENV -Value "sqlOnPrem_password=$sqlPassword"
43+
Add-Content -Path $env:GITHUB_ENV -Value "sqlAzure_password=$sqlPassword"
44+
45+
- name: Install Cake tools
46+
shell: pwsh
47+
run: |
48+
dotnet tool install --tool-path ./.tools Cake.Tool
49+
dotnet tool install --tool-path ./.tools dotnet-t4
50+
51+
- name: Build repository
52+
shell: pwsh
53+
run: |
54+
./.tools/dotnet-cake build.cake --target=all
55+
56+
- name: Upload build logs
57+
if: failure()
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: cake-build-logs
61+
path: artifacts/logs
62+
if-no-files-found: ignore
63+
64+
- name: Start SQL Server container
65+
shell: pwsh
66+
run: |
67+
docker pull mcr.microsoft.com/mssql/server:2025-latest
68+
docker rm -f sqltoolsservice-integration-tests *> $null
69+
docker run `
70+
--detach `
71+
--name sqltoolsservice-integration-tests `
72+
--hostname sqltoolsservice-integration-tests `
73+
--publish 1433:1433 `
74+
--env ACCEPT_EULA=Y `
75+
--env MSSQL_PID=Developer `
76+
--env MSSQL_AGENT_ENABLED=true `
77+
--env MSSQL_SA_PASSWORD="$env:SQL_PASSWORD" `
78+
mcr.microsoft.com/mssql/server:2025-latest
79+
80+
- name: Create SQL login for integration tests
81+
shell: pwsh
82+
run: |
83+
$ready = $false
84+
for ($attempt = 1; $attempt -le 30; $attempt++) {
85+
docker exec sqltoolsservice-integration-tests /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $env:SQL_PASSWORD -C -Q "SELECT 1" *> $null
86+
if ($LASTEXITCODE -eq 0) {
87+
$ready = $true
88+
break
89+
}
90+
91+
Start-Sleep -Seconds 5
92+
}
93+
94+
if (-not $ready) {
95+
throw "SQL Server container did not become ready in time."
96+
}
97+
98+
$sql = "IF NOT EXISTS (SELECT 1 FROM sys.sql_logins WHERE name = 'testAccount') BEGIN CREATE LOGIN [testAccount] WITH PASSWORD = '$($env:SQL_PASSWORD)', CHECK_POLICY = OFF; END; ALTER SERVER ROLE [sysadmin] ADD MEMBER [testAccount];"
99+
docker exec sqltoolsservice-integration-tests /opt/mssql-tools18/bin/sqlcmd `
100+
-S localhost `
101+
-U sa `
102+
-P $env:SQL_PASSWORD `
103+
-C `
104+
-Q $sql
105+
106+
- name: Create integration test connection instances file
107+
shell: pwsh
108+
run: |
109+
@'
110+
<?xml version="1.0" encoding="utf-8"?>
111+
<Instances>
112+
<Instance VersionKey="sqlOnPrem">
113+
<DataSource>localhost</DataSource>
114+
<UserId>testAccount</UserId>
115+
<Password></Password>
116+
</Instance>
117+
<Instance VersionKey="sqlAzure">
118+
<DataSource>localhost</DataSource>
119+
<UserId>testAccount</UserId>
120+
<Password></Password>
121+
</Instance>
122+
</Instances>
123+
'@ | Set-Content -Path test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/SQLConnectionInstances.CI.xml
124+
125+
- name: Generate integration test settings
126+
shell: pwsh
127+
run: |
128+
dotnet run `
129+
--project test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj `
130+
-- `
131+
test/Microsoft.SqlTools.ServiceLayer.TestEnvConfig/SQLConnectionInstances.CI.xml
132+
133+
- name: Build integration tests
134+
shell: pwsh
135+
run: |
136+
dotnet build test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj --configuration Release
137+
138+
- name: Run integration tests
139+
id: integration_tests
140+
continue-on-error: true
141+
timeout-minutes: 60
142+
shell: pwsh
143+
run: |
144+
dotnet test test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj `
145+
--configuration Release `
146+
--no-build `
147+
--logger "trx;LogFileName=IntegrationTests.trx" `
148+
--results-directory "$PWD/TestResults"
149+
150+
- name: Publish integration test report
151+
if: always()
152+
uses: dorny/test-reporter@v1
153+
with:
154+
name: Integration Tests
155+
path: TestResults/*.trx
156+
reporter: dotnet-trx
157+
fail-on-error: false
158+
159+
- name: Upload integration test results
160+
if: always()
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: integration-test-results
164+
path: TestResults/*.trx
165+
if-no-files-found: ignore
166+
167+
- name: Stop SQL container
168+
if: always()
169+
shell: pwsh
170+
run: docker rm -f sqltoolsservice-integration-tests *> $null
171+
172+
- name: Fail workflow when integration tests fail
173+
if: steps.integration_tests.outcome == 'failure'
174+
shell: pwsh
175+
run: exit 1

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<DebugType>full</DebugType>
55
<DebugSymbols>true</DebugSymbols>
66
</PropertyGroup>
7-
</Project>
7+
</Project>

azure-pipelines/build.yml

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,31 @@ steps:
6969
inputs:
7070
useGlobalJson: true
7171

72-
- task: PowerShell@2
72+
- task: NuGetToolInstaller@1
73+
displayName: 'Install NuGet'
74+
75+
- pwsh: |
76+
dotnet tool install --tool-path ./.tools Cake.Tool
77+
dotnet tool install --tool-path ./.tools dotnet-t4
78+
displayName: 'Install Cake tools'
79+
80+
- pwsh: |
81+
$projectFile = '$(Build.SourcesDirectory)/src/Microsoft.SqlTools.SqlCore/Microsoft.SqlTools.SqlCore.csproj'
82+
$props = New-Object XML
83+
$props.Load($projectFile)
84+
$version = ($(Major)).ToString() + '.' + ($(Minor)).ToString() + '.' + $(Patch) + $(Build.BuildNumber);
85+
$props.Project.PropertyGroup.Version = $version;
86+
$props.Save($projectFile)
7387
displayName: 'Add version number to SqlCore project for packaging'
74-
inputs:
75-
targetType: 'inline'
76-
script: |
77-
$projectFile = '$(Build.SourcesDirectory)\src\Microsoft.SqlTools.SqlCore\Microsoft.SqlTools.SqlCore.csproj'
78-
$props = New-Object XML
79-
$props.Load($projectFile)
80-
$version = ($(Major)).ToString() + '.' + ($(Minor)).ToString() + '.' + $(Patch) + $(Build.BuildNumber);
81-
$props.Project.PropertyGroup.Version = $version;
82-
$props.Save($projectFile)
8388

8489
- task: CodeQL3000Init@0
8590
displayName: 'CodeQL Initialize'
8691
condition: eq(variables['Codeql.enabled'], 'True')
8792

88-
- task: BatchScript@1
89-
displayName: 'Run script build.cmd'
90-
inputs:
91-
filename: build.cmd
92-
arguments: '-target=all -mono'
93-
93+
- pwsh: |
94+
./.tools/dotnet-cake build.cake --target=all
95+
displayName: 'Run Cake build'
96+
9497
- task: DotNetCoreCLI@2
9598
displayName: 'dotnet restore test/Microsoft.SqlTools.ServiceLayer.UnitTests'
9699
inputs:
@@ -125,7 +128,7 @@ steps:
125128
displayName: Create Code coverage report
126129

127130

128-
- powershell: |
131+
- pwsh: |
129132
$ProgressPreference = 'SilentlyContinue'
130133
Invoke-WebRequest -Uri https://keybase.io/codecovsecurity/pgp_keys.asc -OutFile codecov.asc
131134
gpg.exe --import codecov.asc
@@ -151,26 +154,23 @@ steps:
151154
codeCoverageTool: 'Cobertura'
152155
summaryFileLocation: '$(Agent.TempDirectory)/coverlet/reports/Cobertura.xml'
153156

154-
- task: PowerShell@2
157+
- pwsh: |
158+
$projectFile = '$(Build.SourcesDirectory)\src\Microsoft.SqlTools.ManagedBatchParser\Microsoft.SqlTools.ManagedBatchParser.csproj'
159+
$props = New-Object XML
160+
$props.Load($projectFile)
161+
$propGroup = $props.Project.PropertyGroup;
162+
$versionPre = $env:ManagedBatchParserMajor + '.' + $env:ManagedBatchParserMinor + '.'
163+
if($env:StableRelease.Equals('true')) {
164+
$version = $versionPre + '0';
165+
} else {
166+
$version = $versionPre + $(Build.BuildNumber) + '-' + $propGroup.VersionSuffix.'#text'
167+
}
168+
$nuspecFile = '$(Build.SourcesDirectory)\packages\Microsoft.SqlTools.ManagedBatchParser\Microsoft.SqlTools.ManagedBatchParser.nuspec'
169+
$nuspec = New-Object XML
170+
$nuspec.Load($nuspecFile)
171+
$nuspec.package.metadata.version = $version;
172+
$nuspec.Save($nuspecFile)
155173
displayName: 'Generate ManagedBatchParser Nuspec Version'
156-
inputs:
157-
targetType: 'inline'
158-
script: |
159-
$projectFile = '$(Build.SourcesDirectory)\src\Microsoft.SqlTools.ManagedBatchParser\Microsoft.SqlTools.ManagedBatchParser.csproj'
160-
$props = New-Object XML
161-
$props.Load($projectFile)
162-
$propGroup = $props.Project.PropertyGroup;
163-
$versionPre = $env:ManagedBatchParserMajor + '.' + $env:ManagedBatchParserMinor + '.'
164-
if($env:StableRelease.Equals('true')) {
165-
$version = $versionPre + '0';
166-
} else {
167-
$version = $versionPre + $(Build.BuildNumber) + '-' + $propGroup.VersionSuffix.'#text'
168-
}
169-
$nuspecFile = '$(Build.SourcesDirectory)\packages\Microsoft.SqlTools.ManagedBatchParser\Microsoft.SqlTools.ManagedBatchParser.nuspec'
170-
$nuspec = New-Object XML
171-
$nuspec.Load($nuspecFile)
172-
$nuspec.package.metadata.version = $version;
173-
$nuspec.Save($nuspecFile)
174174

175175
- task: Npm@1
176176
displayName: 'npm install -g gulp-cli'
@@ -186,19 +186,15 @@ steps:
186186
custom: pack
187187
arguments: '--output $(Build.SourcesDirectory)\artifacts\nugetPackages --no-build --configuration $(buildConfiguration) -v n src\Microsoft.SqlTools.SqlCore\Microsoft.SqlTools.SqlCore.csproj'
188188

189-
- task: BatchScript@1
189+
- pwsh: |
190+
./.tools/dotnet-cake build.cake --target=NugetPackNuspec
190191
displayName: 'Package nuspec projects'
191-
inputs:
192-
filename: build.cmd
193-
arguments: '-target=NugetPackNuspec -mono'
194-
195-
- task: BatchScript@1
196-
displayName: "Build and Package service tool projects"
192+
193+
- pwsh: |
194+
./.tools/dotnet-cake build.cake --target=dotnetpackservicetools
195+
displayName: 'Build and Package service tool projects'
197196
env:
198197
BUILD_DOTNET_TOOL: "true"
199-
inputs:
200-
filename: build.cmd
201-
arguments: "-target=dotnetpackservicetools -mono"
202198

203199
- ${{ each project in parameters.projects }}:
204200
- ${{ each platform in parameters.platforms }}:
@@ -253,4 +249,4 @@ steps:
253249
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
254250
displayName: 'Component Detection'
255251
inputs:
256-
failOnAlert: true
252+
failOnAlert: true

azure-pipelines/createBuildDirectories.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# The script need to run from the repo root
1818

1919
dotnetProjectArray=(
20-
"./src/Microsoft.Kusto.ServiceLayer"
2120
"./src/Microsoft.SqlTools.Credentials"
2221
"./src/Microsoft.SqlTools.Hosting"
2322
"./src/Microsoft.SqlTools.ResourceProvider"
@@ -26,7 +25,7 @@ dotnetProjectArray=(
2625
"./src/Microsoft.SqlTools.ServiceLayer"
2726
"./src/Microsoft.SqlTools.Migration"
2827
"./src/Microsoft.SqlTools.SqlCore"
29-
"./test/Microsoft.Kusto.ServiceLayer.UnitTests"
28+
"./test/Microsoft.SqlTools.Authentication.UnitTests"
3029
"./test/Microsoft.SqlTools.ManagedBatchParser.IntegrationTests"
3130
"./test/Microsoft.SqlTools.ServiceLayer.IntegrationTests"
3231
"./test/Microsoft.SqlTools.ServiceLayer.PerfTests"
@@ -38,8 +37,10 @@ dotnetProjectArray=(
3837
"./test/Microsoft.SqlTools.Test.CompletionExtension"
3938
)
4039

41-
# Please update the framework vars when updating target framework for the projects
42-
framework8="/bin/Debug/net8.0/"
40+
configurations=(
41+
"Debug"
42+
"Release"
43+
)
4344

4445
requiredLocDirectories=(
4546
"pt-br"
@@ -53,10 +54,13 @@ requiredLocDirectories=(
5354
for i in "${dotnetProjectArray[@]}"
5455
do
5556
:
56-
for k in "${requiredLocDirectories[@]}"
57-
do
58-
:
59-
output=`mkdir -v -p $i$framework8$k`
60-
echo $output
57+
for configuration in "${configurations[@]}"
58+
do
59+
for k in "${requiredLocDirectories[@]}"
60+
do
61+
:
62+
output=`mkdir -v -p "$i/bin/$configuration/net8.0/$k"`
63+
echo $output
64+
done
6165
done
6266
done

0 commit comments

Comments
 (0)