Migrate to matrix generator (#3553)

* Represent existing matrix in json
* Use new matrix
* Move to stage
* Cloud configuration
* MaxParallel
* DependsOn
* Quote CtestRegex
* Use template for cmake generate tests
* Template name mappings
* Formatting, parameters
* Remove duplicate bypass-local-dns.yml
* Enable Location override
* Add Location
* Add spelling words
* Use Ubuntu 20 where the name specifies Ubuntu 20
* Apply suggestions from code review

Co-authored-by: Ben Broderick Phillips <ben@benbp.net>

* PR feedback
* fix storage sample
* Matrix documentation

Co-authored-by: Ben Broderick Phillips <ben@benbp.net>
Co-authored-by: Victor Vazquez <vhvb1989@gmail.com>
This commit is contained in:
Daniel Jurek 2022-04-26 07:34:23 -07:00 committed by GitHub
parent 7b87ea1c85
commit 140e05baa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 632 additions and 467 deletions

4
.vscode/cspell.json vendored
View File

@ -146,7 +146,9 @@
"issecret",
"PSScriptRoot",
"BUILDID",
"cppvcpkgcache"
"cppvcpkgcache",
"cmakegenerate",
"cmakesourcegenerate"
]
},
{

View File

@ -1,131 +0,0 @@
parameters:
- name: Artifacts
type: object
default: []
- name: ArtifactsSource
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified
- name: CMakeTestOptions
type: object
default: []
- name: CMakeSourceTestOptions
type: object
default: []
jobs:
- job: CMakeGenerate
condition: and(succeededOrFailed(), ne(variables['Skip.CMakeGenerate'], 'true'))
strategy:
matrix:
Linux:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
CmakeEnvArg: ''
AptDependencies: 'libcurl4-openssl-dev'
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
Windows:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
CmakeEnvArg: ''
VCPKG_DEFAULT_TRIPLET: 'x64-windows'
Mac:
Pool: Azure Pipelines
OSVmImage: macOS-10.15
CmakeEnvArg: ''
VCPKG_DEFAULT_TRIPLET: 'x64-osx'
pool:
name: $(Pool)
vmImage: $(OSVmImage)
variables:
CMOCKA_XML_FILE: "%g-test-results.xml"
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- template: /eng/common/pipelines/templates/steps/bypass-local-dns.yml
- pwsh: sudo apt update && sudo apt install -y $(AptDependencies)
condition: and(succeeded(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: cmake --version
displayName: cmake --version
- ${{ each artifact in parameters.Artifacts }}:
- script: echo 'CMake generate tests for ${{ artifact.Name }}'
displayName: ${{ artifact.Name }}
- ${{ each cmakeOption in parameters.CMakeTestOptions }}:
- template: /eng/pipelines/templates/steps/cmake-generate.yml
parameters:
CmakeGeneratePath: sdk/${{ parameters.ServiceDirectory }}/${{ artifact.Path }}
GenerateArgs: ${{ cmakeOption.Value }}
Env: "$(CmakeEnvArg)"
- job: CMakeSourceGenerate
condition: and(succeededOrFailed(), ne(variables['Skip.CMakeGenerate'], 'true'))
strategy:
matrix:
Windows:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
CmakeEnvArg: ''
Linux:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
CmakeEnvArg: ''
AptDependencies: 'libcurl4-openssl-dev'
Mac:
Pool: Azure Pipelines
OSVmImage: macOS-10.15
CmakeEnvArg: 'OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@3/include '
BrewDependencies: 'openssl'
pool:
name: $(Pool)
vmImage: $(OSVmImage)
variables:
CMOCKA_XML_FILE: "%g-test-results.xml"
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- template: /eng/common/pipelines/templates/steps/bypass-local-dns.yml
- pwsh: sudo apt update && sudo apt install -y $(AptDependencies)
condition: and(succeeded(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- pwsh: |
brew install $(BrewDependencies)
condition: and(succeeded(), ne(variables['BrewDependencies'], ''))
displayName: Install dependencies from brew
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: cmake --version
displayName: cmake --version
- ${{ each artifact in parameters.ArtifactsSource }}:
- script: echo 'CMake generate tests for ${{ artifact.Name }}'
displayName: ${{ artifact.Name }}
- ${{ each cmakeOption in parameters.CMakeSourceTestOptions }}:
- template: /eng/pipelines/templates/steps/cmake-generate.yml
parameters:
CmakeGeneratePath: sdk/${{ parameters.ServiceDirectory }}/${{ artifact.Path }}
GenerateArgs: ${{ cmakeOption.Value }}
Env: "$(CmakeEnvArg)"

View File

@ -1,302 +0,0 @@
parameters:
- name: Location
type: string
default: ''
- name: SubscriptionConfiguration
type: string
default: $(sub-config-azure-cloud-test-resources)
- name: ServiceDirectory
type: string
default: not-specified
- name: CtestRegex
type: string
default: .*
- name: Coverage
type: string
default: 'enabled'
- name: CoverageReportPath
type: string
default: sdk/*/*/*cov_xml.xml
- name: TimeoutInMinutes
type: number
default: 60
# This job uses the legacy matrix format (matrix property of the job, one
# build/test scenario per job). A new format (multiple build/test scenarios per
# job) may be possible here:
# https://github.com/Azure/azure-sdk-for-cpp/issues/2944
jobs:
- job: ValidateLive
condition: and(succeededOrFailed(), ne(variables['Skip.LiveTest'], 'true'))
timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
strategy:
matrix:
Linux_x64_gcc5_with_unit_test:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
# Can't set CC and CXX to env because it would affect VCPKG building which requires g++ > 7
# So, this conf will set the CXX for cmake inline.
CmakeEnvArg: 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake'
BuildArgs: '-j 4'
CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON'
Linux_x64_with_unit_test:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
CmakeArgs: ' -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON'
AptDependencies: 'gcovr lcov'
CODE_COVERAGE: '${{ parameters.Coverage }}'
# Avoid re-running tests again for code coverage since the tests were previously ran
CODE_COVERAGE_COLLECT_ONLY: 1
AZURE_CORE_ENABLE_JSON_TESTS: 1
BuildArgs: '-j 4'
Ubuntu20_x64_with_unit_test:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
CmakeArgs: ' -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SAMPLES=ON'
AZURE_CORE_ENABLE_JSON_TESTS: 1
BuildArgs: '-j 4'
Ubuntu20_samples:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
# Builds samples and run them against the deployed resources. Samples requires Azure Account, so only works on live tests.
CmakeArgs: ' -DBUILD_TESTING=ON -DBUILD_SAMPLES=ON -DCMAKE_BUILD_TYPE=Release '
BuildArgs: '-j 4'
RunSamples: 1
Ubuntu20_x64_no_rtti:
Pool: azsdk-pool-mms-ubuntu-1804-general
OSVmImage: MMSUbuntu18.04
VCPKG_DEFAULT_TRIPLET: 'x64-linux'
CmakeArgs: ' -DBUILD_RTTI=OFF -DCMAKE_BUILD_TYPE=Release '
BuildArgs: '-j 4'
# Not asking for any transport adapter will default to OS -> windows:winHttp or !windows:libcurl
Win_x86_with_unit_test_winHttp:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
VCPKG_DEFAULT_TRIPLET: 'x86-windows-static'
VcpkgInstall: 'openssl'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: Win32
CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON '
BuildArgs: '-v --parallel 8 --config Release'
WindowsCtestConfig: "-C Release"
Win_x86_no_rtti_whit_unit_test:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
VcpkgInstall: 'libxml2 openssl'
VCPKG_DEFAULT_TRIPLET: 'x86-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: Win32
CmakeArgs: ' -DBUILD_RTTI=OFF -DBUILD_TESTING=ON -DBUILD_SAMPLES=ON'
BuildArgs: '-v --parallel 8 --config Release'
WindowsCtestConfig: "-C Release"
Win_x64_with_unit_test_winHttp:
Pool: azsdk-pool-mms-win-2019-general
VcpkgInstall: 'openssl'
OSVmImage: MMS2019
VCPKG_DEFAULT_TRIPLET: 'x64-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: x64
CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON '
BuildArgs: '-v --parallel 8 --config Release '
AZURE_CORE_ENABLE_JSON_TESTS: 1
WindowsCtestConfig: "-C Release"
Win_x64_with_unit_samples_winHttp:
Pool: azsdk-pool-mms-win-2019-general
VcpkgInstall: 'openssl'
OSVmImage: MMS2019
VCPKG_DEFAULT_TRIPLET: 'x64-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: x64
CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON '
BuildArgs: '-v --parallel 8 --config Release '
AZURE_CORE_ENABLE_JSON_TESTS: 1
RunSamples: 1
WindowsCtestConfig: "-C Release"
# specify libcurl to be used on Windows
Win_x86_with_unit_test_libcurl:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
VCPKG_DEFAULT_TRIPLET: 'x86-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: Win32
CmakeArgs: ' -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON '
BuildArgs: '-v --parallel 8'
#AZURE_CORE_ENABLE_JSON_TESTS: 1 # Testing Json lib on Win+WinHttp only, No need to repeat here as it is independent to the http transport adapter.
Win_x64_with_unit_test_libcurl:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
VCPKG_DEFAULT_TRIPLET: 'x64-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: x64
CmakeArgs: ' -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON '
BuildArgs: '-v --parallel 8 --config Release '
WindowsCtestConfig: "-C Release"
#AZURE_CORE_ENABLE_JSON_TESTS: 1 # Testing Json lib on Win+WinHttp only, No need to repeat here as it is independent to the http transport adapter.
Win_x64_with_unit_samples_libcurl:
Pool: azsdk-pool-mms-win-2019-general
OSVmImage: MMS2019
VcpkgInstall: 'curl[winssl] openssl'
VCPKG_DEFAULT_TRIPLET: 'x64-windows-static'
CMAKE_GENERATOR: 'Visual Studio 16 2019'
CMAKE_GENERATOR_PLATFORM: x64
CmakeArgs: ' -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON '
BuildArgs: '-v --parallel 8 --config Release '
RunSamples: 1
WindowsCtestConfig: "-C Release"
MacOS_x64_with_unit_test:
Pool: Azure Pipelines
OSVmImage: 'macOS-10.15'
VCPKG_DEFAULT_TRIPLET: 'x64-osx'
CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON'
AZURE_CORE_ENABLE_JSON_TESTS: 1
BuildArgs: '-j 4'
pool:
name: $(Pool)
vmImage: $(OSVmImage)
variables:
CMOCKA_XML_FILE: "%g-test-results.xml"
CMOCKA_MESSAGE_OUTPUT: "xml"
AZURE_ENABLE_STATIC_ANALYSIS: 1
BuildArgs: ""
WindowsCtestConfig: ""
CmakeEnvArg: ""
CmakeArgs: ""
AZURE_TEST_MODE: "LIVE"
AZURE_LOG_LEVEL: "verbose"
# Surface the ServiceDirectory parameter as an environment variable so tests can take advantage of it.
AZURE_SERVICE_DIRECTORY: ${{ parameters.ServiceDirectory }}
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- template: /eng/common/pipelines/templates/steps/bypass-local-dns.yml
# Add g++5 repo to ubuntu
- bash: sudo sh -c "echo 'deb http://ftp.debian.org/debian/ stretch main' >> /etc/apt/sources.list"
displayName: Add g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install g++5
- bash: sudo apt-get update & sudo apt-get install g++-5
displayName: Install g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install apt dependencies (if appropriate)
- bash: sudo apt install -y $(AptDependencies)
condition: and(succeededOrFailed(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
displayName: Install coverage tools
# CODE_COVERAGE variable is '' (do-not-generate) in all matrix but linux-gcc
# It is 'enabled' by default on linux-gcc but it can be opt-out by each pipeline (disabled)
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/pipelines/templates/steps/cmake-build.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
GenerateArgs: $(CmakeArgs)
BuildArgs: "$(BuildArgs)"
Env: "$(CmakeEnvArg)"
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
Location: ${{ parameters.Location }}
SubscriptionConfiguration: ${{ parameters.SubscriptionConfiguration }}
# For non multi-config generator use the same build configuration to run tests
# We don't need to set it to invoke ctest
# Visual Studio generator used in CI is a multi-config generator.
# As such, it requires the configuration argument for building and invoking ctest
- script: ctest $(WindowsCtestConfig) -V --tests-regex ${{ parameters.CtestRegex }} --no-compress-output -T Test
workingDirectory: build
displayName: ctest
# Runs only if test-resources are happly deployed.
# unit-tests runs for those configs where samples are not ran.
# This enables to run tests and samples at the same time as different matrix configuration.
# Then unit-tests runs, samples should not run.
condition: and(
succeeded(),
ne(variables['RunSamples'], '1'))
- task: PublishTestResults@2
inputs:
testResultsFormat: cTest
testResultsFiles: Testing/*/Test.xml
testRunTitle: $(Agent.JobName)
searchFolder: build
mergeTestResults: true
publishRunAttachments: true
displayName: Publish test results
# this step only makes sense when ctest has run
condition: and(succeededOrFailed(), ne(variables['RunSamples'], '1'))
# Running Samples step.
# Will run samples described on a file name [service]-samples.txt within the build directory.
# For example keyvault-samples.txt.
# The file is written by CMake during configuration when building samples.
- bash: |
IFS=$'\n'
if [[ -f "./${{ parameters.ServiceDirectory }}-samples.txt" ]]; then
for sample in `cat ./${{ parameters.ServiceDirectory }}-samples.txt`
do
echo "**********Running sample: ${sample}"
bash -c "$sample"
status=$?
if [[ $status -eq 0 ]]; then
echo "*********Sample completed*********"
else
echo "*Sample returned a failed code: $status"
exit 1
fi
done
fi
workingDirectory: build
displayName: "Run Samples for : ${{ parameters.ServiceDirectory }}"
condition: and(succeeded(), eq(variables['RunSamples'], '1'))
# Make coverage targets (specified in coverage_targets.txt) and assemble
# coverage report
- bash: |
make `cat ${{ parameters.ServiceDirectory }}-targets-coverage.txt`
../tools/reportgenerator "-reports:${{ parameters.CoverageReportPath }}" "-targetdir:." "-reporttypes:Cobertura"
workingDirectory: build
displayName: Generate Code Coverage Data
condition: and(succeeded(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/**/Cobertura.xml'
displayName: Publish Code Coverage to DevOps
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
SubscriptionConfiguration: ${{ parameters.SubscriptionConfiguration }}

View File

@ -20,6 +20,8 @@ parameters:
- name: CoverageEnabled
type: boolean
default: true
# Matrix generation:
# https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/job-matrix/README.md
- name: Matrix
type: string
- name: LineCoverageTarget

View File

@ -0,0 +1,46 @@
parameters:
- name: Artifacts
type: object
default: []
- name: ArtifactsSource
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified
- name: CMakeTestOptions
type: object
default: []
- name: CMakeSourceTestOptions
type: object
default: []
jobs:
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
parameters:
MatrixConfigs:
- Name: base
Path: eng/pipelines/templates/stages/platform-matrix-cmakegenerate.json
Selection: all
GenerateVMJobs: true
JobTemplatePath: /eng/pipelines/templates/jobs/cmake-generate.tests.yml
GenerateJobName: generate_matrix_cmake
AdditionalParameters:
Artifacts: ${{ parameters.Artifacts }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}
CMakeTestOptions: ${{ parameters.CMakeTestOptions }}
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
parameters:
MatrixConfigs:
- Name: base
Path: eng/pipelines/templates/stages/platform-matrix-cmakesourcegenerate.json
Selection: all
GenerateVMJobs: true
JobTemplatePath: /eng/pipelines/templates/jobs/cmake-generate.tests.yml
GenerateJobName: generate_matrix_cmake_source
AdditionalParameters:
Artifacts: ${{ parameters.ArtifactsSource }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}
CMakeTestOptions: ${{ parameters.CMakeSourceTestOptions }}
JobName: CMakeSourceGenerate

View File

@ -0,0 +1,86 @@
parameters:
- name: Artifacts
type: object
default: []
- name: ServiceDirectory
type: string
default: not-specified
- name: CMakeTestOptions
type: object
default: []
- name: MaxParallel
type: number
default: 0
# Matrix generation:
# https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/job-matrix/README.md
- name: Matrix
type: string
default: ''
- name: UsePlatformContainer
type: boolean
default: false
- name: DependsOn
type: string
default: not-set
- name: CloudConfig
type: object
default: {}
- name: JobName
type: string
default: CMakeGenerate
jobs:
- job: ${{ parameters.JobName }}
condition: >-
and(
succeededOrFailed(),
ne(variables['Skip.CMakeGenerate'], 'true'),
ne(${{ parameters.Matrix }}, '{}')
)
dependsOn: ${{ parameters.DependsOn }}
strategy:
maxParallel: ${{ parameters.MaxParallel }}
matrix: $[ ${{ parameters.Matrix }} ]
pool:
name: $(Pool)
vmImage: $(OSVmImage)
${{ if eq(parameters.UsePlatformContainer, 'true') }}:
# Add a default so the job doesn't fail when the matrix is empty
container: $[ variables['Container'] ]
variables:
CMOCKA_XML_FILE: "%g-test-results.xml"
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- pwsh: sudo apt update && sudo apt install -y $(AptDependencies)
condition: and(succeeded(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- pwsh: |
brew install $(BrewDependencies)
condition: and(succeeded(), ne(variables['BrewDependencies'], ''))
displayName: Install dependencies from brew
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: cmake --version
displayName: cmake --version
- ${{ each artifact in parameters.Artifacts }}:
- script: echo 'CMake generate tests for ${{ artifact.Name }}'
displayName: ${{ artifact.Name }}
- ${{ each cmakeOption in parameters.CMakeTestOptions }}:
- template: /eng/pipelines/templates/steps/cmake-generate.yml
parameters:
CmakeGeneratePath: sdk/${{ parameters.ServiceDirectory }}/${{ artifact.Path }}
GenerateArgs: ${{ cmakeOption.Value }}
Env: "$(CmakeEnvArg)"

View File

@ -0,0 +1,199 @@
parameters:
- name: Location
type: string
default: ''
- name: SubscriptionConfiguration
type: string
default: $(sub-config-azure-cloud-test-resources)
- name: ServiceDirectory
type: string
default: not-specified
- name: CtestRegex
type: string
default: .*
- name: Coverage
type: string
default: 'enabled'
- name: CoverageReportPath
type: string
default: sdk/*/*/*cov_xml.xml
- name: TimeoutInMinutes
type: number
default: 60
- name: DependsOn
type: string
default: ''
# Matrix generation:
# https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/scripts/job-matrix/README.md
- name: Matrix
type: string
- name: MaxParallel
type: number
default: 0
- name: CloudConfig
type: object
default: {}
- name: UsePlatformContainer
type: boolean
default: false
jobs:
- job: ValidateLive
dependsOn: ${{ parameters.DependsOn }}
condition: ne(${{ parameters.Matrix }}, '{}')
pool:
name: $(Pool)
vmImage: $(OSVmImage)
${{ if eq(parameters.UsePlatformContainer, 'true') }}:
# Add a default so the job doesn't fail when the matrix is empty
container: $[ variables['Container'] ]
strategy:
maxParallel: ${{ parameters.MaxParallel }}
matrix: $[ ${{ parameters.Matrix }} ]
variables:
CMOCKA_XML_FILE: "%g-test-results.xml"
CMOCKA_MESSAGE_OUTPUT: "xml"
AZURE_ENABLE_STATIC_ANALYSIS: 1
BuildArgs: ""
WindowsCtestConfig: ""
CmakeEnvArg: ""
CmakeArgs: ""
AZURE_TEST_MODE: "LIVE"
AZURE_LOG_LEVEL: "verbose"
# Surface the ServiceDirectory parameter as an environment variable so tests can take advantage of it.
AZURE_SERVICE_DIRECTORY: ${{ parameters.ServiceDirectory }}
steps:
- checkout: self
submodules: recursive
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
parameters:
AgentImage: $(OSVmImage)
- template: /eng/common/pipelines/templates/steps/bypass-local-dns.yml
# Add g++5 repo to ubuntu
- bash: sudo sh -c "echo 'deb http://ftp.debian.org/debian/ stretch main' >> /etc/apt/sources.list"
displayName: Add g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install g++5
- bash: sudo apt-get update & sudo apt-get install g++-5
displayName: Install g++ 5
condition: >-
and(
succeeded(),
contains(variables['OSVmImage'], 'Ubuntu'),
contains(variables['CmakeEnvArg'], 'CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake')
)
# Install apt dependencies (if appropriate)
- bash: sudo apt install -y $(AptDependencies)
condition: and(succeededOrFailed(), ne(variables['AptDependencies'], ''))
displayName: Install dependencies from apt
- template: /eng/pipelines/templates/steps/vcpkg.yml
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
displayName: Install coverage tools
# CODE_COVERAGE variable is '' (do-not-generate) in all matrix but linux-gcc
# It is 'enabled' by default on linux-gcc but it can be opt-out by each pipeline (disabled)
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/pipelines/templates/steps/cmake-build.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
GenerateArgs: $(CmakeArgs)
BuildArgs: "$(BuildArgs)"
Env: "$(CmakeEnvArg)"
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
${{ if or(parameters.Location, parameters.CloudConfig.Location) }}:
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
# For non multi-config generator use the same build configuration to run tests
# We don't need to set it to invoke ctest
# Visual Studio generator used in CI is a multi-config generator.
# As such, it requires the configuration argument for building and invoking ctest
- script: ctest $(WindowsCtestConfig) -V --tests-regex "${{ parameters.CtestRegex }}" --no-compress-output -T Test
workingDirectory: build
displayName: ctest
# Runs only if test-resources are happly deployed.
# unit-tests runs for those configs where samples are not ran.
# This enables to run tests and samples at the same time as different matrix configuration.
# Then unit-tests runs, samples should not run.
condition: and(
succeeded(),
ne(variables['RunSamples'], '1'))
- task: PublishTestResults@2
inputs:
testResultsFormat: cTest
testResultsFiles: Testing/*/Test.xml
testRunTitle: $(Agent.JobName)
searchFolder: build
mergeTestResults: true
publishRunAttachments: true
displayName: Publish test results
# this step only makes sense when ctest has run
condition: and(succeededOrFailed(), ne(variables['RunSamples'], '1'))
# Running Samples step.
# Will run samples described on a file name [service]-samples.txt within the build directory.
# For example keyvault-samples.txt.
# The file is written by CMake during configuration when building samples.
- bash: |
IFS=$'\n'
if [[ -f "./${{ parameters.ServiceDirectory }}-samples.txt" ]]; then
for sample in `cat ./${{ parameters.ServiceDirectory }}-samples.txt`
do
echo "**********Running sample: ${sample}"
bash -c "$sample"
status=$?
if [[ $status -eq 0 ]]; then
echo "*********Sample completed*********"
else
echo "*Sample returned a failed code: $status"
exit 1
fi
done
fi
workingDirectory: build
displayName: "Run Samples for : ${{ parameters.ServiceDirectory }}"
condition: and(succeeded(), eq(variables['RunSamples'], '1'))
# Make coverage targets (specified in coverage_targets.txt) and assemble
# coverage report
- bash: |
make `cat ${{ parameters.ServiceDirectory }}-targets-coverage.txt`
../tools/reportgenerator "-reports:${{ parameters.CoverageReportPath }}" "-targetdir:." "-reporttypes:Cobertura"
workingDirectory: build
displayName: Generate Code Coverage Data
condition: and(succeeded(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/**/Cobertura.xml'
displayName: Publish Code Coverage to DevOps
condition: and(succeededOrFailed(), ne(variables['CODE_COVERAGE'], 'disabled'), ne(variables['CODE_COVERAGE'], ''))
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
SubscriptionConfiguration: ${{ parameters.SubscriptionConfiguration }}

View File

@ -20,12 +20,6 @@ parameters:
- name: ArtifactsSource
type: object
default: []
- name: Location
type: string
default: ''
- name: SubscriptionConfiguration
type: string
default: $(sub-config-azure-cloud-test-resources)
- name: CoverageReportPath
type: string
default: 'sdk/*/*/*cov_xml.xml'
@ -47,11 +41,38 @@ parameters:
- name: CMakeSourceTestOptions
type: object
default: []
- name: Location
type: string
default: ''
- name: CloudConfig
type: object
default:
Public:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
Preview:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview)
Canary:
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
Location: 'eastus2euap'
UsGov:
SubscriptionConfiguration: $(sub-config-gov-test-resources)
China:
SubscriptionConfiguration: $(sub-config-cn-test-resources)
- name: Clouds
type: string
default: Public
- name: SupportedClouds
type: string
default: Public
- name: UnsupportedClouds
type: string
default: ''
stages:
- stage: CMakeGeneration
jobs:
- template: /eng/pipelines/templates/jobs/archetype-sdk-cmake-generate.yml
- template: /eng/pipelines/templates/jobs/cmake-generate-jobs.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
Artifacts: ${{ parameters.Artifacts }}
@ -77,18 +98,18 @@ stages:
TestEnv: ${{ parameters.TestEnv }}
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(parameters.LiveTestCtestRegex, '')) }}:
- stage: LiveTest
dependsOn: []
jobs:
- template: /eng/pipelines/templates/jobs/archetype-sdk-tests.yml
# Code coverage is enabled by default for live tests
parameters:
TimeoutInMinutes: ${{ parameters.LiveTestTimeoutInMinutes }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}
CtestRegex: ${{ parameters.LiveTestCtestRegex }}
Location: ${{ parameters.Location }}
SubscriptionConfiguration: ${{ parameters.SubscriptionConfiguration }}
CoverageReportPath: ${{ parameters.CoverageReportPath }}
- template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml
# Code coverage is enabled by default for live tests
parameters:
TimeoutInMinutes: ${{ parameters.LiveTestTimeoutInMinutes }}
ServiceDirectory: ${{ parameters.ServiceDirectory }}
CtestRegex: ${{ parameters.LiveTestCtestRegex }}
CoverageReportPath: ${{ parameters.CoverageReportPath }}
Location: ${{ parameters.Location }}
CloudConfig: ${{ parameters.CloudConfig }}
Clouds: ${{ parameters.Clouds }}
SupportedClouds: ${{ parameters.SupportedClouds }}
UnsupportedClouds: ${{ parameters.UnsupportedClouds }}
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), not(endsWith(variables['Build.DefinitionName'], ' - tests'))) }}:
- template: archetype-cpp-release.yml
@ -98,7 +119,11 @@ stages:
- Build
# Only depend on `LiveTest` if there are live tests to execute
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(parameters.LiveTestCtestRegex, '')) }}:
- LiveTest
# Pulled from stages/archetype-sdk-tests.yml to generate 'LiveTest_<cloud>'
- ${{ each cloud in parameters.CloudConfig }}:
- ${{ if or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'tests-weekly'), contains(parameters.SupportedClouds, cloud.key))) }}:
- ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}:
- LiveTest_${{ cloud.key }}
Artifacts: ${{ parameters.Artifacts }}
ArtifactName: packages
${{ if eq(parameters.ServiceDirectory, 'template') }}:

