File: test-proxy-tool.yml

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (69 lines) | stat: -rw-r--r-- 3,195 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 }})

  - pwsh: |
      $version = $(Get-Content "${{ parameters.templateRoot }}/eng/common/testproxy/target_version.txt" -Raw).Trim()
      $overrideVersion = "${{ parameters.targetVersion }}"

      if($overrideVersion) {
        Write-Host "Overriding default target proxy version of '$version' with override $overrideVersion."
        $version = $overrideVersion
      }

      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 "--storage-location ${{ parameters.rootFolder }}" `
          -NoNewWindow -PassThru -RedirectStandardOutput ${{ parameters.templateRoot }}/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 > ${{ parameters.templateRoot }}/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 }})