Skip to content

Commit

Permalink
Use pre steps to determine whether to record live tests (#17063)
Browse files Browse the repository at this point in the history
* Use pre steps to determine record

* Add TestMode setting

* Simplify live test post steps to use TestMode for recording condition
  • Loading branch information
benbp authored Nov 20, 2020
1 parent b01aa8f commit 9b2aadb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 10 additions & 2 deletions eng/pipelines/templates/jobs/archetype-sdk-tests-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
maxParallel: ${{ parameters.MaxParallel }}
matrix: ${{ parameters.Platforms }}

condition: and(succeededOrFailed(), eq(eq(variables['Record'], 'true'), eq('$(TestMode)', 'Record')))
variables:
- template: ../variables/globals.yml
# ServiceDirectory references must get passed down by the caller as variable references
Expand All @@ -52,6 +51,8 @@ jobs:
value: ''
- name: ArmTemplateParameters
value: '@{}'
- name: TestMode
value: 'None'

timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}

Expand All @@ -77,6 +78,13 @@ jobs:
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
ArmTemplateParameters: $(ArmTemplateParameters)

- pwsh: |
if ($env:SupportsRecording -and $env:Record) {
Write-Host "Enabling Record mode"
Write-Host "##vso[task.setvariable variable=TestMode]Record"
}
displayName: Set Test Mode
- pwsh: >
dotnet test eng/service.proj
--framework $(TestTargetFramework)
Expand All @@ -93,7 +101,7 @@ jobs:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_MULTILEVEL_LOOKUP: 0
AZURE_TEST_MODE: "${{ coalesce(variables['TestMode'], 'None') }}"
AZURE_TEST_MODE: $(TestMode)
${{ each var in parameters.EnvVars }}:
${{ var.key }}: ${{ var.value }}
Expand Down
10 changes: 3 additions & 7 deletions eng/pipelines/templates/stages/archetype-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ parameters:
Windows_NetCore:
OSVmImage: "windows-2019"
TestTargetFramework: netcoreapp2.1
SupportsRecording: true
Windows_NetCore_ProjectRefAzureClients:
OSVmImage: "windows-2019"
TestTargetFramework: netcoreapp2.1
Expand All @@ -73,11 +74,6 @@ parameters:
OSVmImage: "macOS-10.15"
TestTargetFramework: netcoreapp2.1
SupportedClouds: 'Public'
Windows_NetCore_Record:
OSVmImage: "windows-2019"
TestMode: Record
TestTargetFramework: netcoreapp2.1
SupportedClouds: 'Public'
- name: PlatformPreSteps
type: object
default:
Expand All @@ -86,7 +82,7 @@ parameters:
type: object
default:
- task: CopyFiles@2
condition: and(succeededOrFailed(), eq(variables['Agent.JobName'], 'Windows_NetCore_Record'))
condition: and(succeededOrFailed(), eq(variables.TestMode, 'Record'))
displayName: "Copy Test Recordings"
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
Expand All @@ -95,7 +91,7 @@ parameters:
contents: 'sdk/$(ServiceDirectory)/**/SessionRecords/**/*.json'
targetFolder: '$(Build.ArtifactStagingDirectory)/SessionRecords'
- task: PublishBuildArtifacts@1
condition: and(succeededOrFailed(), eq(variables['Agent.JobName'], 'Windows_NetCore_Record'))
condition: and(succeededOrFailed(), eq(variables.TestMode, 'Record'))
displayName: "Publish Test Recordings"
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/SessionRecords'
Expand Down

0 comments on commit 9b2aadb

Please sign in to comment.