azure-sdk-for-cpp/eng/common/testproxy/test-proxy-tool.yml
Azure SDK Bot 818d22778f
Sync eng/common directory with azure-sdk-tools for PR 7385 (#5223)
* Update organization of the eng/common/testproxy folder
* Add merge-proxy-tags.ps1 and readme to eng/common/testproxy/scripts/tag-merge/
* Extract common assets script functionality to common-asset-functions.ps1

---------

Co-authored-by: Scott Beddall (from Dev Box) <scbedd@microsoft.com>
2023-12-06 15:18:40 -08:00

72 lines
3.3 KiB
YAML

parameters:
rootFolder: '$(Build.SourcesDirectory)'
runProxy: true
targetVersion: ''
templateRoot: '$(Build.SourcesDirectory)'
condition: true
steps:
- pwsh: |
${{ parameters.templateRoot }}/eng/common/scripts/trust-proxy-certificate.ps1
displayName: 'Language Specific Certificate Trust'
condition: and(succeeded(), ${{ parameters.condition }})
- task: PowerShell@2
displayName: 'Override proxy version if necessary'
condition: and(succeeded(), ${{ parameters.condition }}, ne('${{ parameters.targetVersion }}', ''))
inputs:
targetType: filePath
filePath: '${{ parameters.templateRoot }}/eng/common/testproxy/scripts/override-proxy-version.ps1'
arguments: '-TargetVersion "${{ parameters.targetVersion }}"'
pwsh: true
- pwsh: |
$version = $(Get-Content "${{ parameters.templateRoot }}/eng/common/testproxy/target_version.txt" -Raw).Trim()
dotnet tool install azure.sdk.tools.testproxy `
--tool-path $(Build.BinariesDirectory)/test-proxy `
--add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json `
--version $version
displayName: "Install test-proxy"
condition: and(succeeded(), ${{ parameters.condition }})
- pwsh: |
Write-Host "##vso[task.prependpath]$(Build.BinariesDirectory)/test-proxy"
displayName: "Prepend path with test-proxy tool install location"
- ${{ if eq(parameters.runProxy, 'true') }}:
- pwsh: |
Write-Host "##vso[task.setvariable variable=ASPNETCORE_Kestrel__Certificates__Default__Path]${{ parameters.templateRoot }}/eng/common/testproxy/dotnet-devcert.pfx"
Write-Host "##vso[task.setvariable variable=ASPNETCORE_Kestrel__Certificates__Default__Password]password"
Write-Host "##vso[task.setvariable variable=PROXY_MANUAL_START]true"
displayName: 'Configure Kestrel and PROXY_MANUAL_START Variables'
condition: and(succeeded(), ${{ parameters.condition }})
- pwsh: |
Start-Process $(Build.BinariesDirectory)/test-proxy/test-proxy.exe `
-ArgumentList "start --storage-location ${{ parameters.rootFolder }} -U" `
-NoNewWindow -PassThru -RedirectStandardOutput ${{ parameters.rootFolder }}/test-proxy.log
displayName: 'Run the testproxy - windows'
condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }})
# nohup does NOT continue beyond the current session if you use it within powershell
- bash: |
nohup $(Build.BinariesDirectory)/test-proxy/test-proxy &>$(Build.SourcesDirectory)/test-proxy.log &
displayName: "Run the testproxy - linux/mac"
condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }})
workingDirectory: "${{ parameters.rootFolder }}"
- pwsh: |
for ($i = 0; $i -lt 10; $i++) {
try {
Invoke-WebRequest -Uri "http://localhost:5000/Admin/IsAlive" | Out-Null
exit 0
} catch {
Write-Warning "Failed to successfully connect to test proxy. Retrying..."
Start-Sleep 6
}
}
Write-Error "Could not connect to test proxy."
exit 1
displayName: Test Proxy IsAlive
condition: and(succeeded(), ${{ parameters.condition }})