Skip to content

Add Stress Tests to CI #3558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ indent_size = 4
[*.{json,jsonc}]
indent_size = 2

[*.{yml,yaml}]
indent_size = 2

# C# files
[*.cs]
# New line preferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# The .NET Foundation licenses this file to you under the MIT license. #
# See the LICENSE file in the project root for more information. #
#################################################################################

# This step configures an existing SQL Server running on the local Linux host.
# For example, our 1ES Hosted Pool has images like ADO-UB20-SQL22 that come with
# SQL Server 2022 pre-installed and running.

parameters:
- name: password
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# The .NET Foundation licenses this file to you under the MIT license. #
# See the LICENSE file in the project root for more information. #
#################################################################################

# This step installs the latest SQL Server 2022 onto the macOS host and
# configures it for use.

parameters:
- name: password
type: string
Expand All @@ -13,7 +17,7 @@ parameters:
default: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))

steps:
# Linux only steps
# macOS only steps
- bash: |
# The "user" pipeline variable conflicts with homebrew, causing errors during install. Set it back to the pipeline user.
USER=`whoami`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# The .NET Foundation licenses this file to you under the MIT license. #
# See the LICENSE file in the project root for more information. #
#################################################################################

# This step configures an existing SQL Server running on the local Windows host.
# For example, our 1ES Hosted Pool has images like ADO-MMS22-SQL22 that come
# with SQL Server 2022 pre-installed and running.

parameters:
# Windows only parameters
- name: instanceName
Expand Down Expand Up @@ -63,7 +68,7 @@ parameters:
default: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

