From 868ce4ae5936d252edc498f774aa30677319b7e9 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 16:31:36 -0700 Subject: [PATCH 1/8] allow an override FILE to be honored by test-proxy-tool --- eng/common/testproxy/test-proxy-tool.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index d9a166841926..4949a85becda 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -22,11 +22,19 @@ 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() + } 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 + $(Build.BinariesDirectory)/test-proxy --version displayName: "Install test-proxy" condition: and(succeeded(), ${{ parameters.condition }}) From 2833ee9b513da042424853979d42fe0f9a77b6e2 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 16:32:20 -0700 Subject: [PATCH 2/8] remove test-proxy-docker --- eng/common/testproxy/test-proxy-docker.yml | 40 ---------------------- 1 file changed, 40 deletions(-) delete mode 100644 eng/common/testproxy/test-proxy-docker.yml 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 }}) From 216280d03e77fd801047ef40b3ba44aeb4a45886 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 17:46:54 -0700 Subject: [PATCH 3/8] update to honor the override file --- eng/target_proxy_version.txt | 1 + .../com/azure/core/test/utils/TestProxyUtils.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 eng/target_proxy_version.txt diff --git a/eng/target_proxy_version.txt b/eng/target_proxy_version.txt new file mode 100644 index 000000000000..1979eff49e7b --- /dev/null +++ b/eng/target_proxy_version.txt @@ -0,0 +1 @@ +1.0.0-dev.20240410.1 diff --git a/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java b/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java index e1d510f9eca9..84fa1e32da53 100644 --- a/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java +++ b/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java @@ -238,10 +238,17 @@ public static void checkForTestProxyErrors(HttpResponse httpResponse) { */ public static String getTestProxyVersion(Path testClassPath) { Path rootPath = TestUtils.getRepoRootResolveUntil(testClassPath, "eng"); + Path overrideVersionFile = Paths.get("eng", "target_proxy_version.txt"); Path versionFile = Paths.get("eng", "common", "testproxy", "target_version.txt"); - rootPath = rootPath.resolve(versionFile); + + // if a long-lived override exists, use it. + if (Files.exists(rootPath.resolve(overrideVersionFile))) { + versionFile = overrideVersionFile; + } + + versionFilePath = rootPath.resolve(versionFile); try { - return Files.readAllLines(rootPath).get(0).replace(System.getProperty("line.separator"), ""); + return Files.readAllLines(versionFilePath).get(0).replace(System.getProperty("line.separator"), ""); } catch (IOException e) { throw new UncheckedIOException(e); } From e0b0057c9c54d5625e20c2ecbe20a2f7c37353ab Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 16:31:36 -0700 Subject: [PATCH 4/8] allow an override FILE to be honored by test-proxy-tool --- eng/common/testproxy/test-proxy-tool.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index d9a166841926..4949a85becda 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -22,11 +22,19 @@ 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() + } 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 + $(Build.BinariesDirectory)/test-proxy --version displayName: "Install test-proxy" condition: and(succeeded(), ${{ parameters.condition }}) From f8ffa326285e79fa344b5c12fa9ac925f7d96fd7 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 16:32:20 -0700 Subject: [PATCH 5/8] remove test-proxy-docker --- eng/common/testproxy/test-proxy-docker.yml | 40 ---------------------- 1 file changed, 40 deletions(-) delete mode 100644 eng/common/testproxy/test-proxy-docker.yml 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 }}) From 087604a69b48a4c927e4a4e6650136e517f1e095 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 17:09:22 -0700 Subject: [PATCH 6/8] repair the proxy startup call --- eng/common/testproxy/test-proxy-tool.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index 4949a85becda..9494b1cf0bfb 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -30,11 +30,13 @@ steps: 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 ` --version $version - $(Build.BinariesDirectory)/test-proxy --version displayName: "Install test-proxy" condition: and(succeeded(), ${{ parameters.condition }}) From 67981bd719b815c52d2f65c441eddaa90a6c39e1 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Wed, 24 Apr 2024 21:45:52 -0700 Subject: [PATCH 7/8] remove accidentally added version call --- eng/common/testproxy/test-proxy-tool.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index b1a5202f0cd4..9494b1cf0bfb 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -37,7 +37,6 @@ steps: --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 - $(Build.BinariesDirectory)/test-proxy --version displayName: "Install test-proxy" condition: and(succeeded(), ${{ parameters.condition }}) From 096a721f25fc1e881ee4e6ef9012f7e035b4c527 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 25 Apr 2024 10:21:15 -0700 Subject: [PATCH 8/8] ensure we properly create the new variable --- .../src/main/java/com/azure/core/test/utils/TestProxyUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java b/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java index 84fa1e32da53..9775a51eec6b 100644 --- a/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java +++ b/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java @@ -246,7 +246,7 @@ public static String getTestProxyVersion(Path testClassPath) { versionFile = overrideVersionFile; } - versionFilePath = rootPath.resolve(versionFile); + Path versionFilePath = rootPath.resolve(versionFile); try { return Files.readAllLines(versionFilePath).get(0).replace(System.getProperty("line.separator"), ""); } catch (IOException e) {