Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into dmlib-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinming-Hu committed Oct 31, 2022
2 parents 585869a + bb95a22 commit fbad07b
Show file tree
Hide file tree
Showing 96 changed files with 5,132 additions and 1,289 deletions.
4 changes: 4 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
".github/CODEOWNERS",
".gitignore",
".vscode/cspell.json",
"vcpkg-custom-ports",
"ci.yml",
"squid.conf*",
"eng/common/**/*",
Expand Down Expand Up @@ -54,6 +55,7 @@
"Deserializes",
"DFETCH",
"DMSVC",
"DVCPKG",
"docfx",
"DPAPI",
"DRUN",
Expand All @@ -73,7 +75,9 @@
"HKEY",
"HRESULT",
"IMDS",
"immutability",
"Intel",
"issecret",
"itfactor",
"iusg",
"jepio",
Expand Down
58 changes: 58 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,64 @@
"name": "MSVC_USE_STATIC_CRT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_MANIFEST_MODE",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-DebugWithTests-OpenSSL111",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "VCPKG_TARGET_TRIPLET",
"value": "x64-windows-static",
"type": "STRING"
},
{
"name": "MSVC_USE_STATIC_CRT",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_MANIFEST_MODE",
"value": "True",
"type": "BOOL"
},
{
"name": "VCPKG_OVERLAY_PORTS",
"value": "${projectDir}\\vcpkg-custom-ports",
"type": "STRING"
},
{
"name": "INSTALL_GTEST",
"value": "False",
"type": "BOOL"
},
{
"name": "BUILD_TESTING",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_TRANSPORT_CURL",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SAMPLES",
"value": "True",
"type": "BOOL"
}
]
},
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,41 @@ The following SDK library releases are available on [vcpkg](https://github.com/m

> NOTE: In case of getting linker errors when consuming the SDK on Windows, make sure that [vcpkg triplet](https://vcpkg.readthedocs.io/en/latest/users/triplets/) being consumed matches the [CRT link flags](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-160) being set for your app or library build. See also `MSVC_USE_STATIC_CRT` build flag.
## OpenSSL Version

Several packages within the Azure SDK for C++ use the OpenSSL library. By default, the Azure SDK will use whatever the most recent version of OpenSSL is within the VCPKG repository.

If you need to use a specific version of OpenSSL, you can use the vcpkg custom ports feature to specify the version of OpenSSL to use.
For example, if you want to use OpenSSL 1.1.1, you should create a folder named `vcpkg-custom-ports` next to to your vcpkg.json file.

Navigate to your clone of the vcpkg vcpkg repo and execute "git checkout 3b3bd424827a1f7f4813216f6b32b6c61e386b2e" - this will reset your repo to the last version of OpenSSL 1.1.1
in vcpkg. Then, copy the contents of the `ports/openssl` folder from the vcpkg repo to the `vcpkg-custom-ports` folder you created earlier:

```sh
cd <your vcpkg repo>
git checkout 3b3bd424827a1f7f4813216f6b32b6c61e386b2e
cd ports
cp -r openssl <the location of the vcpkg-custom-ports directory listed above>
```

This will copy the port information for OpenSSL 1.1.1n to your vcpkg-custom-ports directory.

Once that is done, you can install the custom port of OpenSSL 1.1.1n using the vcpkg tool:

```sh
vcpkg install --overlay-ports=<path to the vcpkg-custom-ports above>
```

If you are building using CMAKE, you can instruct CMAKE to apply the overlay ports using the following command line switches:

```sh
vcpkg -DVCPKG_MANIFEST_MODE=ON -DVCPKG_OVERLAY_PORTS=<path to the vcpkg-custom-ports above> -DVCPKG_MANIFEST_DIR=<path to the directory containing the vcpkg.json file>
```

In addition, if you need to consume OpenSSL from a dynamic linked library/shared object, you can set the VCPKG triplet to reflect that you want to build the library with dynamic
entries.Set the VCPKG_you can set the environment variable to `x64-windows-static` or `x64-windows-dynamic` depending on whether you want to use the static or dynamic version of OpenSSL.
Similarly you can use the x64-linux-dynamic and x64-linux-static triplet to specify consumption of libraries as a shared object or dynamic.

## Need help

- For reference documentation visit the [Azure SDK for C++ documentation](https://azure.github.io/azure-sdk-for-cpp).
Expand Down
3 changes: 2 additions & 1 deletion cmake-modules/AddGoogleTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ macro(add_gtest TESTNAME)
else()
gtest_discover_tests(${TESTNAME}
TEST_PREFIX "${TESTNAME}."
PROPERTIES FOLDER "Tests")
PROPERTIES FOLDER "Tests"
DISCOVERY_TIMEOUT 600)
endif()
else()
add_test(${TESTNAME} ${TESTNAME})
Expand Down
2 changes: 1 addition & 1 deletion cmake-modules/AzureVcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ macro(az_vcpkg_integrate)
if(NOT DEFINED ENV{AZURE_SDK_DISABLE_AUTO_VCPKG})
# GET VCPKG FROM SOURCE
# User can set env var AZURE_SDK_VCPKG_COMMIT to pick the VCPKG commit to fetch
set(VCPKG_COMMIT_STRING f0aa678b7471497f1adedcc99f40e1599ad22f69) # default SDK tested commit
set(VCPKG_COMMIT_STRING 6ca56aeb457f033d344a7106cb3f9f1abf8f4e98) # default SDK tested commit
if(DEFINED ENV{AZURE_SDK_VCPKG_COMMIT})
set(VCPKG_COMMIT_STRING "$ENV{AZURE_SDK_VCPKG_COMMIT}") # default SDK tested commit
endif()
Expand Down
11 changes: 11 additions & 0 deletions cmake-modules/PerfTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
macro(SetPerfDeps PACKAGE VAR_RESULT)
string(TOUPPER ${PACKAGE} SUFFIX)
string(CONCAT VAR_TRIGGER "VCPKG-" ${SUFFIX})
message(STATUS "trigger name ${VAR_TRIGGER}")
if(DEFINED ENV{${VAR_TRIGGER}})
find_package(${PACKAGE} $ENV{${VAR_TRIGGER}} EXACT)
add_compile_definitions(${VAR_RESULT}="$ENV{${VAR_TRIGGER}}")
else()
add_compile_definitions(${VAR_RESULT}="source")
endif()
endmacro()
6 changes: 1 addition & 5 deletions doc/DistributedTracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ in-memory logger.
opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>
CreateOpenTelemetryProvider()
{
#if USE_MEMORY_EXPORTER
auto exporter = std::make_unique<opentelemetry::exporter::memory::InMemorySpanExporter>();
#else
auto exporter = std::make_unique<opentelemetry::exporter::trace::OStreamSpanExporter>();
#endif
auto exporter = std::make_unique<MyExporter>();

// simple processor
auto simple_processor = std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>(
Expand Down
171 changes: 171 additions & 0 deletions doc/PerformanceTesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Performance Testing

## Writing a test

Adding tests , at the moment relies in making modifications in a couple of repositories.

## Azure-SDK-For-Cpp repo

E.G. https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/storage/azure-storage-blobs

### Location

Performance tests are located under **"test/perf"** folder under the service folder(e.g. alongside ut folder).

The perf test folder should be added in the parent CMakeLists.txt guarded by the **BUILD_PERFORMANCE_TESTS** flag.

E.G.

```markdown

if(BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()

```

### Structure

As any other CPP project you will need a **CMakeLists.txt** file , along side **src** and **inc** folders

#### Contents of the **inc** directory

Under inc folder create a subfolder structure following your namespace hierarchy ending with another test folder since these are in the ...Test namespace.

E.G. test/perf/inc/azure/storage/blobs/test

The tests are defined in .hpp files under this folder.

##### Test definition

In a .hpp file we define a class that will be contain the tests methods. The class is defined in the ::Test namespace for your service.

The class will inherit from the **PerfTest** base class and will override several methods as follows:
- Constructor(Azure::Perf::TestOptions options) : PerfTest(options)
Options field are passed from the perf test framework and constain the various options defined for running the test.
- void Run(Azure::Core::Context const&) override {...}.
Runs the actual test code. It is strongly recommended that the test code does as little extra work here as possible, it should consist solely of the actual test invocation. The test code should remove all assert, conditional statements ("if"/"else") or any other unnecessary work as any extra work will skew the results.
- std::vector<Azure::Perf::TestOption> GetTestOptions() override
Defines the various parameters for the test run that can be passed to the test from the performance framework. The perf framework uses these params to run various combinations(e.g. blob size)
- static Azure::Perf::TestMetadata GetTestMetadata()
Returns TestMetadate object used to identify the test.

#### Contents of the **src** directory

Contains one cpp file that contains the main method defintion

```cpp
int main(int argc, char** argv)
{
std::cout << "SERVICE VERSION " << VCPKG_SERVICE_VERSION << std::endl;
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{
Service::Namespace::Test::TestName::GetTestMetadata(),
};

Azure::Perf::Program::Run(Azure::Core::Context::ApplicationContext, tests, argc, argv);

return 0;
}
```
#### CMakeLists.txt
Beyond the regular cmake defintion in your cmake file make sure to add
```makefile
include(AzureVcpkg)
az_vcpkg_integrate()
...
include(PerfTest)
SETPERFDEPS(azure-storage-blobs-cpp VCPKG_SERVICE_VERSION)
```

The crucial part here is the SETPERFDEPS cmake macro.
The perf framework will set an environment variable based on the service name with the value representing a version, thus allowing to run the tests against diffrent VCPKG published versions. If the env is not defined then the test will build against the current source code of the service.
There can be multiple set perf for each dependency of the service ( e.g. identity, storage).

## Pipeline definition
The file should be named `perf.yml`, and should be located in the service directory that is to be tested, for consistency and to keep service related resources in the service folder.

```yml
parameters:
- name: PackageVersions
displayName: PackageVersions (regex of package versions to run)
type: string
default: '12|source'
- name: Tests
displayName: Tests (regex of tests to run)
type: string
default: '^(download|upload|list-blobs)$'
- name: Arguments
displayName: Arguments (regex of arguments to run)
type: string
default: '(10240)|(10485760)|(1073741824)|(5 )|(500 )|(50000 )'
- name: Iterations
displayName: Iterations (times to run each test)
type: number
default: '5'
- name: AdditionalArguments
displayName: AdditionalArguments (passed to PerfAutomation)
type: string
default: ' '

extends:
template: /eng/pipelines/templates/jobs/perf.yml
parameters:
ServiceDirectory: service folder
Services: "^service name$"
PackageVersions: ${{ parameters.PackageVersions }}
Tests: ${{ parameters.Tests }}
Arguments: ${{ parameters.Arguments }}
Iterations: ${{ parameters.Iterations }}
AdditionalArguments: ${{ parameters.AdditionalArguments }}
InstallLanguageSteps:
- pwsh: |
Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SOURCES_SECRET;issecret=true;]clear;x-azblob,https://cppvcpkgcache.blob.core.windows.net/public-vcpkg-container,,read"
displayName: Set Vcpkg Variables
EnvVars:
# This is set in the InstallLanguageSteps
VCPKG_BINARY_SOURCES_SECRET: $(VCPKG_BINARY_SOURCES_SECRET)

```

The fields of interest here are the parameters:
- Tests which define which test s run in this pipeline ( which tests are available)
- Arguments which allow to filter which subset of parameters are acceptable for the tests from the plurality in the framework
- ServiceDirectory which represents the root folder of the service
- Services which represents the services which these tests target.

## Resources

If the tests require certain resources to exist beforehand the pipeline can deploy them based on the presence of the **perf-resources.bicep** file which will be used to deploy the required resources defined within.

## Azure-SDK-Tools repo

## Location

The performance automation is located under azure-sdk-tools\tools\perf-automation\Azure.Sdk.Tools.PerfAutomation folder.
(https://github.com/Azure/azure-sdk-tools/tree/main/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation)

## Test definition

in the above mentioned folder resided the test defintion file "tests.yml".

### The tests exists in other languages

If the test exists in other languages then making the CPP version visible to the framework requires adding an entry with the name **CPP** under **Service**/**Languages** followed by the pakages and versions available for the testing(this ties into the CMakeLists SetPerfDeps macro).

Next under the **Tests**/**Test** node with the desired name add the CPP test name. In this section mind the aArguments list , this ies with the regex in the cpp sdk pipeline.yml definition.

### The test does not exist in other languages

In this case you are the first to add the required nodes. The defintion is fairly simple and straightforward.

## Pipeline

Once you have everything in place create a pipeline using the definition in your in the cpp repo by going to https://dev.azure.com/azure-sdk/internal/_build?definitionScope=%5Cperf and create a new one under the cpp node.

To test intermediate definitions of your pipeline you can run the https://dev.azure.com/azure-sdk/internal/_build?definitionId=5121 pipline and set the proper values for the cpp node( make sure to deselect all other languages except cpp unless you want to run them).

6 changes: 3 additions & 3 deletions eng/common/scripts/Helpers/PSModule-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function Update-PSModulePathForCI()
$modulePaths = $modulePaths.Where({ !$_.StartsWith($hostedAgentModulePath) })

# Add any "az_" paths from the agent which is the lastest set of azure modules
$AzModuleCachPath = (Get-ChildItem "$hostedAgentModulePath/az_*" -Attributes Directory) -join $moduleSeperator
if ($AzModuleCachPath -and $env.PSModulePath -notcontains $AzModuleCachPath) {
$modulePaths += $AzModuleCachPath
$AzModuleCachePath = (Get-ChildItem "$hostedAgentModulePath/az_*" -Attributes Directory) -join $moduleSeperator
if ($AzModuleCachePath -and $env:PSModulePath -notcontains $AzModuleCachePath) {
$modulePaths += $AzModuleCachePath
}

$env:PSModulePath = $modulePaths -join $moduleSeperator
Expand Down
9 changes: 7 additions & 2 deletions eng/common/scripts/Update-DocsMsToc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ depending on the requirements for the domain
.PARAMETER OutputLocation
Output location for unified reference yml file
.PARAMETER ReadmeFolderRoot
The readme folder root path, use default value here for backward compability. E.g. docs-ref-services in Java, JS, Python, api/overview/azure
#>

param(
[Parameter(Mandatory = $true)]
[string] $DocRepoLocation,

[Parameter(Mandatory = $true)]
[string] $OutputLocation
[string] $OutputLocation,

[Parameter(Mandatory = $false)]
[string] $ReadmeFolderRoot = 'docs-ref-services'
)
. $PSScriptRoot/common.ps1
. $PSScriptRoot/Helpers/PSModule-Helpers.ps1
Expand Down Expand Up @@ -208,7 +213,7 @@ foreach ($service in $serviceNameList) {
$serviceReadmeBaseName = $service.ToLower().Replace(' ', '-').Replace('/', '-')
$serviceTocEntry = [PSCustomObject]@{
name = $service;
href = "~/docs-ref-services/{moniker}/$serviceReadmeBaseName.md"
href = "~/$ReadmeFolderRoot/{moniker}/$serviceReadmeBaseName.md"
landingPageType = 'Service'
items = @($packageItems)
}
Expand Down
Loading

0 comments on commit fbad07b

Please sign in to comment.