Skip to content

Commit 006f96a

Browse files
authored
FEAT: Add support for testing against SQL Server 2025 across Windows, macOS, and Linux CI pipelines (#389)
### Work Item / Issue Reference <!-- IMPORTANT: Please follow the PR template guidelines below. For mssql-python maintainers: Insert your ADO Work Item ID below (e.g. AB#37452) For external contributors: Insert Github Issue number below (e.g. #149) Only one reference is required - either GitHub issue OR ADO Work Item. --> <!-- mssql-python maintainers: ADO Work Item --> > [AB#40316](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/40316) <!-- External contributors: GitHub Issue --> > GitHub Issue: #<ISSUE_NUMBER> ------------------------------------------------------------------- ### Summary <!-- Insert your summary of changes below. Minimum 10 characters required. --> This pull request adds support for testing against SQL Server 2025 across Windows, macOS, and Linux CI pipelines. It introduces new matrix configurations, installation steps, and test/benchmark execution for SQL Server 2025, ensuring the project is validated on the upcoming SQL Server release as well as existing versions. **CI Pipeline Enhancements for SQL Server 2025:** *Windows pipeline updates:* - Added a new matrix entry for `SQLServer2025` with Python 3.14 to the Windows pipeline, alongside the installation and setup scripts for SQL Server 2025 Express, including database and user creation steps. [[1]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621L55-R60) [[2]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621R162-R227) - Configured test execution and code coverage collection for SQL Server 2025, mirroring existing steps for SQL Server 2022. - Updated AdventureWorks2022 database restore and performance benchmarking steps to also run for SQL Server 2025. [[1]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621L217-R291) [[2]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621L309-R384) *macOS and Linux pipeline updates:* - Added matrix entries and logic to run tests against SQL Server 2025 Docker images on both macOS and Linux, in addition to SQL Server 2022. [[1]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621R427-R435) [[2]](diffhunk://#diff-296c8f902bbd70f34ee1c8c32383c8c99165fe4c8e5b0f234f8f22246e56a621R542-R546) - Updated Docker commands to use the matrix-provided SQL Server image, supporting both 2022 and 2025 images. *General improvements:* - Enhanced test result publishing to include the SQL Server version in the run title for better traceability. **Other minor changes:** - Updated the `git rm` and `git checkout` commands in the ADO sync pipeline to exclude the `.gdn` directory from removal and checkout, preventing accidental deletion of required files. <!-- ### PR Title Guide > For feature requests FEAT: (short-description) > For non-feature requests like test case updates, config updates , dependency updates etc CHORE: (short-description) > For Fix requests FIX: (short-description) > For doc update requests DOC: (short-description) > For Formatting, indentation, or styling update STYLE: (short-description) > For Refactor, without any feature changes REFACTOR: (short-description) > For release related changes, without any feature changes RELEASE: #<RELEASE_VERSION> (short-description) ### Contribution Guidelines External contributors: - Create a GitHub issue first: https://github.com/microsoft/mssql-python/issues/new - Link the GitHub issue in the "GitHub Issue" section above - Follow the PR title format and provide a meaningful summary mssql-python maintainers: - Create an ADO Work Item following internal processes - Link the ADO Work Item in the "ADO Work Item" section above - Follow the PR title format and provide a meaningful summary -->
1 parent 38e2382 commit 006f96a

File tree

1 file changed

+98
-10
lines changed

1 file changed

+98
-10
lines changed

eng/pipelines/pr-validation-pipeline.yml

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ jobs:
5252

5353
strategy:
5454
matrix:
55-
LocalDB:
56-
sqlVersion: 'LocalDB'
57-
pythonVersion: '3.13'
5855
SQLServer2022:
5956
sqlVersion: 'SQL2022'
6057
pythonVersion: '3.13'
58+
SQLServer2025:
59+
sqlVersion: 'SQL2025'
60+
pythonVersion: '3.14'
6161
LocalDB_Python314:
6262
sqlVersion: 'LocalDB'
6363
pythonVersion: '3.14'
@@ -98,7 +98,7 @@ jobs:
9898
Write-Host "Downloading SQL Server 2022 Express..."
9999
# Download SQL Server 2022 Express installer
100100
$ProgressPreference = 'SilentlyContinue'
101-
Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?linkid=2216019" -OutFile "SQL2022-SSEI-Expr.exe"
101+
Invoke-WebRequest -Uri "https://download.microsoft.com/download/5/1/4/5145fe04-4d30-4b85-b0d1-39533663a2f1/SQL2022-SSEI-Expr.exe" -OutFile "SQL2022-SSEI-Expr.exe"
102102
103103
Write-Host "Installing SQL Server 2022 Express..."
104104
# Install SQL Server 2022 Express with basic features
@@ -159,6 +159,72 @@ jobs:
159159
env:
160160
DB_PASSWORD: $(DB_PASSWORD)
161161
162+
# Install SQL Server 2025 (for SQL2025 matrix)
163+
- powershell: |
164+
Write-Host "Downloading SQL Server 2025 Express..."
165+
# Download SQL Server 2025 Express installer
166+
$ProgressPreference = 'SilentlyContinue'
167+
Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?linkid=2216019&clcid=0x409&culture=en-us&country=us" -OutFile "SQL2025-SSEI-Expr.exe"
168+
169+
Write-Host "Installing SQL Server 2025 Express..."
170+
# Install SQL Server 2025 Express with basic features
171+
Start-Process -FilePath "SQL2025-SSEI-Expr.exe" -ArgumentList "/Action=Download","/MediaPath=$env:TEMP","/MediaType=Core","/Quiet" -Wait
172+
173+
# Find the downloaded setup file
174+
$setupFile = Get-ChildItem -Path $env:TEMP -Filter "SQLEXPR_x64_ENU.exe" -Recurse | Select-Object -First 1
175+
176+
if ($setupFile) {
177+
Write-Host "Extracting SQL Server setup files..."
178+
Start-Process -FilePath $setupFile.FullName -ArgumentList "/x:$env:TEMP\SQL2025Setup","/u" -Wait
179+
180+
Write-Host "Running SQL Server setup..."
181+
Start-Process -FilePath "$env:TEMP\SQL2025Setup\setup.exe" -ArgumentList "/Q","/ACTION=Install","/FEATURES=SQLEngine","/INSTANCENAME=MSSQLSERVER","/SQLSVCACCOUNT=`"NT AUTHORITY\SYSTEM`"","/SQLSYSADMINACCOUNTS=`"BUILTIN\Administrators`"","/TCPENABLED=1","/SECURITYMODE=SQL","/SAPWD=$(DB_PASSWORD)","/IACCEPTSQLSERVERLICENSETERMS" -Wait
182+
} else {
183+
Write-Error "Failed to download SQL Server setup file"
184+
exit 1
185+
}
186+
187+
Write-Host "SQL Server 2025 installation completed"
188+
displayName: 'Install SQL Server 2025 Express'
189+
condition: eq(variables['sqlVersion'], 'SQL2025')
190+
env:
191+
DB_PASSWORD: $(DB_PASSWORD)
192+
193+
# Create database for SQL Server 2025
194+
- powershell: |
195+
# Wait for SQL Server to start
196+
$maxAttempts = 30
197+
$attempt = 0
198+
$connected = $false
199+
200+
Write-Host "Waiting for SQL Server 2025 to start..."
201+
while (-not $connected -and $attempt -lt $maxAttempts) {
202+
try {
203+
sqlcmd -S "localhost" -U "sa" -P "$(DB_PASSWORD)" -Q "SELECT 1" -C
204+
$connected = $true
205+
Write-Host "SQL Server is ready!"
206+
} catch {
207+
$attempt++
208+
Write-Host "Waiting... ($attempt/$maxAttempts)"
209+
Start-Sleep -Seconds 2
210+
}
211+
}
212+
213+
if (-not $connected) {
214+
Write-Error "Failed to connect to SQL Server after $maxAttempts attempts"
215+
exit 1
216+
}
217+
218+
# Create database and user
219+
sqlcmd -S "localhost" -U "sa" -P "$(DB_PASSWORD)" -Q "CREATE DATABASE TestDB" -C
220+
sqlcmd -S "localhost" -U "sa" -P "$(DB_PASSWORD)" -Q "CREATE LOGIN testuser WITH PASSWORD = '$(DB_PASSWORD)'" -C
221+
sqlcmd -S "localhost" -U "sa" -P "$(DB_PASSWORD)" -d TestDB -Q "CREATE USER testuser FOR LOGIN testuser" -C
222+
sqlcmd -S "localhost" -U "sa" -P "$(DB_PASSWORD)" -d TestDB -Q "ALTER ROLE db_owner ADD MEMBER testuser" -C
223+
displayName: 'Setup database and user for SQL Server 2025'
224+
condition: eq(variables['sqlVersion'], 'SQL2025')
225+
env:
226+
DB_PASSWORD: $(DB_PASSWORD)
227+
162228
- script: |
163229
cd mssql_python\pybind
164230
build.bat x64
@@ -180,6 +246,14 @@ jobs:
180246
env:
181247
DB_CONNECTION_STRING: 'Server=localhost;Database=TestDB;Uid=testuser;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
182248
249+
# Run tests for SQL Server 2025
250+
- script: |
251+
python -m pytest -v --junitxml=test-results-sql2025.xml --cov=. --cov-report=xml:coverage-sql2025.xml --capture=tee-sys --cache-clear
252+
displayName: 'Run tests with coverage on SQL Server 2025'
253+
condition: eq(variables['sqlVersion'], 'SQL2025')
254+
env:
255+
DB_CONNECTION_STRING: 'Server=localhost;Database=TestDB;Uid=testuser;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
256+
183257
# Download and restore AdventureWorks2022 database for benchmarking
184258
- powershell: |
185259
Write-Host "Downloading AdventureWorks2022.bak..."
@@ -214,7 +288,7 @@ jobs:
214288
exit 1
215289
}
216290
displayName: 'Download and restore AdventureWorks2022 database'
217-
condition: eq(variables['sqlVersion'], 'SQL2022')
291+
condition: or(eq(variables['sqlVersion'], 'SQL2022'), eq(variables['sqlVersion'], 'SQL2025'))
218292
env:
219293
DB_PASSWORD: $(DB_PASSWORD)
220294
@@ -306,8 +380,8 @@ jobs:
306380
307381
Write-Host "`nRunning performance benchmarks..."
308382
python benchmarks/perf-benchmarking.py
309-
displayName: 'Run performance benchmarks on SQL Server 2022'
310-
condition: eq(variables['sqlVersion'], 'SQL2022')
383+
displayName: 'Run performance benchmarks on SQL Server 2022/2025'
384+
condition: or(eq(variables['sqlVersion'], 'SQL2022'), eq(variables['sqlVersion'], 'SQL2025'))
311385
continueOnError: true
312386
env:
313387
DB_CONNECTION_STRING: 'Server=localhost;Database=AdventureWorks2022;Uid=sa;Pwd=$(DB_PASSWORD);TrustServerCertificate=yes'
@@ -350,6 +424,15 @@ jobs:
350424
pool:
351425
vmImage: 'macos-latest'
352426

