|
| 1 | +################################################################################ |
| 2 | +# Licensed to the .NET Foundation under one or more agreements. The .NET |
| 3 | +# Foundation licenses this file to you under the MIT license. See the LICENSE |
| 4 | +# file in the project root for more information. |
| 5 | +################################################################################ |
| 6 | + |
| 7 | +# This stage builds and runs stress tests against an MDS NuGet package available |
| 8 | +# as a pipeline artifact. |
| 9 | +# |
| 10 | +# The stress tests are located here: |
| 11 | +# |
| 12 | +# src/Microsoft.Data.SqlClient/tests/StressTests |
| 13 | +# |
| 14 | +# This template defines a job named 'run_stress_tests_job_<suffix>' that can be |
| 15 | +# depended on by downstream jobs. |
| 16 | + |
| 17 | +parameters: |
| 18 | + # The suffix to append to the job name. |
| 19 | + - name: jobNameSuffix |
| 20 | + type: string |
| 21 | + default: '' |
| 22 | + |
| 23 | + # The prefix to prepend to the job's display name: |
| 24 | + # |
| 25 | + # [<prefix>] Run Stress Tests |
| 26 | + # |
| 27 | + - name: displayNamePrefix |
| 28 | + type: string |
| 29 | + default: '' |
| 30 | + |
| 31 | + # The name of the Azure Pipelines pool to use. |
| 32 | + - name: poolName |
| 33 | + type: string |
| 34 | + default: '' |
| 35 | + |
| 36 | + # The pool VM image to use. |
| 37 | + - name: vmImage |
| 38 | + type: string |
| 39 | + default: '' |
| 40 | + |
| 41 | + # The pipeline step to run to configure SQL Server. |
| 42 | + # |
| 43 | + # This step is expected to require no parameters. It must configure a SQL |
| 44 | + # Server instance listening on localhost for SQL auth via the 'sa' user with |
| 45 | + # the pipeline variable $(Password) as the password. |
| 46 | + - name: sqlSetupStep |
| 47 | + type: string |
| 48 | + default: '' |
| 49 | + |
| 50 | + # The name of the pipeline artifact to download that contains the MDS package |
| 51 | + # to stress test. |
| 52 | + - name: pipelineArtifactName |
| 53 | + type: string |
| 54 | + default: '' |
| 55 | + |
| 56 | + # The solution file to restore/build. |
| 57 | + - name: solution |
| 58 | + type: string |
| 59 | + default: '' |
| 60 | + |
| 61 | + # The test project to run. |
| 62 | + - name: testProject |
| 63 | + type: string |
| 64 | + default: '' |
| 65 | + |
| 66 | + # dotnet CLI arguments for the restore step. |
| 67 | + - name: restoreArguments |
| 68 | + type: string |
| 69 | + default: '' |
| 70 | + |
| 71 | + # dotnet CLI arguments for the build and run steps. |
| 72 | + - name: buildArguments |
| 73 | + type: string |
| 74 | + default: '' |
| 75 | + |
| 76 | + # The list of .NET runtimes to test against. |
| 77 | + - name: netTestRuntimes |
| 78 | + type: object |
| 79 | + default: [] |
| 80 | + |
| 81 | + # The list of .NET Framework runtimes to test against. |
| 82 | + - name: netFrameworkTestRuntimes |
| 83 | + type: object |
| 84 | + default: [] |
| 85 | + |
| 86 | + # The stress test config file contents to write to the config file. |
| 87 | + # |
| 88 | + # This should point to the SQL Server configured via the sqlSetupStep |
| 89 | + # parameter, with user 'sa' and password of $(Password). |
| 90 | + - name: configContent |
| 91 | + type: string |
| 92 | + default: '' |
| 93 | + |
| 94 | +jobs: |
| 95 | +- job: run_stress_tests_job_${{ parameters.jobNameSuffix }} |
| 96 | + displayName: '[${{ parameters.displayNamePrefix }}] Run Stress Tests' |
| 97 | + pool: |
| 98 | + name: ${{ parameters.poolName }} |
| 99 | + ${{ if eq(parameters.poolName, 'Azure Pipelines') }}: |
| 100 | + vmImage: ${{ parameters.vmImage }} |
| 101 | + ${{ else }}: |
| 102 | + demands: |
| 103 | + - imageOverride -equals ${{ parameters.vmImage }} |
| 104 | + |
| 105 | + variables: |
| 106 | + # Stress test command-line arguments. |
| 107 | + - name: testArguments |
| 108 | + value: -a SqlClient.Stress.Tests -console |
| 109 | + |
| 110 | + # Explicitly unset the $PLATFORM environment variable that is set by the |
| 111 | + # 'ADO Build properties' Library in the ADO SqlClientDrivers public project. |
| 112 | + # This is defined with a non-standard Platform of 'AnyCPU', and will fail |
| 113 | + # the builds if left defined. The stress tests solution does not require |
| 114 | + # any specific Platform, and so its solution file doesn't support any |
| 115 | + # non-standard platforms. |
| 116 | + # |
| 117 | + # Note that Azure Pipelines will inject this variable as PLATFORM into the |
| 118 | + # environment of all tasks in this job. |
| 119 | + # |
| 120 | + # See: |
| 121 | + # https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch |
| 122 | + # |
| 123 | + - name: Platform |
| 124 | + value: '' |
| 125 | + |
| 126 | + # Do the same for $CONFIGURATION since we explicitly set it using our |
| 127 | + # 'buildConfiguration' parameter, and we don't want the environment to |
| 128 | + # override us. |
| 129 | + - name: Configuration |
| 130 | + value: '' |
| 131 | + |
| 132 | + steps: |
| 133 | + |
| 134 | + # Install the .NET 9.0 SDK. |
| 135 | + - task: UseDotNet@2 |
| 136 | + displayName: Install .NET 9.0 SDK |
| 137 | + inputs: |
| 138 | + packageType: sdk |
| 139 | + version: 9.x |
| 140 | + |
| 141 | + # Install the .NET 8.0 runtime. |
| 142 | + - task: UseDotNet@2 |
| 143 | + displayName: Install .NET 8.0 Runtime |
| 144 | + inputs: |
| 145 | + packageType: runtime |
| 146 | + version: 8.x |
| 147 | + |
| 148 | + # Download the pipeline artifact that contains the MDS package to test. |
| 149 | + - task: DownloadPipelineArtifact@2 |
| 150 | + displayName: Download Pipeline Artifact |
| 151 | + inputs: |
| 152 | + artifactName: ${{ parameters.pipelineArtifactName }} |
| 153 | + # The stress tests solution has a NuGet.config file that configures |
| 154 | + # sources to look in this packages/ directory. |
| 155 | + targetPath: $(Build.SourcesDirectory)/packages |
| 156 | + |
| 157 | + # Setup the local SQL Server. |
| 158 | + - template: ${{ parameters.sqlSetupStep }}@self |
| 159 | + |
| 160 | + # We use the 'custom' command because the DotNetCoreCLI@2 task doesn't support |
| 161 | + # all of our argument combinations for the different build steps. |
| 162 | + |
| 163 | + # Restore the solution. |
| 164 | + - task: DotNetCoreCLI@2 |
| 165 | + displayName: Restore Solution |
| 166 | + inputs: |
| 167 | + command: custom |
| 168 | + custom: restore |
| 169 | + projects: ${{ parameters.solution }} |
| 170 | + arguments: ${{ parameters.restoreArguments }} |
| 171 | + |
| 172 | + # Build the solution. |
| 173 | + - task: DotNetCoreCLI@2 |
| 174 | + displayName: Build Solution |
| 175 | + inputs: |
| 176 | + command: custom |
| 177 | + custom: build |
| 178 | + projects: ${{ parameters.solution }} |
| 179 | + arguments: ${{ parameters.buildArguments }} --no-restore |
| 180 | + |
| 181 | + # Write the config file. |
| 182 | + - task: PowerShell@2 |
| 183 | + displayName: Write Config File |
| 184 | + inputs: |
| 185 | + pwsh: true |
| 186 | + targetType: inline |
| 187 | + script: | |
| 188 | + # Capture the multi-line JSON content into a variable. |
| 189 | + $content = @" |
| 190 | + ${{ parameters.configContent }} |
| 191 | + "@ |
| 192 | +
|
| 193 | + # Write the JSON content to the config file. |
| 194 | + $content | Out-File -FilePath "config.json" |
| 195 | +
|
| 196 | + # Run the stress tests for each .NET runtime. |
| 197 | + - ${{ each runtime in parameters.netTestRuntimes }}: |
| 198 | + - task: DotNetCoreCLI@2 |
| 199 | + displayName: Test [${{runtime}}] |
| 200 | + inputs: |
| 201 | + command: custom |
| 202 | + custom: run |
| 203 | + projects: ${{ parameters.testProject }} |
| 204 | + arguments: ${{ parameters.buildArguments }} --no-build -f ${{runtime}} -e STRESS_CONFIG_FILE=config.json -- $(testArguments) |
| 205 | + |
| 206 | + # Run the stress tests for each .NET Framework runtime. |
| 207 | + - ${{ each runtime in parameters.netFrameworkTestRuntimes }}: |
| 208 | + - task: DotNetCoreCLI@2 |
| 209 | + displayName: Test [${{runtime}}] |
| 210 | + inputs: |
| 211 | + command: custom |
| 212 | + custom: run |
| 213 | + projects: ${{ parameters.testProject }} |
| 214 | + arguments: ${{ parameters.buildArguments }} --no-build -f ${{runtime}} -e STRESS_CONFIG_FILE=config.json -- $(testArguments) |
0 commit comments