From 992d2fe70ce591c3116311a485d80c14716f0cb5 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:31:20 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 8158 (#22780) * allow an override FILE to be honored by test-proxy-tool * update local test-framework to honor proxy override version by default --------- Co-authored-by: Scott Beddall (from Dev Box) --- eng/common/testproxy/test-proxy-docker.yml | 40 ---------------------- eng/common/testproxy/test-proxy-tool.yml | 12 ++++++- eng/target_proxy_version.txt | 1 + sdk/internal/recording/server.go | 10 ++++++ 4 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 eng/common/testproxy/test-proxy-docker.yml create mode 100644 eng/target_proxy_version.txt diff --git a/eng/common/testproxy/test-proxy-docker.yml b/eng/common/testproxy/test-proxy-docker.yml deleted file mode 100644 index 307b5032a494..000000000000 --- a/eng/common/testproxy/test-proxy-docker.yml +++ /dev/null @@ -1,40 +0,0 @@ -parameters: - rootFolder: '$(Build.SourcesDirectory)' - 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: | - docker info - displayName: 'Dump active docker information' - condition: and(succeeded(), ${{ parameters.condition }}) - - - pwsh: | - ${{ parameters.templateRoot }}/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}" -VersionOverride="${{ parameters.targetVersion }}" - displayName: 'Run the docker container' - condition: and(succeeded(), ${{ parameters.condition }}) - - - pwsh: | - docker container ls -a - displayName: Check running container - condition: and(succeeded(), ${{ parameters.condition }}) - - - pwsh: | - Write-Host "##vso[task.setvariable variable=PROXY_MANUAL_START]true" - displayName: 'Set PROXY_MANUAL_START' - condition: and(succeeded(), ${{ parameters.condition }}) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index d9a166841926..9494b1cf0bfb 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -22,7 +22,17 @@ steps: pwsh: true - pwsh: | - $version = $(Get-Content "${{ parameters.templateRoot }}/eng/common/testproxy/target_version.txt" -Raw).Trim() + $standardVersion = "${{ parameters.templateRoot }}/eng/common/testproxy/target_version.txt" + $overrideVersion = "${{ parameters.templateRoot }}/eng/target_proxy_version.txt" + + $version = $(Get-Content $standardVersion -Raw).Trim() + + if (Test-Path $overrideVersion) { + $version = $(Get-Content $overrideVersion -Raw).Trim() + } + + Write-Host "Installing test-proxy version $version" + 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 ` diff --git a/eng/target_proxy_version.txt b/eng/target_proxy_version.txt new file mode 100644 index 000000000000..a9598ae32651 --- /dev/null +++ b/eng/target_proxy_version.txt @@ -0,0 +1 @@ +1.0.0-dev.20240410.1 \ No newline at end of file diff --git a/sdk/internal/recording/server.go b/sdk/internal/recording/server.go index a17c8bffe369..89ad4f4ad5eb 100644 --- a/sdk/internal/recording/server.go +++ b/sdk/internal/recording/server.go @@ -319,6 +319,16 @@ func getProxyLog() (*os.File, error) { func getProxyVersion(gitRoot string) (string, error) { proxyVersionConfig := filepath.Join(gitRoot, "eng/common/testproxy/target_version.txt") + overrideProxyVersionConfig := filepath.Join(gitRoot, "eng/target_proxy_version.txt") + + if _, err := os.Stat(overrideProxyVersionConfig); err == nil { + version, err := ioutil.ReadFile(overrideProxyVersionConfig) + if err == nil { + proxyVersion := strings.TrimSpace(string(version)) + return proxyVersion, nil + } + } + version, err := ioutil.ReadFile(proxyVersionConfig) if err != nil { return "", err