427+
strategy:
428+
matrix:
429+
SQL2022:
430+
sqlServerImage: 'mcr.microsoft.com/mssql/server:2022-latest'
431+
sqlVersion: 'SQL2022'
432+
SQL2025:
433+
sqlServerImage: 'mcr.microsoft.com/mssql/server:2025-latest'
434+
sqlVersion: 'SQL2025'
435+
353436
steps:
354437
- task: UsePythonVersion@0
355438
inputs:
@@ -382,13 +465,13 @@ jobs:
382465
383466
- script: |
384467
# Pull and run SQL Server container
385-
docker pull mcr.microsoft.com/mssql/server:2022-latest
468+
docker pull $(sqlServerImage)
386469
docker run \
387470
--name sqlserver \
388471
-e ACCEPT_EULA=Y \
389472
-e MSSQL_SA_PASSWORD="${DB_PASSWORD}" \
390473
-p 1433:1433 \
391-
-d mcr.microsoft.com/mssql/server:2022-latest
474+
-d $(sqlServerImage)
392475
393476
# Starting SQL Server container…
394477
for i in {1..30}; do
@@ -426,7 +509,7 @@ jobs:
426509
condition: succeededOrFailed()
427510
inputs:
428511
testResultsFiles: '**/test-results.xml'
429-
testRunTitle: 'Publish pytest results on macOS'
512+
testRunTitle: 'Publish pytest results on macOS $(sqlVersion)'
430513

431514
- job: PytestOnLinux
432515
displayName: 'Linux x86_64'
@@ -456,6 +539,11 @@ jobs:
456539
distroName: 'Debian'
457540
sqlServerImage: 'mcr.microsoft.com/mssql/server:2022-latest'
458541
useAzureSQL: 'false'
542+
Debian_SQL2025:
543+
dockerImage: 'debian:12'
544+
distroName: 'Debian-SQL2025'
545+
sqlServerImage: 'mcr.microsoft.com/mssql/server:2025-latest'
546+
useAzureSQL: 'false'
459547

460548
steps:
461549
- script: |

0 commit comments

Comments
 (0)