azure-sdk-for-cpp/sdk/core/ci.yml
Larry Osterman b12942e115
Add support for Proxy Server to WinHTTP and CURL transports. (#3885)
# Add Support for Proxy Server to WinHTTP and CURL transports.

This PR adds support for proxy servers (with optional basic authentication) to the HTTP transports supported by C++.

* Use a singleton for WinHTTP transport to enable connection pooling across multiple service clients (support modeled after .Net equivalent functionality).
* Fixed retry delay to match azure guidelines; documented test hook in CalculateExponentialDelay.

Co-authored-by: George Arama <50641385+gearama@users.noreply.github.com>
Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Rick Winter <rick.winter@microsoft.com>
2022-08-19 22:42:47 +00:00

158 lines
7.0 KiB
YAML

# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
trigger:
batch: true
branches:
include:
- master
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- cmake-modules/
- eng/
- CMakeLists.txt
- sdk/core
pr:
branches:
include:
- master
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- cmake-modules/
- eng/
- CMakeLists.txt
- sdk/core
stages:
- template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: core
# CI has static code analysis disabled, while LiveTest will have it enabled
# In the case of changes to core we want to re-run all CI tests for all
# libraries to check for potential regressions everywhere.
CtestRegex: .*
LiveTestCtestRegex: azure-core.|json-test
LiveTestTimeoutInMinutes: 90 # default is 60 min. We need a little longer on worst case for Win+jsonTests
LineCoverageTarget: 93
BranchCoverageTarget: 55
PreTestSteps:
- task: UsePythonVersion@0
displayName: 'Use Python 3'
inputs:
versionSpec: '3'
condition: and(succeeded(), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
- pwsh: |
python --version
pip install -r requirements.txt
workingDirectory: build/sdk/core/azure-core/test/ut
displayName: Install Python requirements.
condition: and(succeeded(), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
- task: PowerShell@2
displayName: 'Launch python websocket server'
inputs:
pwsh: true
filePath: build/sdk/core/azure-core/test/ut/Start-WebSocketServer.ps1
arguments: $(Build.SourcesDirectory)/WebSocketServer.log
workingDirectory: build/sdk/core/azure-core/test/ut
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
# It would be nice to collapse this branch with the previous one, but nohup doesn't seem to
# behave when called from powershell.
- bash: |
nohup python sdk/core/azure-core/test/ut/websocket_server.py > $(Build.SourcesDirectory)/WebSocketServer.log &
workingDirectory: build
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
displayName: Launch python websocket server (Linux).
- pwsh: |
docker build -t squid-local $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy
docker build -t squid-local.passwd $(Build.SourcesDirectory)/sdk/core/azure-core/test/ut/proxy_tests/localproxy.passwd
docker run --rm -d -p 3128:3128 squid-local
docker run --rm -d -p 3129:3129 squid-local.passwd
displayName: Launch Docker container proxy.
# The image we use for MacOS doesn't support docker, so skip on MacOS.
# We don't have a squid proxy container for windows, so we only run this on Ubuntu.
condition: and(succeeded(), contains(variables.CmakeArgs, 'CODE_COVERAGE'), contains(variables.CmakeArgs, 'BUILD_TESTING=ON'))
PostTestSteps:
# Shut down the test server. This uses curl to send a request to the "terminateserver" websocket endpoint.
# When the test server receives a request on terminateserver, it shuts down gracefully.
- pwsh: |
curl `
--include `
--no-buffer `
--header "Connection: Upgrade" `
--header "Upgrade: websocket" `
--header "Host: localhost:8000" `
--header "Origin: http://localhost:8000" `
--header "Sec-WebSocket-Key: eaQZ9ed+LnT0zs5EvI04aQ==" `
--header "Sec-WebSocket-Version: 13" `
http://localhost:8000/terminateserver
displayName: Shutdown WebSocket server.
condition: contains(variables.CmakeArgs, 'BUILD_TESTING=ON')
- pwsh: |
docker ps -q -f ancestor=azsdkengsys.azurecr.io/cpp/squid | ForEach-Object { `
docker stop $_ `
}
displayName: Shutdown Squid Proxy.
condition: and(contains(variables.CmakeArgs, 'BUILD_TESTING=ON'), contains(variables['OSVmImage'], 'ubuntu'))
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
ArtifactPath: '$(Build.SourcesDirectory)/WebSocketServer.log'
ArtifactName: 'WebSocketLogs-$(Agent.JobName)_attempt_$(System.JobAttempt)'
CustomCondition: contains(variables.CmakeArgs, 'BUILD_TESTING=ON')
Artifacts:
- Name: azure-core
Path: azure-core
VcpkgPortName: azure-core-cpp
- Name: azure-core-tracing-opentelemetry
Path: azure-core-tracing-opentelemetry
VcpkgPortName: azure-core-tracing-opentelemetry-cpp
# Since Azure Core will run all service's tests, it requires all the expected env vars from services
TestEnv:
# Key Vault
- Name: AZURE_KEYVAULT_URL
Value: "https://non-real-account.vault.azure.net"
- Name: AZURE_KEYVAULT_HSM_URL
Value: "https://non-real-account.managedhsm.azure.net/"
# Key Vault & Identity
- Name: AZURE_TENANT_ID
Value: "33333333-3333-3333-3333-333333333333"
- Name: AZURE_CLIENT_ID
Value: "non-real-client"
- Name: AZURE_CLIENT_SECRET
Value: "non-real-secret"
# Storage
- Name: AAD_TENANT_ID
Value: "33333333-3333-3333-3333-333333333333"
- Name: AAD_CLIENT_ID
Value: "non-real-client"
- Name: AAD_CLIENT_SECRET
Value: "non-real-secret"
- Name: STANDARD_STORAGE_CONNECTION_STRING
Value: "DefaultEndpointsProtocol=https;AccountName=notReal;AccountKey=3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333;EndpointSuffix=core.windows.net"
- Name: ADLS_GEN2_CONNECTION_STRING
Value: "DefaultEndpointsProtocol=https;AccountName=notReal;AccountKey=3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333;EndpointSuffix=core.windows.net"
- Name: PREMIUM_FILE_CONNECTION_STRING
Value: "DefaultEndpointsProtocol=https;AccountName=notReal;AccountKey=3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333;EndpointSuffix=core.windows.net"
# Attestation
- Name: LOCATION_SHORT_NAME
Value: "wus"
- Name: ATTESTATION_ISOLATED_URL
Value: https://NotRealAttestationInstanceiso.wus.attest.azure.net
- Name: ATTESTATION_AAD_URL
Value: https://NotRealAttestationInstanceaad.wus.attest.azure.net
CMakeTestOptions:
- Name: Default
Value: ''
- Name: Test
Value: '-DBUILD_TESTING=ON'