diff --git a/eng/common/testproxy/docker-start-proxy.ps1 b/eng/common/testproxy/docker-start-proxy.ps1 index 1bef33483e0a7..c15fc37a7e404 100644 --- a/eng/common/testproxy/docker-start-proxy.ps1 +++ b/eng/common/testproxy/docker-start-proxy.ps1 @@ -13,6 +13,9 @@ Pass value "start" or "stop" to start up or stop the test-proxy instance. .PARAMETER TargetFolder The folder in which context the test proxy will be started. Defaults to current working directory. +.PARAMETER VersionOverride +This script defaults the proxy version to the "common" version synced across all sdk repositories. If provided, +this parameter's value will be used as the target tag when downloading the image from azsdk docker hosting. #> [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -20,7 +23,9 @@ param( [String] $Mode, [String] - $TargetFolder = "" + $TargetFolder = "", + [String] + $VersionOverride = "" ) try { @@ -31,11 +36,16 @@ catch { Write-Error "Please check your docker invocation and try running the script again." } -$SELECTED_IMAGE_TAG = "1369319" +$SELECTED_IMAGE_TAG = $(Get-Content "$PSScriptRoot/target_version.txt" -Raw).Trim() $CONTAINER_NAME = "ambitious_azsdk_test_proxy" $LINUX_IMAGE_SOURCE = "azsdkengsys.azurecr.io/engsys/testproxy-lin:${SELECTED_IMAGE_TAG}" $WINDOWS_IMAGE_SOURCE = "azsdkengsys.azurecr.io/engsys/testproxy-win:${SELECTED_IMAGE_TAG}" +if($VersionOverride) { + Write-Host "Overriding default target proxy version of '$SELECTED_IMAGE_TAG' with override $VersionOverride." + $SELECTED_IMAGE_TAG = $VersionOverride +} + if (-not $TargetFolder){ $TargetFolder = Join-Path -Path $PSScriptRoot -ChildPath "../../../" } @@ -51,7 +61,7 @@ function Get-Proxy-Container(){ $SelectedImage = $LINUX_IMAGE_SOURCE $Initial = "" -$LinuxContainerArgs = "--add-host=host.docker.internal:host-gateway" +$AdditionalContainerArgs = "--add-host=host.docker.internal:host-gateway" # most of the time, running this script on a windows machine will work just fine, as docker defaults to linux containers # however, in CI, windows images default to _windows_ containers. We cannot swap them. We can tell if we're in a CI build by @@ -59,7 +69,13 @@ $LinuxContainerArgs = "--add-host=host.docker.internal:host-gateway" if ($IsWindows -and $env:TF_BUILD){ $SelectedImage = $WINDOWS_IMAGE_SOURCE $Initial = "C:" - $LinuxContainerArgs = "" + $AdditionalContainerArgs = "" +} + +# there isn't really a great way to get environment variables automagically from the CI environment to the docker image +# handle loglevel here so that setting such a setting in CI will also bump the docker logging +if ($env:Logging__LogLevel__Default) { + $AdditionalContainerArgs += "-e Logging__LogLevel__Default=$($env:Logging__LogLevel__Default)" } if ($Mode -eq "start"){ @@ -77,9 +93,9 @@ if ($Mode -eq "start"){ else { $attempts = 0 Write-Host "Attempting creation of Docker host $CONTAINER_NAME" - Write-Host "docker container create -v `"${root}:${Initial}/srv/testproxy`" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage" + Write-Host "docker container create -v `"${root}:${Initial}/srv/testproxy`" $AdditionalContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage" while($attempts -lt 3){ - docker container create -v "${root}:${Initial}/srv/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage + docker container create -v "${root}:${Initial}/srv/testproxy" $AdditionalContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage if($LASTEXITCODE -ne 0){ $attempts += 1 diff --git a/eng/common/testproxy/target_version.txt b/eng/common/testproxy/target_version.txt new file mode 100644 index 0000000000000..ac34389c60993 --- /dev/null +++ b/eng/common/testproxy/target_version.txt @@ -0,0 +1 @@ +1.0.0-dev.20220224.2 diff --git a/eng/common/testproxy/test-proxy-docker.yml b/eng/common/testproxy/test-proxy-docker.yml index 8cde51a898191..df2548ab77662 100644 --- a/eng/common/testproxy/test-proxy-docker.yml +++ b/eng/common/testproxy/test-proxy-docker.yml @@ -1,5 +1,6 @@ parameters: - rootFolder: '$(Build.SourcesDirectory)' + rootFolder: '$(Build.SourcesDirectory)' + targetVersion: '' steps: - pwsh: | @@ -11,7 +12,7 @@ steps: displayName: 'Dump active docker information' - pwsh: | - $(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}" + $(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}" -VersionOverride="${{ parameters.targetVersion }}" displayName: 'Run the docker container' - pwsh: | diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index a1d5191eb01b1..9006c0d7af761 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -1,6 +1,7 @@ parameters: rootFolder: '$(Build.SourcesDirectory)' runProxy: true + targetVersion: '' steps: - pwsh: | @@ -8,10 +9,18 @@ steps: displayName: 'Language Specific Certificate Trust' - pwsh: | + $version = $(Get-Content "$(Build.SourcesDirectory)/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 1.0.0-dev.20220210.1 + --version $version displayName: "Install test-proxy" - pwsh: |