View File

@ -0,0 +1,59 @@
parameters:
- name: ServiceDirectory
type: string
default: not-specified
- name: CtestRegex
type: string
default: .*
- name: Coverage
type: string
default: 'enabled'
- name: CoverageReportPath
type: string
default: sdk/*/*/*cov_xml.xml
- name: TimeoutInMinutes
type: number
default: 60
- name: Location
type: string
default: ''
- name: CloudConfig
type: object
default: {}
- name: Clouds
type: string
default: Public
- name: SupportedClouds
type: string
default: 'Public'
- name: UnsupportedClouds
type: string
default: ''
stages:
- ${{ each cloud in parameters.CloudConfig }}:
- ${{ if or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'tests-weekly'), contains(parameters.SupportedClouds, cloud.key))) }}:
- ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}:
- stage: LiveTest_${{ cloud.key }}
dependsOn: []
jobs:
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
parameters:
MatrixConfigs:
- Name: base
Path: eng/pipelines/templates/stages/platform-matrix-live.json
Selection: all
GenerateVMJobs: true
JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml
CloudConfig:
SubscriptionConfiguration: ${{ cloud.value.SubscriptionConfiguration }}
SubscriptionConfigurations: ${{ cloud.value.SubscriptionConfigurations }}
Location: ${{ coalesce(parameters.Location, cloud.value.Location) }}
Cloud: ${{ cloud.key }}
AdditionalParameters:
Location: ${{ parameters.Location}}
ServiceDirectory: ${{ parameters.ServiceDirectory}}
CtestRegex: ${{ parameters.CtestRegex}}
Coverage: ${{ parameters.Coverage}}
CoverageReportPath: ${{ parameters.CoverageReportPath}}
TimeoutInMinutes: ${{ parameters.TimeoutInMinutes}}