steps:
# windows only steps
# Windows only steps
- powershell: |
try
{
Expand Down
25 changes: 23 additions & 2 deletions eng/pipelines/dotnet-sqlclient-ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,22 @@ parameters:
- Project
- Package

- name: buildConfiguration
displayName: 'Build Configuration'
default: Release
values:
- Release
- Debug

- name: defaultPoolName
type: string
default: $(ci_var_defaultPoolName)

- name: enableStressTests
displayName: Enable Stress Tests
type: boolean
default: false

variables:
- template: libraries/ci-build-variables.yml@self

Expand All @@ -84,6 +96,7 @@ stages:
jobs:
- template: common/templates/jobs/ci-build-nugets-job.yml@self
parameters:
configuration: ${{ parameters.buildConfiguration }}
artifactName: $(artifactName)
${{if ne(parameters.SNIVersion, '')}}:
prebuildSteps:
Expand All @@ -92,6 +105,16 @@ stages:
SNIVersion: ${{parameters.SNIVersion}}
SNIValidationFeed: ${{parameters.SNIValidationFeed}}

- ${{ if eq(parameters.enableStressTests, true) }}:
- template: stages/stress-tests-ci-stage.yml@self
parameters:
buildConfiguration: ${{ parameters.buildConfiguration }}
dependsOn: [build_nugets]
pipelineArtifactName: $(artifactName)
mdsPackageVersion: $(NugetPackageVersion)
${{ if eq(parameters.debug, 'true') }}:
verbosity: 'detailed'

- template: common/templates/stages/ci-run-tests-stage.yml@self
parameters:
debug: ${{ parameters.debug }}
Expand Down Expand Up @@ -139,7 +162,6 @@ stages:
testConfigurations:
windows_sql_19_x64: # configuration name
pool: ${{parameters.defaultPoolName }} # pool name
hostedPool: false # whether the pool is hosted or not
images: # list of images to run tests on
Win22_Sql19: ADO-MMS22-SQL19 # stage display name: image name from the pool
TargetFrameworks: ${{parameters.targetFrameworks }} #[net462, net8.0] # list of target frameworks to run
Expand Down Expand Up @@ -181,7 +203,6 @@ stages:

windows_sql_19_x86: # configuration name
pool: ${{parameters.defaultPoolName }} # pool name
hostedPool: false # whether the pool is hosted or not
images: # list of images to run tests on
Win22_Sql19_x86: ADO-MMS22-SQL19 # stage display name: image name from the pool
TargetFrameworks: [net8.0] #[net462, net8.0] # list of target frameworks to run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ parameters: # parameters are shown up in ADO UI in a build queue time
- Project
- Package

- name: buildConfiguration
displayName: 'Build Configuration'
default: Release
values:
- Release
- Debug

- name: enableStressTests
displayName: Enable Stress Tests
type: boolean
default: false

extends:
template: dotnet-sqlclient-ci-core.yml@self
parameters:
Expand All @@ -92,3 +104,5 @@ extends:
useManagedSNI: ${{ parameters.useManagedSNI }}
codeCovTargetFrameworks: ${{ parameters.codeCovTargetFrameworks }}
buildType: ${{ parameters.buildType }}
buildConfiguration: ${{ parameters.buildConfiguration }}
enableStressTests: ${{ parameters.enableStressTests }}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ parameters: # parameters are shown up in ADO UI in a build queue time
- Project
- Package

- name: buildConfiguration
displayName: 'Build Configuration'
default: Release
values:
- Release
- Debug

- name: enableStressTests
displayName: Enable Stress Tests
type: boolean
default: false

extends:
template: dotnet-sqlclient-ci-core.yml@self
parameters:
Expand All @@ -84,3 +96,5 @@ extends:
useManagedSNI: ${{ parameters.useManagedSNI }}
codeCovTargetFrameworks: ${{ parameters.codeCovTargetFrameworks }}
buildType: ${{ parameters.buildType }}
buildConfiguration: ${{ parameters.buildConfiguration }}
enableStressTests: ${{ parameters.enableStressTests }}
214 changes: 214 additions & 0 deletions eng/pipelines/jobs/stress-tests-ci-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
################################################################################
# Licensed to the .NET Foundation under one or more agreements. The .NET
# Foundation licenses this file to you under the MIT license. See the LICENSE
# file in the project root for more information.
################################################################################

# This stage builds and runs stress tests against an MDS NuGet package available
# as a pipeline artifact.
#
# The stress tests are located here:
#
# src/Microsoft.Data.SqlClient/tests/StressTests
#
# This template defines a job named 'run_stress_tests_job_<suffix>' that can be
# depended on by downstream jobs.

parameters:
# The suffix to append to the job name.
- name: jobNameSuffix
type: string
default: ''

# The prefix to prepend to the job's display name:
#
# [<prefix>] Run Stress Tests
#
- name: displayNamePrefix
type: string
default: ''

# The name of the Azure Pipelines pool to use.
- name: poolName
type: string
default: ''

# The pool VM image to use.
- name: vmImage
type: string
default: ''

# The pipeline step to run to configure SQL Server.
#
# This step is expected to require no parameters. It must configure a SQL
# Server instance listening on localhost for SQL auth via the 'sa' user with
# the pipeline variable $(Password) as the password.
- name: sqlSetupStep
type: string
default: ''

# The name of the pipeline artifact to download that contains the MDS package
# to stress test.
- name: pipelineArtifactName
type: string
default: ''

# The solution file to restore/build.
- name: solution
type: string
default: ''

# The test project to run.
- name: testProject
type: string
default: ''

# dotnet CLI arguments for the restore step.
- name: restoreArguments
type: string
default: ''

# dotnet CLI arguments for the build and run steps.
- name: buildArguments
type: string
default: ''

# The list of .NET runtimes to test against.
- name: netTestRuntimes
type: object
default: []

# The list of .NET Framework runtimes to test against.
- name: netFrameworkTestRuntimes
type: object
default: []

# The stress test config file contents to write to the config file.
#
# This should point to the SQL Server configured via the sqlSetupStep
# parameter, with user 'sa' and password of $(Password).
- name: configContent
type: string
default: ''

jobs:
- job: run_stress_tests_job_${{ parameters.jobNameSuffix }}
displayName: '[${{ parameters.displayNamePrefix }}] Run Stress Tests'
pool:
name: ${{ parameters.poolName }}
${{ if eq(parameters.poolName, 'Azure Pipelines') }}:
vmImage: ${{ parameters.vmImage }}
${{ else }}:
demands:
- imageOverride -equals ${{ parameters.vmImage }}

variables:
# Stress test command-line arguments.
- name: testArguments
value: -a SqlClient.Stress.Tests -console

# Explicitly unset the $PLATFORM environment variable that is set by the
# 'ADO Build properties' Library in the ADO SqlClientDrivers public project.
# This is defined with a non-standard Platform of 'AnyCPU', and will fail
# the builds if left defined. The stress tests solution does not require
# any specific Platform, and so its solution file doesn't support any
# non-standard platforms.
#
# Note that Azure Pipelines will inject this variable as PLATFORM into the
# environment of all tasks in this job.
#
# See:
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch
#
- name: Platform
value: ''

# Do the same for $CONFIGURATION since we explicitly set it using our
# 'buildConfiguration' parameter, and we don't want the environment to
# override us.
- name: Configuration
value: ''

steps:

# Install the .NET 9.0 SDK.
- task: UseDotNet@2
displayName: Install .NET 9.0 SDK
inputs:
packageType: sdk
version: 9.x

# Install the .NET 8.0 runtime.
- task: UseDotNet@2
displayName: Install .NET 8.0 Runtime
inputs:
packageType: runtime
version: 8.x

# Download the pipeline artifact that contains the MDS package to test.
- task: DownloadPipelineArtifact@2
displayName: Download Pipeline Artifact
inputs:
artifactName: ${{ parameters.pipelineArtifactName }}
# The stress tests solution has a NuGet.config file that configures
# sources to look in this packages/ directory.
targetPath: $(Build.SourcesDirectory)/packages

# Setup the local SQL Server.
- template: ${{ parameters.sqlSetupStep }}@self

# We use the 'custom' command because the DotNetCoreCLI@2 task doesn't support
# all of our argument combinations for the different build steps.

# Restore the solution.
- task: DotNetCoreCLI@2
displayName: Restore Solution
inputs:
command: custom
custom: restore
projects: ${{ parameters.solution }}
arguments: ${{ parameters.restoreArguments }}

# Build the solution.
- task: DotNetCoreCLI@2
displayName: Build Solution
inputs:
command: custom
custom: build
projects: ${{ parameters.solution }}
arguments: ${{ parameters.buildArguments }} --no-restore

# Write the config file.
- task: PowerShell@2
displayName: Write Config File
inputs:
pwsh: true
targetType: inline
script: |
# Capture the multi-line JSON content into a variable.
$content = @"
${{ parameters.configContent }}
"@

# Write the JSON content to the config file.
$content | Out-File -FilePath "config.json"

# Run the stress tests for each .NET runtime.
- ${{ each runtime in parameters.netTestRuntimes }}:
- task: DotNetCoreCLI@2
displayName: Test [${{runtime}}]
inputs:
command: custom
custom: run
projects: ${{ parameters.testProject }}
arguments: ${{ parameters.buildArguments }} --no-build -f ${{runtime}} -e STRESS_CONFIG_FILE=config.json -- $(testArguments)

# Run the stress tests for each .NET Framework runtime.
- ${{ each runtime in parameters.netFrameworkTestRuntimes }}:
- task: DotNetCoreCLI@2
displayName: Test [${{runtime}}]
inputs:
command: custom
custom: run
projects: ${{ parameters.testProject }}
arguments: ${{ parameters.buildArguments }} --no-build -f ${{runtime}} -e STRESS_CONFIG_FILE=config.json -- $(testArguments)
Loading
Loading