forked from Azure/azure-sdk-for-cpp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* secrets * perftestst for get Secret * dss * qfe * pipelines * comments * cleanup script * comment * key last * somemore stuff * clang
- Loading branch information
Showing
11 changed files
with
453 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
sdk/keyvault/azure-security-keyvault-certificates/perf.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
parameters: | ||
- name: PackageVersions | ||
displayName: PackageVersions (regex of package versions to run) | ||
type: string | ||
default: '1|source' | ||
- name: Tests | ||
displayName: Tests (regex of tests to run) | ||
type: string | ||
default: '^(get-certificate)$' | ||
- name: Arguments | ||
displayName: Arguments (regex of arguments to run) | ||
type: string | ||
default: '.*' | ||
- 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: keyvault | ||
Services: "^keyvault-certificates$" | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
parameters: | ||
- name: PackageVersions | ||
displayName: PackageVersions (regex of package versions to run) | ||
type: string | ||
default: '1|source' | ||
- name: Tests | ||
displayName: Tests (regex of tests to run) | ||
type: string | ||
default: '^(get-key)$' | ||
- name: Arguments | ||
displayName: Arguments (regex of arguments to run) | ||
type: string | ||
default: '.*' | ||
- 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: keyvault | ||
Services: "^keyvault-keys$" | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
parameters: | ||
- name: PackageVersions | ||
displayName: PackageVersions (regex of package versions to run) | ||
type: string | ||
default: '1|source' | ||
- name: Tests | ||
displayName: Tests (regex of tests to run) | ||
type: string | ||
default: '^(get-secret|list-secrets)$' | ||
- name: Arguments | ||
displayName: Arguments (regex of arguments to run) | ||
type: string | ||
default: '.*' | ||
- 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: keyvault | ||
Services: "^keyvault-secrets$" | ||
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) |
38 changes: 38 additions & 0 deletions
38
sdk/keyvault/azure-security-keyvault-secrets/test/perf/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Configure CMake project. | ||
cmake_minimum_required (VERSION 3.13) | ||
project(azure-security-keyvault-secrets-perf LANGUAGES CXX) | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
set( | ||
AZURE_KEYVAULT_SECRETS_PERF_TEST_HEADER | ||
inc/azure/keyvault/secrets/test/get_secret_test.hpp | ||
) | ||
|
||
set( | ||
AZURE_KEYVAULT_SECRETS_PERF_TEST_SOURCE | ||
src/azure_security_keyvault_secrets_perf_test.cpp | ||
) | ||
|
||
# Name the binary to be created. | ||
add_executable ( | ||
azure-security-keyvault-secrets-perf | ||
${AZURE_KEYVAULT_SECRETS_PERF_TEST_HEADER} ${AZURE_KEYVAULT_SECRETS_PERF_TEST_SOURCE} | ||
) | ||
create_per_service_target_build(keyvault azure-security-keyvault-secrets-perf) | ||
create_map_file(azure-security-keyvault-secrets-perf azure-security-keyvault-secrets-perf.map) | ||
|
||
# Include the headers from the project. | ||
target_include_directories( | ||
azure-security-keyvault-secrets-perf | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc> | ||
) | ||
|
||
# link the `azure-perf` lib together with any other library which will be used for the tests. | ||
target_link_libraries(azure-security-keyvault-secrets-perf PRIVATE azure-identity azure-security-keyvault-secrets azure-perf) | ||
# Make sure the project will appear in the test folder for Visual Studio CMake view | ||
set_target_properties(azure-security-keyvault-secrets-perf PROPERTIES FOLDER "Tests/Keyvault") |
126 changes: 126 additions & 0 deletions
126
...e-security-keyvault-secrets/test/perf/inc/azure/keyvault/secrets/test/get_secret_test.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
/** | ||
* @file | ||
* @brief Test the overhead of getting a secret. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <azure/perf.hpp> | ||
|
||
#include <azure/core/internal/environment.hpp> | ||
#include <azure/identity.hpp> | ||
#include <azure/keyvault/secrets.hpp> | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
using namespace Azure::Core::_internal; | ||
namespace Azure { namespace Security { namespace KeyVault { namespace Secrets { namespace Test { | ||
|
||
/** | ||
* @brief A test to measure getting a secret performance. | ||
* | ||
*/ | ||
class GetSecret : public Azure::Perf::PerfTest { | ||
private: | ||
std::string m_vaultUrl; | ||
std::string m_secretName; | ||
std::string m_tenantId; | ||
std::string m_clientId; | ||
std::string m_secret; | ||
std::shared_ptr<Azure::Identity::ClientSecretCredential> m_credential; | ||
std::unique_ptr<Azure::Security::KeyVault::Secrets::SecretClient> m_client; | ||
|
||
public: | ||
/** | ||
* @brief Get the Ids and secret | ||
* | ||
*/ | ||
void Setup() override | ||
{ | ||
m_vaultUrl = m_options.GetOptionOrDefault<std::string>( | ||
"vaultUrl", Environment::GetVariable("AZURE_KEYVAULT_URL")); | ||
m_tenantId = m_options.GetOptionOrDefault<std::string>( | ||
"TenantId", Environment::GetVariable("AZURE_TENANT_ID")); | ||
m_clientId = m_options.GetOptionOrDefault<std::string>( | ||
"ClientId", Environment::GetVariable("AZURE_CLIENT_ID")); | ||
m_secret = m_options.GetOptionOrDefault<std::string>( | ||
"Secret", Environment::GetVariable("AZURE_CLIENT_SECRET")); | ||
m_credential = std::make_shared<Azure::Identity::ClientSecretCredential>( | ||
m_tenantId, m_clientId, m_secret); | ||
m_client = std::make_unique<Azure::Security::KeyVault::Secrets::SecretClient>( | ||
m_vaultUrl, | ||
m_credential, | ||
InitClientOptions<Azure::Security::KeyVault::Secrets::SecretClientOptions>()); | ||
this->CreateRandomNameKey(); | ||
} | ||
|
||
/** | ||
* @brief Create a random named secret. | ||
* | ||
*/ | ||
void CreateRandomNameKey() | ||
{ | ||
std::string name("perf"); | ||
int suffixLen = 10; | ||
static const char alphanum[] | ||
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | ||
std::string suffix; | ||
suffix.reserve(suffixLen); | ||
|
||
for (int i = 0; i < suffixLen; ++i) | ||
{ | ||
suffix += alphanum[rand() % (sizeof(alphanum) - 1)]; | ||
} | ||
|
||
m_secretName = name + suffix; | ||
|
||
auto secretResponse = m_client->SetSecret(m_secretName, "secretValue"); | ||
} | ||
|
||
/** | ||
* @brief Construct a new GetSecret test. | ||
* | ||
* @param options The test options. | ||
*/ | ||
GetSecret(Azure::Perf::TestOptions options) : PerfTest(options) {} | ||
|
||
/** | ||
* @brief Define the test | ||
* | ||
*/ | ||
void Run(Azure::Core::Context const&) override { auto t = m_client->GetSecret(m_secretName); } | ||
|
||
/** | ||
* @brief Define the test options for the test. | ||
* | ||
* @return The list of test options. | ||
*/ | ||
std::vector<Azure::Perf::TestOption> GetTestOptions() override | ||
{ | ||
return { | ||
{"vaultUrl", {"--vaultUrl"}, "The Key Vault Account.", 1, false}, | ||
{"TenantId", {"--tenantId"}, "The tenant Id for the authentication.", 1, false}, | ||
{"ClientId", {"--clientId"}, "The client Id for the authentication.", 1, false}, | ||
{"Secret", {"--secret"}, "The secret for authentication.", 1, false, true}}; | ||
} | ||
|
||
/** | ||
* @brief Get the static Test Metadata for the test. | ||
* | ||
* @return Azure::Perf::TestMetadata describing the test. | ||
*/ | ||
static Azure::Perf::TestMetadata GetTestMetadata() | ||
{ | ||
return {"GetSecret", "Get a secret", [](Azure::Perf::TestOptions options) { | ||
return std::make_unique<Azure::Security::KeyVault::Secrets::Test::GetSecret>( | ||
options); | ||
}}; | ||
} | ||
}; | ||
}}}}} // namespace Azure::Security::KeyVault::Secrets::Test |
18 changes: 18 additions & 0 deletions
18
...ure-security-keyvault-secrets/test/perf/src/azure_security_keyvault_secrets_perf_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include <azure/perf.hpp> | ||
|
||
#include "azure/keyvault/secrets/test/get_secret_test.hpp" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
|
||
// Create the test list | ||
std::vector<Azure::Perf::TestMetadata> tests{ | ||
Azure::Security::KeyVault::Secrets::Test::GetSecret::GetTestMetadata()}; | ||
|
||
Azure::Perf::Program::Run(Azure::Core::Context::ApplicationContext, tests, argc, argv); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# SPDX-License-Identifier: MIT | ||
|
||
cmake_minimum_required (VERSION 3.13) | ||
|
||
project (cleanup-keyvault LANGUAGES CXX) | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
add_executable ( | ||
cleanup-keyvault | ||
cleanup.cpp | ||
) | ||
create_per_service_target_build_for_sample(keyvault cleanup-keyvault) | ||
|
||
target_link_libraries(cleanup-keyvault PRIVATE azure-security-keyvault-secrets azure-security-keyvault-keys azure-security-keyvault-certificates azure-identity get-env-helper) |
Oops, something went wrong.