View File

@ -0,0 +1,23 @@
{
"matrix": {
"CmakeEnvArg": "",
"OSConfig": {
"Linux": {
"Pool": "azsdk-pool-mms-ubuntu-1804-general",
"OSVmImage": "MMSUbuntu18.04",
"AptDependencies": "libcurl4-openssl-dev",
"VCPKG_DEFAULT_TRIPLET": "x64-linux"
},
"Windows": {
"Pool": "azsdk-pool-mms-win-2019-general",
"OSVmImage": "MMS2019",
"VCPKG_DEFAULT_TRIPLET": "x64-windows"
},
"Mac": {
"Pool": "Azure Pipelines",
"OSVmImage": "macOS-10.15",
"VCPKG_DEFAULT_TRIPLET": "x64-osx"
}
}
}
}

View File

@ -0,0 +1,23 @@
{
"matrix": {
"OSConfig": {
"Windows": {
"Pool": "azsdk-pool-mms-win-2019-general",
"OSVmImage": "MMS2019",
"CmakeEnvArg": ""
},
"Linux": {
"Pool": "azsdk-pool-mms-ubuntu-1804-general",
"OSVmImage": "MMSUbuntu18.04",
"CmakeEnvArg": "",
"AptDependencies": "libcurl4-openssl-dev"
},
"Mac": {
"Pool": "Azure Pipelines",
"OSVmImage": "macOS-10.15",
"CmakeEnvArg": "OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@3/include ",
"BrewDependencies": "openssl"
}
}
}
}

