Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion azure-pipelines/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ variables:
value: '0'

stages:
- stage: IntegrationTests
variables:
- name: buildConfiguration
value: 'Debug'
jobs:
- job: IntegrationTests
pool:
vmImage: 'ubuntu-latest'
steps:
- template: integration-tests.yml
timeoutInMinutes: 60

- stage: Build
variables:
- name: buildConfiguration
Expand All @@ -32,4 +44,4 @@ stages:
- ImageOverride -equals ADS-Windows_Image
steps:
- template: build.yml
timeoutInMinutes: 90
timeoutInMinutes: 90
1 change: 0 additions & 1 deletion azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ steps:
reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Agent.TempDirectory)/coverlet/reports -reporttypes:"Cobertura"
displayName: Create Code coverage report


- powershell: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://keybase.io/codecovsecurity/pgp_keys.asc -OutFile codecov.asc
Expand Down
74 changes: 74 additions & 0 deletions azure-pipelines/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
steps:
- task: UseDotNet@2
displayName: 'Use .NET sdk'
inputs:
useGlobalJson: true

- pwsh: |
# setup docker image for SQL 2025
# generate random password of 24 characters, save to a script variable
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%^&*()'
$password = -join (1..24 | ForEach-Object { $chars[(Get-Random -Maximum $chars.Length)] })
Write-Host "##vso[task.setvariable variable=SqlPassword;issecret=true]$password"

# pull docker image for SQL 2025
docker pull mcr.microsoft.com/mssql/server:2025-latest

# set up docker container for SQL 2025 using that password
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$password" -p 1433:1433 --name sql2025 -d mcr.microsoft.com/mssql/server:2025-latest

# Wait for SQL Server to be ready
$start = Get-Date
$timeout = New-TimeSpan -Seconds 60
do {
Start-Sleep -Seconds 2
$logs = docker logs sql2025 2>&1
if ($logs -match "SQL Server is now ready for client connections") {
Write-Host "SQL Server is ready."
break
}
if ((Get-Date) - $start -gt $timeout) {
Write-Error "Timeout waiting for SQL Server to start."
exit 1
}
} while ($true)

# Create settings.json for tests
$settingsContent = @"
{
"mssql.connections": [
{
"server": "localhost",
"authenticationType": "SqlLogin",
"user": "sa",
"password": "$password",
"serverType": "OnPrem"
}
]
}
"@
$settingsPath = Join-Path "$(Agent.TempDirectory)" "settings.json"
Set-Content -Path $settingsPath -Value $settingsContent
Write-Host "Created settings.json at $settingsPath"

# Set environment variable for tests
Write-Host "##vso[task.setvariable variable=SettingsFileName]$settingsPath"
displayName: 'Setup Docker image for integration tests'

- task: Bash@3
displayName: 'Create Loc Directories'
inputs:
filePath: ./azure-pipelines/createBuildDirectories.sh

- script: dotnet restore test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Microsoft.SqlTools.ServiceLayer.IntegrationTests.csproj --configfile nuget.config
displayName: 'dotnet restore test/Microsoft.SqlTools.ServiceLayer.IntegrationTests'

- task: DotNetCoreCLI@2
displayName: 'dotnet test test/Microsoft.SqlTools.ServiceLayer.IntegrationTests'
env:
SettingsFileName: $(SettingsFileName)
inputs:
command: test
projects: test/Microsoft.SqlTools.ServiceLayer.IntegrationTests
testRunTitle: SqlTools.ServiceLayer.IntegrationTests
arguments: '--configuration $(buildConfiguration) --collect "XPlat Code Coverage"'
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static InstanceInfo? SqlOnPrem
public static InstanceInfo? GetInstance(string key)
{
connectionProfilesCache.TryGetValue(key, out InstanceInfo? instanceInfo);
Assert.True(instanceInfo != null, string.Format(CultureInfo.InvariantCulture, "Cannot find any instance for version key: {0}", key));
Assert.True(instanceInfo != null, $"Cannot find any instance for version key: {key}; available keys: {String.Join(", ", connectionProfilesCache.Keys)}");
return instanceInfo;
}

Expand Down