View File

@ -0,0 +1,133 @@
{
"displayNames": {
"_": ""
},
"include": [
{
"StaticConfigs": {
"MacOS_x64_with_unit_test": {
"Pool": "Azure Pipelines",
"OSVmImage": "macOS-10.15",
"VCPKG_DEFAULT_TRIPLET": "x64-osx",
"CmakeArgs": " -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON",
"AZURE_CORE_ENABLE_JSON_TESTS": 1,
"BuildArgs": "-j 4"
}
}
},
{
"StaticConfigs": {
"_": {
"VCPKG_DEFAULT_TRIPLET": "x64-linux",
"BuildArgs": "-j 4",
"Pool": "azsdk-pool-mms-ubuntu-1804-general",
"OSVmImage": "MMSUbuntu18.04"
}
},
"BuildConfig": {
"Linux_x64_gcc5_with_unit_test": {
"CmakeEnvArg": "CC=/usr/bin/gcc-5 CXX=/usr/bin/g++-5 cmake",
"CmakeArgs": " -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON"
},
"Linux_x64_with_unit_test": {
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON",
"AptDependencies": "gcovr lcov",
"CODE_COVERAGE": "enabled",
"CODE_COVERAGE_COLLECT_ONLY": 1,
"AZURE_CORE_ENABLE_JSON_TESTS": 1
}
}
},
{
"StaticConfigs": {
"_": {
"BuildArgs": "-j 4",
"Pool": "azsdk-pool-mms-ubuntu-2004-general",
"OSVmImage": "MMSUbuntu20.04",
"VCPKG_DEFAULT_TRIPLET": "x64-linux"
}
},
"BuildConfiguration": {
"Ubuntu20_x64_with_unit_test": {
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SAMPLES=ON",
"AZURE_CORE_ENABLE_JSON_TESTS": 1
},
"Ubuntu20_samples": {
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_SAMPLES=ON -DCMAKE_BUILD_TYPE=Release ",
"RunSamples": 1
},
"Ubuntu20_x64_no_rtti": {
"CmakeArgs": " -DBUILD_RTTI=OFF -DCMAKE_BUILD_TYPE=Release "
}
}
},
{
"StaticConfigs": {
"_": {
"Pool": "azsdk-pool-mms-win-2019-general",
"OSVmImage": "MMS2019",
"CMAKE_GENERATOR": "Visual Studio 16 2019"
}
},
"BuildConfig": {
"Win_x86_with_unit_test_winHttp": {
"VcpkgInstall": "openssl",
"CMAKE_GENERATOR_PLATFORM": "Win32",
"CmakeArgs": " -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON ",
"VCPKG_DEFAULT_TRIPLET": "x86-windows-static",
"WindowsCtestConfig": "-C Release",
"BuildArgs": "-v --parallel 8 --config Release"
},
"Win_x86_no_rtti_whit_unit_test": {
"VcpkgInstall": "libxml2 openssl",
"CMAKE_GENERATOR_PLATFORM": "Win32",
"CmakeArgs": " -DBUILD_RTTI=OFF -DBUILD_TESTING=ON -DBUILD_SAMPLES=ON",
"VCPKG_DEFAULT_TRIPLET": "x86-windows-static",
"WindowsCtestConfig": "-C Release",
"BuildArgs": "-v --parallel 8 --config Release"
},
"Win_x86_with_unit_test_libcurl": {
"CMAKE_GENERATOR_PLATFORM": "Win32",
"VCPKG_DEFAULT_TRIPLET": "x86-windows-static",
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON ",
"BuildArgs": "-v --parallel 8"
},
"Win_x64_with_unit_test_winHttp": {
"VcpkgInstall": "openssl",
"CMAKE_GENERATOR_PLATFORM": "x64",
"CmakeArgs": " -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON ",
"BuildArgs": "-v --parallel 8 --config Release",
"AZURE_CORE_ENABLE_JSON_TESTS": 1,
"VCPKG_DEFAULT_TRIPLET": "x64-windows-static",
"WindowsCtestConfig": "-C Release"
},
"Win_x64_with_unit_samples_winHttp": {
"VcpkgInstall": "openssl",
"VCPKG_DEFAULT_TRIPLET": "x64-windows-static",
"CMAKE_GENERATOR_PLATFORM": "x64",
"CmakeArgs": " -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON ",
"BuildArgs": "-v --parallel 8 --config Release",
"AZURE_CORE_ENABLE_JSON_TESTS": 1,
"RunSamples": 1,
"WindowsCtestConfig": "-C Release"
},
"Win_x64_with_unit_test_libcurl": {
"VCPKG_DEFAULT_TRIPLET": "x64-windows-static",
"CMAKE_GENERATOR_PLATFORM": "x64",
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON ",
"BuildArgs": "-v --parallel 8 --config Release",
"WindowsCtestConfig": "-C Release"
},
"Win_x64_with_unit_samples_libcurl": {
"VcpkgInstall": "curl[winssl] openssl",
"VCPKG_DEFAULT_TRIPLET": "x64-windows-static",
"CMAKE_GENERATOR_PLATFORM": "x64",
"CmakeArgs": " -DBUILD_TRANSPORT_CURL=ON -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_PERFORMANCE_TESTS=ON -DBUILD_SAMPLES=ON ",
"BuildArgs": "-v --parallel 8 --config Release",
"RunSamples": 1,
"WindowsCtestConfig": "-C Release"
}
}
}
]
}

View File

@ -26,6 +26,7 @@ stages:
- template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: attestation
Clouds: Public
Location: WestUS
CtestRegex: azure-security-attestation.*
LiveTestCtestRegex: azure-security-attestation.*

View File

@ -38,7 +38,7 @@ stages:
# 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"'
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

View File

@ -29,7 +29,6 @@ stages:
CtestRegex: "azure-security-keyvault.*"
LiveTestCtestRegex: "azure-security-keyvault.*"
LiveTestTimeoutInMinutes: 120
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
LineCoverageTarget: 81
BranchCoverageTarget: 42
Artifacts:

View File

@ -538,32 +538,31 @@ namespace Azure { namespace Storage { namespace Test {
std::vector<uint8_t> expectedData = m_fileContent;
int64_t fileSize = m_fileContent.size();
int64_t actualDownloadSize = std::min(p.DownloadSize, fileSize);
auto offset = p.Offset;
auto length = p.Length;
auto chunkSize = p.ChunkSize;
auto concurrency = p.Concurrency;
auto initialChunkSize = p.InitialChunkSize;
if (offset.HasValue() && length.HasValue())
if (p.Offset.HasValue() && length.HasValue())
{
actualDownloadSize = std::min(length.Value(), fileSize - offset.Value());
actualDownloadSize = std::min(length.Value(), fileSize - p.Offset.Value());
if (actualDownloadSize >= 0)
{
expectedData.assign(
m_fileContent.begin() + static_cast<ptrdiff_t>(offset.Value()),
m_fileContent.begin() + static_cast<ptrdiff_t>(offset.Value() + actualDownloadSize));
m_fileContent.begin() + static_cast<ptrdiff_t>(p.Offset.Value()),
m_fileContent.begin() + static_cast<ptrdiff_t>(p.Offset.Value() + actualDownloadSize));
}
else
{
expectedData.clear();
}
}
else if (offset.HasValue())
else if (p.Offset.HasValue())
{
actualDownloadSize = fileSize - offset.Value();
actualDownloadSize = fileSize - p.Offset.Value();
if (actualDownloadSize >= 0)
{
expectedData.assign(
m_fileContent.begin() + static_cast<ptrdiff_t>(offset.Value()), m_fileContent.end());
m_fileContent.begin() + static_cast<ptrdiff_t>(p.Offset.Value()), m_fileContent.end());
}
else
{
@ -573,10 +572,10 @@ namespace Azure { namespace Storage { namespace Test {
downloadBuffer.resize(static_cast<size_t>(p.DownloadSize), '\x00');
Files::Shares::DownloadFileToOptions options;
options.TransferOptions.Concurrency = concurrency;
if (offset.HasValue())
if (p.Offset.HasValue())
{
options.Range = Core::Http::HttpRange();
options.Range.Value().Offset = offset.Value();
options.Range.Value().Offset = p.Offset.Value();
options.Range.Value().Length = length;
}

View File

@ -30,7 +30,8 @@ stages:
LineCoverageTarget: 76
BranchCoverageTarget: 41
LiveTestCtestRegex: azure-storage
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview)
Clouds: Preview
SupportedClouds: Preview
Artifacts:
- Name: azure-storage-common
Path: azure-storage-common