Rename and structure unit test and perf tests (#1706)

* Rename and structure unit test and perf tests
This commit is contained in:
Victor Vazquez 2021-02-23 05:55:12 +00:00 committed by GitHub
parent f9eea4d22d
commit b7de24483a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
95 changed files with 750 additions and 735 deletions

View File

@ -30,22 +30,8 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(BUILD_TESTING)
# define a symbol that enables some test hooks in code
add_compile_definitions(TESTING_BUILD)
if(RUN_LONG_UNIT_TESTS)
add_compile_definitions(RUN_LONG_UNIT_TESTS)
endif()
# tests
include(AddGoogleTest)
enable_testing ()
add_subdirectory(sdk/core/azure-core/test/ut)
# Set `AZURE_CORE_ENABLE_JSON_TESTS` env var to run Json tests
if(DEFINED ENV{AZURE_CORE_ENABLE_JSON_TESTS})
add_subdirectory(sdk/core/azure-core/test/nlohmann-json-test)
endif()
add_subdirectory(sdk/identity/azure-identity/test)
include(AddGoogleTest)
enable_testing ()
endif()
# compiler warning flags globally

View File

@ -46,7 +46,7 @@ message(STATUS "Operating system: ${OS_VERSION_STRINGS}")
# determine the compiler (for debug and support purposes)
if (MSVC)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE CXX_VERSION_RESULT ERROR_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_COMPILER "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
set(CXX_VERSION_RESULT "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")
else()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

View File

@ -10,5 +10,5 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_subdirectory(azure-core)
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(performance-stress)
add_subdirectory(perf)
endif()

View File

@ -142,6 +142,21 @@ az_vcpkg_export(
"azure/core/dll_import_export.hpp"
)
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/performance)
if(BUILD_TESTING)
# define a symbol that enables some test hooks in code
add_compile_definitions(TESTING_BUILD)
if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()
add_subdirectory(test/ut)
if(DEFINED ENV{AZURE_CORE_ENABLE_JSON_TESTS})
add_subdirectory(test/nlohmann-json-test)
endif()
endif()
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()

View File

@ -10,6 +10,8 @@ set_tests_properties(download_test_data PROPERTIES FIXTURES_SETUP TEST_DATA)
#############################################################################
add_library(doctest_main OBJECT src/unit.cpp)
# Remove global compile options from this target.
set_target_properties(doctest_main PROPERTIES COMPILE_OPTIONS "")
set_target_properties(doctest_main PROPERTIES
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
@ -93,6 +95,8 @@ foreach(file ${files})
string(REGEX REPLACE "unit-([^$]+)" "json-test-\\1" testcase ${file_basename})
add_executable(${testcase} $<TARGET_OBJECTS:doctest_main> ${file})
# Remove global compile options from this target.
set_target_properties(${testcase} PROPERTIES COMPILE_OPTIONS "")
target_compile_definitions(${testcase} PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
target_compile_options(${testcase} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>

View File

@ -3,13 +3,13 @@
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-core-performance LANGUAGES CXX)
project(azure-core-perf LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_CORE_PERF_TEST_HEADER
inc/azure/core/test/performance/nullable.hpp
inc/azure/core/test/nullable.hpp
)
set(
@ -19,18 +19,18 @@ set(
# Name the binary to be created.
add_executable (
azure-core-performance
azure-core-perf
${AZURE_CORE_PERF_TEST_HEADER} ${AZURE_CORE_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-core-performance
azure-core-perf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests.
target_link_libraries(azure-core-performance PRIVATE azure-core azure-performance-stress)
# link the `azure-perf` lib together with any other library which will be used for the tests.
target_link_libraries(azure-core-perf PRIVATE azure-core azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-core-performance PROPERTIES FOLDER "Tests/Core")
set_target_properties(azure-core-perf PROPERTIES FOLDER "Tests/Core")

View File

@ -9,29 +9,28 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <memory>
namespace Azure { namespace Core { namespace Test { namespace Performance {
namespace Azure { namespace Core { namespace Test {
/**
* @brief Measure the Nullable object performance.
*
*/
class NullableTest : public Azure::PerformanceStress::PerformanceTest {
class NullableTest : public Azure::Perf::PerfTest {
public:
/**
* @brief Construct a new Nullable test.
*
* @param options The test options.
*/
NullableTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
NullableTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Use NUllable to assing and read.
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override
{
@ -58,17 +57,17 @@ namespace Azure { namespace Core { namespace Test { namespace Performance {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"NullableTest",
"Measures the overhead of using nullable objects",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::Core::Test::Performance::NullableTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Core::Test::NullableTest>(options);
}};
}
};
}}}} // namespace Azure::Core::Test::Performance
}}} // namespace Azure::Core::Test

View File

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/perf.hpp>
#include "azure/core/test/nullable.hpp"
#include <vector>
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{Azure::Core::Test::NullableTest::GetTestMetadata()};
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -1,20 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/performance_framework.hpp>
#include "azure/core/test/performance/nullable.hpp"
#include <vector>
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::PerformanceStress::TestMetadata> tests{
Azure::Core::Test::Performance::NullableTest::GetTestMetadata()};
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -70,7 +70,8 @@ if (MSVC)
# - 'testing::internal::Mutex::StaticConstructorSelector'
# - 'testing::TestPartResult::Type'
# is unscoped. Prefer 'enum class' over 'enum' (Enum.3)
target_compile_options(azure-core-test PUBLIC /wd26495 /wd26812)
# - C6323: Google comparisons
target_compile_options(azure-core-test PUBLIC /wd26495 /wd26812 /wd6326 /wd28204 /wd28020 /wd6330 /wd4389)
endif()
# Adding private headers from CORE to the tests so we can test the private APIs with no relative paths include.

View File

@ -14,7 +14,7 @@ TEST(Base64, Basic)
int maxLength = 7;
std::vector<uint8_t> data;
for (int i = 0; i < maxLength; i++)
for (uint8_t i = 0; i < maxLength; i++)
{
data.push_back(i + 1);
}

View File

@ -25,7 +25,7 @@ using namespace Azure::Core;
// Used to test virtual, default behavior of BodyStream.
class TestBodyStream : public Http::BodyStream {
int64_t OnRead(Context const& context, uint8_t* buffer, int64_t count) override { return 0; }
int64_t OnRead(Context const&, uint8_t*, int64_t) override { return 0; }
int64_t Length() const override { return 0; }
};

View File

@ -9,6 +9,15 @@
*
*/
#ifdef _MSC_VER
#pragma warning(push)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) // !_MSC_VER
#pragma GCC diagnostic push
#elif defined(__clang__) // !_MSC_VER !__clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif // _MSC_VER
#include <azure/core/http/curl/curl.hpp>
#include <curl/curl.h>
#include <gmock/gmock.h>
@ -50,3 +59,11 @@ namespace Azure { namespace Core { namespace Test {
};
}}} // namespace Azure::Core::Test
#ifdef _MSC_VER
#pragma warning(pop)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) // !_MSC_VER
#pragma GCC diagnostic pop
#elif defined(__clang__) // !_MSC_VER !__clang__
#pragma clang diagnostic pop // NOLINT(clang-diagnostic-unknown-pragmas)
#endif // _MSC_VER

View File

@ -117,9 +117,9 @@ namespace Azure { namespace Core { namespace Test {
request, std::move(uniqueCurlMock), true);
EXPECT_NO_THROW(session->Perform(Azure::Core::GetApplicationContext()));
auto response = session->GetResponse();
response->SetBodyStream(std::move(session));
auto bodyS = response->GetBodyStream();
auto r = session->GetResponse();
r->SetBodyStream(std::move(session));
auto bodyS = r->GetBodyStream();
// Read the bodyStream to get all chunks
EXPECT_THROW(

View File

@ -27,7 +27,7 @@ namespace Azure { namespace Core { namespace Test {
int m_count = 0;
private:
std::unique_ptr<Http::RawResponse> PollInternal(Context& context) override
std::unique_ptr<Http::RawResponse> PollInternal(Context&) override
{
// Artificial delay to require 2 polls
if (++m_count == 2)
@ -58,7 +58,7 @@ namespace Azure { namespace Core { namespace Test {
}
public:
StringOperation(StringClient* client) : m_client(client) {}
StringOperation(StringClient* client) : m_client(client) { (void)m_client; }
std::string GetResumeToken() const override { return m_operationToken; }

View File

@ -8,6 +8,15 @@
*
*/
#ifdef _MSC_VER
#pragma warning(push)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) // !_MSC_VER
#pragma GCC diagnostic push
#elif defined(__clang__) // !_MSC_VER !__clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#endif // _MSC_VER
#include <azure/core.hpp>
#include <gtest/gtest.h>
@ -40,3 +49,11 @@ TEST(SimplifiedHeader, core)
}
EXPECT_NO_THROW(Azure::Core::Http::TelemetryPolicy tp("", ""));
}
#ifdef _MSC_VER
#pragma warning(pop)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) // !_MSC_VER
#pragma GCC diagnostic pop
#elif defined(__clang__) // !_MSC_VER !__clang__
#pragma clang diagnostic pop // NOLINT(clang-diagnostic-unknown-pragmas)
#endif // _MSC_VER

View File

@ -429,7 +429,7 @@ namespace Azure { namespace Core { namespace Test {
// if ref can't be cast, it throws
EXPECT_NO_THROW((void)dynamic_cast<Azure::Core::Http::TransportException&>(err));
EXPECT_NO_THROW((void)dynamic_cast<std::runtime_error&>(err));
EXPECT_THROW(dynamic_cast<std::range_error&>(err), std::bad_cast);
EXPECT_THROW((void)dynamic_cast<std::range_error&>(err), std::bad_cast);
}
}
@ -599,7 +599,7 @@ namespace Azure { namespace Core { namespace Test {
if (size > 0)
{ // only for known body size
EXPECT_EQ(bodyVector.size(), size);
EXPECT_EQ(bodyVector.size(), static_cast<size_t>(size));
}
if (expectedBody.size() > 0)

View File

@ -115,7 +115,6 @@ namespace Azure { namespace Core { namespace Test {
TEST(URL, query_parameter_encode_decode)
{
Http::HttpMethod httpMethod = Http::HttpMethod::Put;
Http::Url url("http://test.com");
EXPECT_NO_THROW(url.AppendQueryParameter("query", Http::Url::Encode("va=lue")));

View File

@ -33,7 +33,7 @@ TEST(Uuid, separatorPosition)
auto uuidKey = Uuid::CreateUuid().ToString();
// validate expected format '8-4-4-4-12'
EXPECT_PRED5(
[](std::string const& uuidKey, char pos1, char pos2, char pos3, char pos4) {
[](std::string const&, char pos1, char pos2, char pos3, char pos4) {
return pos1 == pos2 && pos1 == pos3 && pos1 == pos4 && pos1 == '-';
},
uuidKey,
@ -50,7 +50,7 @@ TEST(Uuid, validChars)
EXPECT_PRED2(
[](std::string const& uuidKey, int expectedSeparators) {
int separatorsCount = 0;
for (int index = 0; index < uuidKey.size(); index++)
for (size_t index = 0; index < uuidKey.size(); index++)
{
if (uuidKey[index] == '-')
{

View File

@ -0,0 +1,49 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.13)
project(azure-perf LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_PERFORMANCE_HEADER
inc/azure/perf/argagg.hpp
inc/azure/perf/base_test.hpp
inc/azure/perf/dynamic_test_options.hpp
inc/azure/perf/options.hpp
inc/azure/perf/program.hpp
inc/azure/perf/test_metadata.hpp
inc/azure/perf/test.hpp
inc/azure/perf/test_options.hpp
)
set(
AZURE_PERFORMANCE_SOURCE
src/arg_parser.cpp
src/options.cpp
src/program.cpp
)
add_library(azure-perf ${AZURE_PERFORMANCE_HEADER} ${AZURE_PERFORMANCE_SOURCE})
target_include_directories(
azure-perf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<INSTALL_INTERFACE:include/az_core>
)
if (MSVC)
#argagg warnings
target_compile_options(azure-perf PUBLIC /wd28020 /wd28204)
endif()
# make sure that users can consume the project as a library.
add_library (Azure::Perf ALIAS azure-perf)
target_link_libraries(azure-perf PRIVATE azure-core)
set_target_properties(azure-perf PROPERTIES FOLDER "Core")
add_subdirectory(test)

View File

@ -1,4 +1,4 @@
performance-stress
Azure Perf
NOTICES AND INFORMATION
Do Not Translate or Localize

View File

@ -1,6 +1,6 @@
# Azure SDK performance stress C++
# Azure SDK Perf for C++
Azure performance stress for C++ (`azure-performance-stress`) provides shared primitives, abstractions, and helpers for running performance tests for an Azure SDK clients for C++. It represent the C++ version of the [.NET original version](https://github.com/Azure/azure-sdk-for-net/tree/master/common/Perf).
Azure perf for C++ (`azure-perf`) provides shared primitives, abstractions, and helpers for running performance tests for an Azure SDK clients for C++. It represent the C++ version of the [.NET original version](https://github.com/Azure/azure-sdk-for-net/tree/master/common/Perf).
## Getting started
@ -24,14 +24,14 @@ cmake --build .
### Run
Once building is completed, a performance test application will be created inside the the test folder from each service SDK. For instance, the Azure core performance test application would be inside: `build/sdk/core/azure-core/test/performance`. See next example for running the performance framework.
Once building is completed, a performance test application will be created inside the the test folder from each service SDK. For instance, the Azure core performance test application would be inside: `build/sdk/core/azure-core/test/perf`. See next example for running the performance framework.
```bash
#
# Running the performance framework tests application
#
# From within the build folder (build)
./sdk/core/performance-stress/test/azure-performance-stress-test
./sdk/core/perf/test/azure-perf-test
```
>Note: When building the code with windows using Visual Studio, use the [cmake project view](https://docs.microsoft.com/cpp/build/cmake-projects-in-visual-studio?view=msvc-160) to run the performance tests. Find the tests directly in the tests folder from the cmake tree next to all other test cmake projects.
@ -40,7 +40,7 @@ Once building is completed, a performance test application will be created insid
After running the performance test application like it is mentioned above (without any command line arguments) the application will list the available test names to be run. The application will expect the test name to be executed as a mandatory argument. If the input test name is not found, the application will return an error and will terminate. The next pattern represents the right usage of the performance test application:
```bash
usage: azure-performance-stress-test testName [options]
usage: azure-perf-test testName [options]
```
>Note: You can use the option `-h` to print out the available options for a test name.
@ -60,7 +60,7 @@ The next options can be used for any test:
| Rate | -r, --rate | Target throughput (ops/sec) | NA | -r 3000
| Warm up | -w, --warmup | Duration of warmup in seconds | 5 | -w 0 (no warm up)
## Creating a performance test
## Creating a perf test
Find below how to create a new CMake performance test project from scratch to an existing CMake project. Then how to add the performance tests to it.
@ -92,8 +92,8 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests. Below example is using azure-core only.
target_link_libraries(azure-performance-library-name-test PRIVATE azure-core azure-performance-stress)
# link the `azure-perf` lib together with any other library which will be used for the tests. Below example is using azure-core only.
target_link_libraries(azure-performance-library-name-test PRIVATE azure-core azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-performance-library-name-test PROPERTIES FOLDER "Tests")
@ -112,12 +112,12 @@ The main source file defines the list of available tests and calls the performan
// SPDX-License-Identifier: MIT
// The performance framework headers
#include <azure/performance-stress/options.hpp>
#include <azure/performance-stress/program.hpp>
#include <azure/perf/options.hpp>
#include <azure/perf/program.hpp>
// The test definition headers
#include "azure/performance-stress/test/extended_options.hpp"
#include "azure/performance-stress/test/no_op_test.hpp"
#include "azure/perf/test/extended_options.hpp"
#include "azure/perf/test/no_op_test.hpp"
// The utilities
#include <functional>
@ -129,7 +129,7 @@ int main(int argc, char** argv)
/**
* The test list is a dictionary with the name of the test as a key and
* an std::function to define how to instantiate a new Test for the PerformanceTest
* an std::function to define how to instantiate a new Test for the PerfTest
* interface.
*
* In the next example, a map called `tests` is init with two test definitions.
@ -137,22 +137,22 @@ int main(int argc, char** argv)
**/
std::map<
std::string,
std::function<std::unique_ptr<Azure::PerformanceStress::PerformanceTest>(
Azure::PerformanceStress::TestOptions)>>
std::function<std::unique_ptr<Azure::Perf::PerfTest>(
Azure::Perf::TestOptions)>>
tests{
{"noOp", // Test Name
[](Azure::PerformanceStress::TestOptions options) {
[](Azure::Perf::TestOptions options) {
// No Op test
return std::make_unique<Azure::PerformanceStress::Test::NoOp>(options);
return std::make_unique<Azure::Perf::Test::NoOp>(options);
}},
{"extendedOptions", // Test Name
[](Azure::PerformanceStress::TestOptions options) {
[](Azure::Perf::TestOptions options) {
// Extended options test
return std::make_unique<Azure::PerformanceStress::Test::ExtendedOptionsTest>(options);
return std::make_unique<Azure::Perf::Test::ExtendedOptionsTest>(options);
}}};
// Call the `Run` method with a context, the tests and the application arguments to launch the program.
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}
@ -180,19 +180,19 @@ The next code example illustrates how to define a very simple empty test.
#pragma once
// The performance framework headers
#include <azure/performance-stress/options.hpp>
#include <azure/performance-stress/test.hpp>
#include <azure/perf/options.hpp>
#include <azure/perf/test.hpp>
// Use a namespace according to the service package
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
// Define a derived class from a PerformanceTest
class NoOp : public Azure::PerformanceStress::PerformanceTest {
// Define a derived class from a PerfTest
class NoOp : public Azure::Perf::PerfTest {
public:
// Define a constructor to take TestOptions and use the options for the
// PerformanceTest constructor.
NoOp(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
// PerfTest constructor.
NoOp(Azure::Perf::TestOptions options) : PerfTest(options) {}
// Override the `Run` method with the test definition
void Run(Azure::Core::Context const& ctx) override {
@ -200,7 +200,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test
```
@ -221,25 +221,25 @@ A test can define its own options as an addition to the base options from the pe
#pragma once
// The performance framework headers
#include <azure/performance-stress/options.hpp>
#include <azure/performance-stress/test.hpp>
#include <azure/performance-stress/test_options.hpp>
#include <azure/perf/options.hpp>
#include <azure/perf/test.hpp>
#include <azure/perf/test_options.hpp>
// Utilities
#include <vector>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
// The test class definition and constructor looks just the same as any
// other test (with or without extended options).
class ExtendedOptionsTest : public Azure::PerformanceStress::PerformanceTest {
class ExtendedOptionsTest : public Azure::Perf::PerfTest {
public:
ExtendedOptionsTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
ExtendedOptionsTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
// Override the `GetTestOptions` function to define the unique test options.
// Do not duplicate activators or test names or the application will fail during parsing.
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
// Each test option is define by 4 properties:
// - Name (string)
@ -260,7 +260,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test
```
@ -294,17 +294,4 @@ Security issues and bugs should be reported privately, via email, to the Microso
### License
Azure SDK for C++ is licensed under the [MIT](https://github.com/Azure/azure-sdk-for-cpp/blob/master/sdk/core/performance-stress/LICENSE) license.
<!-- LINKS -->
[azure_sdk_for_c_contributing]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md
[azure_sdk_for_c_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md#developer-guide
[azure_sdk_for_c_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-cpp/blob/master/CONTRIBUTING.md#pull-requests
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker
[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry
[azure_portal]: https://portal.azure.com
[azure_sub]: https://azure.microsoft.com/free/
[c_compiler]: https://visualstudio.microsoft.com/vs/features/cplusplus/
[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview
[cloud_shell_bash]: https://shell.azure.com/bash
Azure SDK for C++ is licensed under the [MIT](https://github.com/Azure/azure-sdk-for-cpp/blob/master/LICENSE.txt) license.

View File

@ -0,0 +1,14 @@
{
"Registrations": [
{
"Component": {
"Type": "git",
"git": {
"RepositoryUrl": "https://github.com/vietjtnguyen/argagg",
"CommitHash": "b259b76c51751e5b4dbd070968e60dce108bbc88"
}
},
"DevelopmentDependency": true
}
]
}

View File

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Convenience top level header to include all the performance framework functionality.
*
*/
#pragma once
#include "azure/perf/argagg.hpp"
#include "azure/perf/base_test.hpp"
#include "azure/perf/dynamic_test_options.hpp"
#include "azure/perf/options.hpp"
#include "azure/perf/program.hpp"
#include "azure/perf/test.hpp"
#include "azure/perf/test_metadata.hpp"
#include "azure/perf/test_options.hpp"

View File

@ -169,7 +169,6 @@ namespace convert {
* provides that extension point. The default, generic implementation of
* argagg::convert::arg<T>() calls converter<T>::convert().
*
* @see
* @ref argagg::csv
*/
template <typename T> struct converter

View File

@ -11,12 +11,12 @@
#include <azure/core/context.hpp>
#include "azure/performance-stress/test_options.hpp"
#include "azure/perf/test_options.hpp"
#include <string>
#include <vector>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief The base interface for a performance test.
@ -51,9 +51,9 @@ namespace Azure { namespace PerformanceStress {
*
* @return The array of test options supported by a performance test.
*/
virtual std::vector<Azure::PerformanceStress::TestOption> GetTestOptions()
virtual std::vector<Azure::Perf::TestOption> GetTestOptions()
{
return std::vector<Azure::PerformanceStress::TestOption>();
return std::vector<Azure::Perf::TestOption>();
};
/**
@ -78,4 +78,4 @@ namespace Azure { namespace PerformanceStress {
*/
virtual void GlobalCleanup(){};
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -9,9 +9,9 @@
#pragma once
#include "azure/performance-stress/argagg.hpp"
#include "azure/perf/argagg.hpp"
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define a wrapper container for the test options.
*
@ -73,4 +73,4 @@ namespace Azure { namespace PerformanceStress {
return m_results[optionName].as<T>();
}
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -12,16 +12,16 @@
#include <string>
#include "azure/core/nullable.hpp"
#include "azure/performance-stress/argagg.hpp"
#include "azure/performance-stress/dynamic_test_options.hpp"
#include "azure/performance-stress/test_options.hpp"
#include "azure/perf/argagg.hpp"
#include "azure/perf/dynamic_test_options.hpp"
#include "azure/perf/test_options.hpp"
#include <azure/core/internal/json.hpp>
#include <iostream>
#include <vector>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define the performance framework options.
*
@ -99,20 +99,20 @@ namespace Azure { namespace PerformanceStress {
/**
* @brief Create an array of the performance framework options.
*
* @return An array of the options as #Azure::PerformanceStress::TestOption.
* @return An array of the options as #Azure::Perf::TestOption.
*/
static std::vector<Azure::PerformanceStress::TestOption> GetOptionMetadata();
static std::vector<Azure::Perf::TestOption> GetOptionMetadata();
};
/**
* @brief Define a #Azure::Core::Internal::Json::json to
* Azure::PerformanceStress::GlobalTestOptions convertion.
* Azure::Perf::GlobalTestOptions convertion.
*
* @remark The Json library consumes this implementation for parsing
* #Azure::PerformanceStress::GlobalTestOptions to Json.
* #Azure::Perf::GlobalTestOptions to Json.
*
* @param j A Json reference to be written.
* @param p A #Azure::PerformanceStress::GlobalTestOptions reference to be parsed.
* @param p A #Azure::Perf::GlobalTestOptions reference to be parsed.
*/
void to_json(Azure::Core::Internal::Json::json& j, const GlobalTestOptions& p);
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -9,12 +9,12 @@
#pragma once
#include "azure/performance-stress/argagg.hpp"
#include "azure/performance-stress/test_metadata.hpp"
#include "azure/perf/argagg.hpp"
#include "azure/perf/test_metadata.hpp"
#include <vector>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define a performance application.
*
@ -26,10 +26,9 @@ namespace Azure { namespace PerformanceStress {
static argagg::parser_results Parse(
int argc,
char** argv,
std::vector<Azure::PerformanceStress::TestOption> const& testOptions);
std::vector<Azure::Perf::TestOption> const& testOptions);
static Azure::PerformanceStress::GlobalTestOptions Parse(
argagg::parser_results const& parsedArgs);
static Azure::Perf::GlobalTestOptions Parse(argagg::parser_results const& parsedArgs);
};
public:
@ -43,8 +42,8 @@ namespace Azure { namespace PerformanceStress {
*/
static void Run(
Azure::Core::Context const& context,
std::vector<Azure::PerformanceStress::TestMetadata> const& tests,
std::vector<Azure::Perf::TestMetadata> const& tests,
int argc,
char** argv);
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -9,21 +9,21 @@
#pragma once
#include "azure/performance-stress/base_test.hpp"
#include "azure/performance-stress/dynamic_test_options.hpp"
#include "azure/performance-stress/options.hpp"
#include "azure/perf/base_test.hpp"
#include "azure/perf/dynamic_test_options.hpp"
#include "azure/perf/options.hpp"
#include <memory>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define a performance test with options.
*
*/
class PerformanceTest : public Azure::PerformanceStress::BaseTest {
class PerfTest : public Azure::Perf::BaseTest {
protected:
Azure::PerformanceStress::TestOptions m_options;
Azure::Perf::TestOptions m_options;
public:
/**
@ -31,12 +31,12 @@ namespace Azure { namespace PerformanceStress {
*
* @param options The command-line parsed options.
*/
PerformanceTest(Azure::PerformanceStress::TestOptions options) : m_options(options) {}
PerfTest(Azure::Perf::TestOptions options) : m_options(options) {}
/**
* @brief Destroy the Performance Test object.
*
*/
virtual ~PerformanceTest() {}
virtual ~PerfTest() {}
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -9,14 +9,14 @@
#pragma once
#include "azure/performance-stress/test.hpp"
#include "azure/performance-stress/test_options.hpp"
#include "azure/perf/test.hpp"
#include "azure/perf/test_options.hpp"
#include <functional>
#include <memory>
#include <string>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define the metadata of a test that can be run by the performance framework.
*
@ -38,8 +38,6 @@ namespace Azure { namespace PerformanceStress {
* @brief The callback function which produces the performance test.
*
*/
std::function<std::unique_ptr<Azure::PerformanceStress::PerformanceTest>(
Azure::PerformanceStress::TestOptions)>
Factory;
std::function<std::unique_ptr<Azure::Perf::PerfTest>(Azure::Perf::TestOptions)> Factory;
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -14,7 +14,7 @@
#include <string>
#include <vector>
namespace Azure { namespace PerformanceStress {
namespace Azure { namespace Perf {
/**
* @brief Define the properties of a test option that can be parsed from command line.
*
@ -55,4 +55,4 @@ namespace Azure { namespace PerformanceStress {
*/
bool sensitiveData = false;
};
}} // namespace Azure::PerformanceStress
}} // namespace Azure::Perf

View File

@ -1,22 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/performance-stress/argagg.hpp"
#include "azure/performance-stress/program.hpp"
#include "azure/perf/argagg.hpp"
#include "azure/perf/program.hpp"
#include <stdexcept>
#include <vector>
#define GET_ARG(Name, Is)
argagg::parser_results Azure::PerformanceStress::Program::ArgParser::Parse(
argagg::parser_results Azure::Perf::Program::ArgParser::Parse(
int argc,
char** argv,
std::vector<Azure::PerformanceStress::TestOption> const& testOptions)
std::vector<Azure::Perf::TestOption> const& testOptions)
{
// Option Name, Activate options, display message and number of expected args.
argagg::parser argParser;
auto optionsMetadata = Azure::PerformanceStress::GlobalTestOptions::GetOptionMetadata();
auto optionsMetadata = Azure::Perf::GlobalTestOptions::GetOptionMetadata();
for (auto option : testOptions)
{
argParser.definitions.push_back(
@ -45,10 +45,10 @@ argagg::parser_results Azure::PerformanceStress::Program::ArgParser::Parse(
return argsResults;
}
Azure::PerformanceStress::GlobalTestOptions Azure::PerformanceStress::Program::ArgParser::Parse(
Azure::Perf::GlobalTestOptions Azure::Perf::Program::ArgParser::Parse(
argagg::parser_results const& parsedArgs)
{
Azure::PerformanceStress::GlobalTestOptions options;
Azure::Perf::GlobalTestOptions options;
if (parsedArgs["Duration"])
{
options.Duration = parsedArgs["Duration"];

View File

@ -1,13 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/performance-stress/options.hpp"
#include "azure/perf/options.hpp"
#include <iostream>
void Azure::PerformanceStress::to_json(
Azure::Core::Internal::Json::json& j,
const GlobalTestOptions& p)
void Azure::Perf::to_json(Azure::Core::Internal::Json::json& j, const GlobalTestOptions& p)
{
j = Azure::Core::Internal::Json::json{
{"Duration", p.Duration},
@ -37,8 +35,7 @@ void Azure::PerformanceStress::to_json(
}
}
std::vector<Azure::PerformanceStress::TestOption>
Azure::PerformanceStress::GlobalTestOptions::GetOptionMetadata()
std::vector<Azure::Perf::TestOption> Azure::Perf::GlobalTestOptions::GetOptionMetadata()
{
/*
[Option('d', "duration", Default = 10, HelpText = "Duration of test in seconds")]

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/performance-stress/program.hpp"
#include "azure/performance-stress/argagg.hpp"
#include "azure/perf/program.hpp"
#include "azure/perf/argagg.hpp"
#include <azure/core/internal/json.hpp>
#include <azure/core/internal/strings.hpp>
@ -13,8 +13,8 @@
namespace {
inline std::unique_ptr<Azure::PerformanceStress::PerformanceTest> PrintAvailableTests(
std::vector<Azure::PerformanceStress::TestMetadata> const& tests)
inline std::unique_ptr<Azure::Perf::PerfTest> PrintAvailableTests(
std::vector<Azure::Perf::TestMetadata> const& tests)
{
std::cout << "No test name found in the input. Available tests to run:" << std::endl;
std::cout << std::endl << "Name\t\tDescription" << std::endl << "---\t\t---" << std::endl;
@ -25,8 +25,8 @@ inline std::unique_ptr<Azure::PerformanceStress::PerformanceTest> PrintAvailable
return nullptr;
}
inline Azure::PerformanceStress::TestMetadata const* GetTestMetadata(
std::vector<Azure::PerformanceStress::TestMetadata> const& tests,
inline Azure::Perf::TestMetadata const* GetTestMetadata(
std::vector<Azure::Perf::TestMetadata> const& tests,
int argc,
char** argv)
{
@ -64,8 +64,8 @@ inline std::string ReplaceAll(
}
inline void PrintOptions(
Azure::PerformanceStress::GlobalTestOptions const& options,
std::vector<Azure::PerformanceStress::TestOption> const& testOptions,
Azure::Perf::GlobalTestOptions const& options,
std::vector<Azure::Perf::TestOption> const& testOptions,
argagg::parser_results const& parsedArgs)
{
{
@ -109,7 +109,7 @@ inline void PrintOptions(
inline void RunLoop(
Azure::Core::Context const& context,
Azure::PerformanceStress::PerformanceTest& test,
Azure::Perf::PerfTest& test,
uint64_t& completedOperations,
std::chrono::nanoseconds& lastCompletionTimes,
bool latency,
@ -183,8 +183,8 @@ inline std::vector<double> ZipAvg(
inline void RunTests(
Azure::Core::Context const& context,
std::vector<std::unique_ptr<Azure::PerformanceStress::PerformanceTest>> const& tests,
Azure::PerformanceStress::GlobalTestOptions const& options,
std::vector<std::unique_ptr<Azure::Perf::PerfTest>> const& tests,
Azure::Perf::GlobalTestOptions const& options,
std::string const& title,
bool warmup = false)
{
@ -270,9 +270,9 @@ inline void RunTests(
} // namespace
void Azure::PerformanceStress::Program::Run(
void Azure::Perf::Program::Run(
Azure::Core::Context const& context,
std::vector<Azure::PerformanceStress::TestMetadata> const& tests,
std::vector<Azure::Perf::TestMetadata> const& tests,
int argc,
char** argv)
{
@ -287,12 +287,12 @@ void Azure::PerformanceStress::Program::Run(
}
// Initial test to get it's options, we can use a dummy parser results
argagg::parser_results argResults;
auto test = testGenerator(Azure::PerformanceStress::TestOptions(argResults));
auto test = testGenerator(Azure::Perf::TestOptions(argResults));
auto testOptions = test->GetTestOptions();
argResults = Azure::PerformanceStress::Program::ArgParser::Parse(argc, argv, testOptions);
argResults = Azure::Perf::Program::ArgParser::Parse(argc, argv, testOptions);
// ReCreate Test with parsed results
test = testGenerator(Azure::PerformanceStress::TestOptions(argResults));
auto options = Azure::PerformanceStress::Program::ArgParser::Parse(argResults);
test = testGenerator(Azure::Perf::TestOptions(argResults));
auto options = Azure::Perf::Program::ArgParser::Parse(argResults);
if (options.JobStatistics)
{
@ -308,11 +308,10 @@ void Azure::PerformanceStress::Program::Run(
// Create parallel pool of tests
int const parallelTasks = options.Parallel;
std::vector<std::unique_ptr<Azure::PerformanceStress::PerformanceTest>> parallelTest(
parallelTasks);
std::vector<std::unique_ptr<Azure::Perf::PerfTest>> parallelTest(parallelTasks);
for (int i = 0; i < parallelTasks; i++)
{
parallelTest[i] = testGenerator(Azure::PerformanceStress::TestOptions(argResults));
parallelTest[i] = testGenerator(Azure::Perf::TestOptions(argResults));
}
/******************** Global Set up ******************************/

View File

@ -0,0 +1,42 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-perf-test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_PERF_TEST_HEADER
inc/azure/perf/test/curl_http_client_get_test.hpp
inc/azure/perf/test/delay_test.hpp
inc/azure/perf/test/exception_test.hpp
inc/azure/perf/test/extended_options_test.hpp
inc/azure/perf/test/http_client_get_test.hpp
inc/azure/perf/test/no_op_test.hpp
inc/azure/perf/test/win_http_client_get_test.hpp
)
set(
AZURE_PERF_TEST_SOURCE
src/main.cpp
)
# Name the binary to be created.
add_executable (
azure-perf-test
${AZURE_PERF_TEST_HEADER} ${AZURE_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-perf-test
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-perf-test PRIVATE azure-core azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-perf-test PROPERTIES FOLDER "Tests/Core")

View File

@ -9,18 +9,18 @@
#pragma once
#include "azure/performance-stress/test/http_client_get_test.hpp"
#include "azure/perf/test/http_client_get_test.hpp"
#include <azure/core/http/curl/curl.hpp>
#include <curl/curl.h>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
/**
* @brief A performance test that defines a test option.
*
*/
class CurlHttpClientGetTest : public Azure::PerformanceStress::Test::HttpClientGetTest {
class CurlHttpClientGetTest : public Azure::Perf::Test::HttpClientGetTest {
private:
Azure::Core::Http::Url m_url;
@ -30,10 +30,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @param options The command-line parsed options.
*/
CurlHttpClientGetTest(Azure::PerformanceStress::TestOptions options)
: HttpClientGetTest(options)
{
}
CurlHttpClientGetTest(Azure::Perf::TestOptions options) : HttpClientGetTest(options) {}
/**
* @brief Set up the http client
@ -50,17 +47,17 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"curlHttpClientGet",
"Send an Http Get request to a configurable url using libcurl.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::CurlHttpClientGetTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::CurlHttpClientGetTest>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -9,7 +9,7 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <atomic>
#include <chrono>
@ -17,7 +17,7 @@
#include <thread>
#include <vector>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
namespace Details {
static std::atomic_uint64_t DelayTestInstanceCount(0);
@ -27,7 +27,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
* @brief A performance test that defines a test option.
*
*/
class DelayTest : public Azure::PerformanceStress::PerformanceTest {
class DelayTest : public Azure::Perf::PerfTest {
private:
std::chrono::milliseconds m_delay;
@ -52,7 +52,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @param options The command-line parsed options.
*/
DelayTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options)
DelayTest(Azure::Perf::TestOptions options) : PerfTest(options)
{
// Increment the counter and fetch the value, then remove 1 to get the previous-increment
// value
@ -66,7 +66,6 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief The test definition
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override { std::this_thread::sleep_for(m_delay); }
@ -75,7 +74,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return {
{"InitialDelayMs",
@ -97,17 +96,17 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"delay",
"The no op test with a configurable time delay for the main test loop.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::DelayTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::DelayTest>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -10,25 +10,25 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <memory>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
/**
* @brief Measures the overhead of creating, throwing, and catching an exception (compared to
* NoOpTest).
*
*/
class ExceptionTest : public Azure::PerformanceStress::PerformanceTest {
class ExceptionTest : public Azure::Perf::PerfTest {
public:
/**
* @brief Construct a new Exception test.
*
* @param options The test options.
*/
ExceptionTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
ExceptionTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Test throwing and catching.
@ -49,17 +49,17 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"exception",
"Measure how the impact of catching a runtime exception.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::ExceptionTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::ExceptionTest>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -9,30 +9,29 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <memory>
#include <vector>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
/**
* @brief A performance test that defines a test option.
*
*/
class ExtendedOptionsTest : public Azure::PerformanceStress::PerformanceTest {
class ExtendedOptionsTest : public Azure::Perf::PerfTest {
public:
/**
* @brief Construct a new Extended Options Test object.
*
* @param options The command-line parsed options.
*/
ExtendedOptionsTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
ExtendedOptionsTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief The test definition
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override
{
@ -46,7 +45,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return {{"extraOption", {"-e"}, "Example for extended option for test.", 1}};
}
@ -54,18 +53,18 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"extendedOptions",
"Demostrate how to include a test option to a test and measures how expensive is to do "
"it.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::ExtendedOptionsTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::ExtendedOptionsTest>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -9,7 +9,7 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <azure/core/http/body_stream.hpp>
#include <azure/core/http/http.hpp>
@ -18,7 +18,7 @@
#include <memory>
#include <vector>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
namespace Details {
static std::unique_ptr<Azure::Core::Http::HttpTransport> HttpClient;
@ -28,7 +28,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
* @brief A performance test that defines a test option.
*
*/
class HttpClientGetTest : public Azure::PerformanceStress::PerformanceTest {
class HttpClientGetTest : public Azure::Perf::PerfTest {
protected:
Azure::Core::Http::Url m_url;
@ -38,7 +38,7 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @param options The command-line parsed options.
*/
HttpClientGetTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
HttpClientGetTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Get and set the url option
@ -68,10 +68,10 @@ namespace Azure { namespace PerformanceStress { namespace Test {
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return {{"url", {"--url"}, "Url to send the http request. *Required parameter.", 1, true}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -9,46 +9,45 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <memory>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
/**
* @brief The no op test is an empty test used to measure the performance framework alone.
*
*/
class NoOp : public Azure::PerformanceStress::PerformanceTest {
class NoOp : public Azure::Perf::PerfTest {
public:
/**
* @brief Construct a new No Op test.
*
* @param options The test options.
*/
NoOp(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
NoOp(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Define an empty test.
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override {}
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"NoOp",
"Simplest test to measure the performance framework speed.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::NoOp>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::NoOp>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -9,26 +9,24 @@
#pragma once
#include "azure/performance-stress/test/http_client_get_test.hpp"
#include "azure/perf/test/http_client_get_test.hpp"
#include <azure/core/http/winhttp/win_http_client.hpp>
namespace Azure { namespace PerformanceStress { namespace Test {
namespace Azure { namespace Perf { namespace Test {
/**
* @brief A performance test that defines a test option.
*
*/
class WinHttpClientGetTest : public Azure::PerformanceStress::Test::HttpClientGetTest {
class WinHttpClientGetTest : public Azure::Perf::Test::HttpClientGetTest {
public:
/**
* @brief Construct a new Extended Options Test object.
*
* @param options The command-line parsed options.
*/
WinHttpClientGetTest(Azure::PerformanceStress::TestOptions options) : HttpClientGetTest(options)
{
}
WinHttpClientGetTest(Azure::Perf::TestOptions options) : HttpClientGetTest(options) {}
/**
* @brief Set up the http client
@ -42,17 +40,17 @@ namespace Azure { namespace PerformanceStress { namespace Test {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"winHttpClientGet",
"Send an Http Get request to a configurable url using winHttp.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::PerformanceStress::Test::WinHttpClientGetTest>(options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Perf::Test::WinHttpClientGetTest>(options);
}};
}
};
}}} // namespace Azure::PerformanceStress::Test
}}} // namespace Azure::Perf::Test

View File

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/perf.hpp>
#include "azure/perf/test/delay_test.hpp"
#include "azure/perf/test/extended_options_test.hpp"
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
#include "azure/perf/test/curl_http_client_get_test.hpp"
#endif
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
#include "azure/perf/test/win_http_client_get_test.hpp"
#endif
#include "azure/perf/test/exception_test.hpp"
#include "azure/perf/test/no_op_test.hpp"
#include <vector>
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{
Azure::Perf::Test::NoOp::GetTestMetadata(),
Azure::Perf::Test::ExtendedOptionsTest::GetTestMetadata(),
Azure::Perf::Test::DelayTest::GetTestMetadata(),
Azure::Perf::Test::ExceptionTest::GetTestMetadata()};
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
tests.emplace_back(Azure::Perf::Test::CurlHttpClientGetTest::GetTestMetadata());
#endif
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
tests.emplace_back(Azure::Perf::Test::WinHttpClientGetTest::GetTestMetadata());
#endif
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -1,5 +0,0 @@
# Release History
## 1.0.0-preview.1 (Unreleased)
* Testing. Validating automation.

View File

@ -1,49 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.13)
project(azure-performance-stress LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_PERFORMANCE_HEADER
inc/azure/performance-stress/argagg.hpp
inc/azure/performance-stress/base_test.hpp
inc/azure/performance-stress/dynamic_test_options.hpp
inc/azure/performance-stress/options.hpp
inc/azure/performance-stress/program.hpp
inc/azure/performance-stress/test_metadata.hpp
inc/azure/performance-stress/test.hpp
inc/azure/performance-stress/test_options.hpp
)
set(
AZURE_PERFORMANCE_SOURCE
src/arg_parser.cpp
src/options.cpp
src/program.cpp
)
add_library(azure-performance-stress ${AZURE_PERFORMANCE_HEADER} ${AZURE_PERFORMANCE_SOURCE})
target_include_directories(
azure-performance-stress
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<INSTALL_INTERFACE:include/az_core>
)
if (MSVC)
#argagg warnings
target_compile_options(azure-performance-stress PUBLIC /wd28020 /wd28204)
endif()
# make sure that users can consume the project as a library.
add_library (Azure::PerfStress ALIAS azure-performance-stress)
target_link_libraries(azure-performance-stress PRIVATE azure-core)
set_target_properties(azure-performance-stress PROPERTIES FOLDER "Core")
add_subdirectory(test)

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,4 +0,0 @@
{
"Registrations": [
]
}

View File

@ -1,19 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Convenience top level header to include all the performance framework functionality.
*
*/
#pragma once
#include "azure/performance-stress/argagg.hpp"
#include "azure/performance-stress/base_test.hpp"
#include "azure/performance-stress/dynamic_test_options.hpp"
#include "azure/performance-stress/options.hpp"
#include "azure/performance-stress/program.hpp"
#include "azure/performance-stress/test.hpp"
#include "azure/performance-stress/test_metadata.hpp"
#include "azure/performance-stress/test_options.hpp"

View File

@ -1,42 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-performance-stress-test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_PERF_TEST_HEADER
inc/azure/performance-stress/test/curl_http_client_get_test.hpp
inc/azure/performance-stress/test/delay_test.hpp
inc/azure/performance-stress/test/exception_test.hpp
inc/azure/performance-stress/test/extended_options_test.hpp
inc/azure/performance-stress/test/http_client_get_test.hpp
inc/azure/performance-stress/test/no_op_test.hpp
inc/azure/performance-stress/test/win_http_client_get_test.hpp
)
set(
AZURE_PERF_TEST_SOURCE
src/main.cpp
)
# Name the binary to be created.
add_executable (
azure-performance-stress-test
${AZURE_PERF_TEST_HEADER} ${AZURE_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-performance-stress-test
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests.
target_link_libraries(azure-performance-stress-test PRIVATE azure-core azure-performance-stress)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-performance-stress-test PROPERTIES FOLDER "Tests/Core")

View File

@ -1,40 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/performance_framework.hpp>
#include "azure/performance-stress/test/delay_test.hpp"
#include "azure/performance-stress/test/extended_options_test.hpp"
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
#include "azure/performance-stress/test/curl_http_client_get_test.hpp"
#endif
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
#include "azure/performance-stress/test/win_http_client_get_test.hpp"
#endif
#include "azure/performance-stress/test/exception_test.hpp"
#include "azure/performance-stress/test/no_op_test.hpp"
#include <vector>
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::PerformanceStress::TestMetadata> tests{
Azure::PerformanceStress::Test::NoOp::GetTestMetadata(),
Azure::PerformanceStress::Test::ExtendedOptionsTest::GetTestMetadata(),
Azure::PerformanceStress::Test::DelayTest::GetTestMetadata(),
Azure::PerformanceStress::Test::ExceptionTest::GetTestMetadata()};
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
tests.emplace_back(Azure::PerformanceStress::Test::CurlHttpClientGetTest::GetTestMetadata());
#endif
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
tests.emplace_back(Azure::PerformanceStress::Test::WinHttpClientGetTest::GetTestMetadata());
#endif
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -26,6 +26,11 @@ if(NOT AZ_ALL_LIBRARIES)
endif()
endif()
if(BUILD_TESTING)
# define a symbol that enables some test hooks in code
add_compile_definitions(TESTING_BUILD)
endif()
set(
AZURE_IDENTITY_HEADER
inc/azure/identity/client_secret_credential.hpp
@ -69,3 +74,17 @@ az_vcpkg_export(
IDENTITY
"azure/identity/dll_import_export.hpp"
)
if(BUILD_TESTING)
# tests
if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()
add_subdirectory(test/ut)
endif()
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()

View File

@ -3,13 +3,13 @@
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-identity-performance LANGUAGES CXX)
project(azure-identity-perf LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_IDENTITY_PERF_TEST_HEADER
inc/azure/identity/test/performance/secret_credential.hpp
inc/azure/identity/test/secret_credential.hpp
)
set(
@ -19,18 +19,18 @@ set(
# Name the binary to be created.
add_executable (
azure-identity-performance
azure-identity-perf
${AZURE_IDENTITY_PERF_TEST_HEADER} ${AZURE_IDENTITY_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-identity-performance
azure-identity-perf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests.
target_link_libraries(azure-identity-performance PRIVATE azure-identity azure-performance-stress)
# link the `azure-perf` lib together with any other library which will be used for the tests.
target_link_libraries(azure-identity-perf PRIVATE azure-identity azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-identity-performance PROPERTIES FOLDER "Tests/Identity")
set_target_properties(azure-identity-perf PROPERTIES FOLDER "Tests/Identity")

View File

@ -9,7 +9,7 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <azure/identity.hpp>
@ -17,13 +17,13 @@
#include <string>
#include <vector>
namespace Azure { namespace Identity { namespace Test { namespace Performance {
namespace Azure { namespace Identity { namespace Test {
/**
* @brief A test to measure the authentication token performance.
*
*/
class SecretCredentialTest : public Azure::PerformanceStress::PerformanceTest {
class SecretCredentialTest : public Azure::Perf::PerfTest {
private:
std::string m_tenantId;
std::string m_clientId;
@ -51,14 +51,12 @@ namespace Azure { namespace Identity { namespace Test { namespace Performance {
*
* @param options The test options.
*/
SecretCredentialTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options)
{
}
SecretCredentialTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Define the test
*
* @param ctx The cancellation token.
* @param context The cancellation token.
*/
void Run(Azure::Core::Context const& context) override
{
@ -70,7 +68,7 @@ namespace Azure { namespace Identity { namespace Test { namespace Performance {
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return {
{"TenantId", {"--tenantId"}, "The tenant Id for the authentication.", 1, true},
@ -82,18 +80,17 @@ namespace Azure { namespace Identity { namespace Test { namespace Performance {
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {
"SecretCredential",
"Get a token using a secret client token credential.",
[](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::Identity::Test::Performance::SecretCredentialTest>(
options);
[](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Identity::Test::SecretCredentialTest>(options);
}};
}
};
}}}} // namespace Azure::Identity::Test::Performance
}}} // namespace Azure::Identity::Test

View File

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/perf.hpp>
#include "azure/identity/test/secret_credential.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{
Azure::Identity::Test::SecretCredentialTest::GetTestMetadata()};
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -1,18 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/performance_framework.hpp>
#include "azure/identity/test/performance/secret_credential.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::PerformanceStress::TestMetadata> tests{
Azure::Identity::Test::Performance::SecretCredentialTest::GetTestMetadata()};
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -29,7 +29,7 @@ if (MSVC)
# - 'testing::internal::Mutex::StaticConstructorSelector'
# - 'testing::TestPartResult::Type'
# is unscoped. Prefer 'enum class' over 'enum' (Enum.3)
target_compile_options(azure-identity-test PUBLIC /wd26495 /wd26812)
target_compile_options(azure-identity-test PUBLIC /wd26495 /wd26812 /wd6326)
endif()
# Adding private headers from identity to the tests so we can test the private APIs with no relative paths include.
@ -43,7 +43,3 @@ gtest_discover_tests(azure-identity-test
TEST_PREFIX azure-identity.
NO_PRETTY_TYPES
NO_PRETTY_VALUES)
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(performance)
endif()

View File

@ -69,7 +69,12 @@ generate_documentation(azure-security-keyvault-common ${AZ_LIBRARY_VERSION})
if(BUILD_TESTING)
# tests
add_subdirectory(test)
if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()
add_subdirectory(test/ut)
endif()
az_vcpkg_export(

View File

@ -74,7 +74,17 @@ get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/keyvault/keys/version.hpp"
generate_documentation(azure-security-keyvault-keys ${AZ_LIBRARY_VERSION})
if(BUILD_TESTING)
add_subdirectory(test)
if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()
add_subdirectory(test/ut)
endif()
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()
if(BUILD_SAMPLES)

View File

@ -3,13 +3,13 @@
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-security-keyvault-keys-performance LANGUAGES CXX)
project(azure-security-keyvault-keys-perf LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_KEYVAULT_KEY_PERF_TEST_HEADER
inc/azure/keyvault/keys/test/performance/get_key.hpp
inc/azure/keyvault/keys/test/get_key.hpp
)
set(
@ -19,18 +19,18 @@ set(
# Name the binary to be created.
add_executable (
azure-security-keyvault-keys-performance
azure-security-keyvault-keys-perf
${AZURE_KEYVAULT_KEY_PERF_TEST_HEADER} ${AZURE_KEYVAULT_KEY_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-security-keyvault-keys-performance
azure-security-keyvault-keys-perf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests.
target_link_libraries(azure-security-keyvault-keys-performance PRIVATE azure-identity azure-security-keyvault-keys azure-performance-stress)
# link the `azure-perf` lib together with any other library which will be used for the tests.
target_link_libraries(azure-security-keyvault-keys-perf PRIVATE azure-identity azure-security-keyvault-keys azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-security-keyvault-keys-performance PROPERTIES FOLDER "Tests/Keyvault")
set_target_properties(azure-security-keyvault-keys-perf PROPERTIES FOLDER "Tests/Keyvault")

View File

@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Test the overhead of getting a key.
*
*/
#pragma once
#include <azure/perf.hpp>
#include <azure/identity.hpp>
#include <azure/keyvault/key_vault.hpp>
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test {
/**
* @brief A test to measure getting a key performance.
*
*/
class GetKey : public Azure::Perf::PerfTest {
private:
std::string m_vaultUrl;
std::string m_keyName;
std::string m_tenantId;
std::string m_clientId;
std::string m_secret;
std::shared_ptr<Azure::Identity::ClientSecretCredential> m_credentail;
std::unique_ptr<Azure::Security::KeyVault::Keys::KeyClient> m_client;
public:
/**
* @brief Get the Ids and secret
*
*/
void Setup() override
{
m_vaultUrl = m_options.GetMandatoryOption<std::string>("vaultUrl");
m_keyName = m_options.GetMandatoryOption<std::string>("keyName");
m_tenantId = m_options.GetMandatoryOption<std::string>("TenantId");
m_clientId = m_options.GetMandatoryOption<std::string>("ClientId");
m_secret = m_options.GetMandatoryOption<std::string>("Secret");
m_credentail = std::make_shared<Azure::Identity::ClientSecretCredential>(
m_tenantId, m_clientId, m_secret);
m_client
= std::make_unique<Azure::Security::KeyVault::Keys::KeyClient>(m_vaultUrl, m_credentail);
}
/**
* @brief Construct a new GetKey test.
*
* @param options The test options.
*/
GetKey(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Define the test
*
*/
void Run(Azure::Core::Context const&) override { auto t = m_client->GetKey(m_keyName); }
/**
* @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, true},
{"keyName", {"--keyName"}, "The Key name to get.", 1, true},
{"TenantId", {"--tenantId"}, "The tenant Id for the authentication.", 1, true},
{"ClientId", {"--clientId"}, "The client Id for the authentication.", 1, true},
{"Secret", {"--secret"}, "The secret for authentication.", 1, true, true}};
}
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {"GetKey", "Get a key", [](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Security::KeyVault::Keys::Test::GetKey>(options);
}};
}
};
}}}}} // namespace Azure::Security::KeyVault::Keys::Test

View File

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/perf.hpp>
#include "azure/keyvault/keys/test/get_key.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{
Azure::Security::KeyVault::Keys::Test::GetKey::GetTestMetadata()};
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -1,100 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Test the overhead of getting a key.
*
*/
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/identity.hpp>
#include <azure/keyvault/key_vault.hpp>
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace Test {
namespace Performance {
/**
* @brief A test to measure getting a key performance.
*
*/
class GetKey : public Azure::PerformanceStress::PerformanceTest {
private:
std::string m_vaultUrl;
std::string m_keyName;
std::string m_tenantId;
std::string m_clientId;
std::string m_secret;
std::shared_ptr<Azure::Identity::ClientSecretCredential> m_credentail;
std::unique_ptr<Azure::Security::KeyVault::Keys::KeyClient> m_client;
public:
/**
* @brief Get the Ids and secret
*
*/
void Setup() override
{
m_vaultUrl = m_options.GetMandatoryOption<std::string>("vaultUrl");
m_keyName = m_options.GetMandatoryOption<std::string>("keyName");
m_tenantId = m_options.GetMandatoryOption<std::string>("TenantId");
m_clientId = m_options.GetMandatoryOption<std::string>("ClientId");
m_secret = m_options.GetMandatoryOption<std::string>("Secret");
m_credentail = std::make_shared<Azure::Identity::ClientSecretCredential>(
m_tenantId, m_clientId, m_secret);
m_client = std::make_unique<Azure::Security::KeyVault::Keys::KeyClient>(
m_vaultUrl, m_credentail);
}
/**
* @brief Construct a new GetKey test.
*
* @param options The test options.
*/
GetKey(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
/**
* @brief Define the test
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override { auto t = m_client->GetKey(m_keyName); }
/**
* @brief Define the test options for the test.
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
{
return {
{"vaultUrl", {"--vaultUrl"}, "The Key Vault Account.", 1, true},
{"keyName", {"--keyName"}, "The Key name to get.", 1, true},
{"TenantId", {"--tenantId"}, "The tenant Id for the authentication.", 1, true},
{"ClientId", {"--clientId"}, "The client Id for the authentication.", 1, true},
{"Secret", {"--secret"}, "The secret for authentication.", 1, true, true}};
}
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
{
return {
"GetKey", "Get a key", [](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::Security::KeyVault::Keys::Test::Performance::GetKey>(
options);
}};
}
};
}}}}}} // namespace Azure::Security::KeyVault::Keys::Test::Performance

View File

@ -1,18 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/performance_framework.hpp>
#include "azure/keyvault/keys/test/performance/get_key.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::PerformanceStress::TestMetadata> tests{
Azure::Security::KeyVault::Keys::Test::Performance::GetKey::GetTestMetadata()};
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -51,7 +51,3 @@ gtest_discover_tests(azure-security-keyvault-keys-test-live
NO_PRETTY_TYPES
NO_PRETTY_VALUES
)
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(performance)
endif()

View File

@ -7,6 +7,12 @@ project (azure-storage LANGUAGES CXX)
option(BUILD_STORAGE_SAMPLES "Build storage sample codes" ON)
if(BUILD_TESTING)
if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()
add_executable(azure-storage-test)
add_gtest(azure-storage-test)
endif()

View File

@ -88,17 +88,17 @@ if(BUILD_TESTING)
target_sources(
azure-storage-test
PRIVATE
test/append_blob_client_test.cpp
test/append_blob_client_test.hpp
test/blob_container_client_test.cpp
test/blob_container_client_test.hpp
test/blob_sas_test.cpp
test/blob_service_client_test.cpp
test/block_blob_client_test.cpp
test/block_blob_client_test.hpp
test/page_blob_client_test.cpp
test/page_blob_client_test.hpp
test/storage_retry_policy_test.cpp
test/ut/append_blob_client_test.cpp
test/ut/append_blob_client_test.hpp
test/ut/blob_container_client_test.cpp
test/ut/blob_container_client_test.hpp
test/ut/blob_sas_test.cpp
test/ut/blob_service_client_test.cpp
test/ut/block_blob_client_test.cpp
test/ut/block_blob_client_test.hpp
test/ut/page_blob_client_test.cpp
test/ut/page_blob_client_test.hpp
test/ut/storage_retry_policy_test.cpp
)
target_link_libraries(azure-storage-test PRIVATE azure-storage-blobs)
@ -115,5 +115,5 @@ if(BUILD_STORAGE_SAMPLES)
endif()
if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/performance)
add_subdirectory(test/perf)
endif()

View File

@ -3,13 +3,14 @@
# Configure CMake project.
cmake_minimum_required (VERSION 3.13)
project(azure-storage-blobs-performance LANGUAGES CXX)
project(azure-storage-blobs-perf LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(
AZURE_STORAGE_BLOBS_PERF_TEST_HEADER
inc/azure/storage/blobs/test/performance/download_blob.hpp
inc/azure/storage/blobs/test/blob_base_test.hpp
inc/azure/storage/blobs/test/download_blob.hpp
)
set(
@ -19,18 +20,18 @@ set(
# Name the binary to be created.
add_executable (
azure-storage-blobs-performance
azure-storage-blobs-perf
${AZURE_STORAGE_BLOBS_PERF_TEST_HEADER} ${AZURE_STORAGE_BLOBS_PERF_TEST_SOURCE}
)
# Include the headers from the project.
target_include_directories(
azure-storage-blobs-performance
azure-storage-blobs-perf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)
# link the `azure-performance-stress` lib together with any other library which will be used for the tests.
target_link_libraries(azure-storage-blobs-performance PRIVATE azure-storage-blobs azure-performance-stress)
# link the `azure-perf` lib together with any other library which will be used for the tests.
target_link_libraries(azure-storage-blobs-perf PRIVATE azure-storage-blobs azure-perf)
# Make sure the project will appear in the test folder for Visual Studio CMake view
set_target_properties(azure-storage-blobs-performance PROPERTIES FOLDER "Tests/Storage")
set_target_properties(azure-storage-blobs-perf PROPERTIES FOLDER "Tests/Storage")

View File

@ -9,7 +9,7 @@
#pragma once
#include <azure/performance_framework.hpp>
#include <azure/perf.hpp>
#include <azure/storage/blobs.hpp>
@ -17,13 +17,13 @@
#include <string>
#include <vector>
namespace Azure { namespace Storage { namespace Blobs { namespace Test { namespace Performance {
namespace Azure { namespace Storage { namespace Blobs { namespace Test {
/**
* @brief A base test that set up a blobs performance test.
*
*/
class BlobsTest : public Azure::PerformanceStress::PerformanceTest {
class BlobsTest : public Azure::Perf::PerfTest {
protected:
std::string m_containerName;
std::string m_blobName;
@ -54,14 +54,14 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { namespa
*
* @param options The test options.
*/
BlobsTest(Azure::PerformanceStress::TestOptions options) : PerformanceTest(options) {}
BlobsTest(Azure::Perf::TestOptions options) : PerfTest(options) {}
/**
* @brief Define the test options for the test.
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return {
{"connectionString",
@ -75,4 +75,4 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { namespa
}
};
}}}}} // namespace Azure::Storage::Blobs::Test::Performance
}}}} // namespace Azure::Storage::Blobs::Test

View File

@ -0,0 +1,65 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Test the performance of downloading a block blob.
*
*/
#pragma once
#include <azure/perf.hpp>
#include "azure/storage/blobs/test/blob_base_test.hpp"
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Storage { namespace Blobs { namespace Test {
/**
* @brief A test to measure downloading a blob.
*
*/
class DownloadBlob : public Azure::Storage::Blobs::Test::BlobsTest {
public:
/**
* @brief Construct a new DownloadBlob test.
*
* @param options The test options.
*/
DownloadBlob(Azure::Perf::TestOptions options) : BlobsTest(options) {}
/**
* @brief Define the test
*
*/
void Run(Azure::Core::Context const&) override { auto blob = m_blobClient->Download(); }
/**
* @brief Define the test options for the test.
*
* @return The list of test options.
*/
std::vector<Azure::Perf::TestOption> GetTestOptions() override
{
return Azure::Storage::Blobs::Test::BlobsTest::GetTestOptions();
}
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::Perf::TestMetadata describing the test.
*/
static Azure::Perf::TestMetadata GetTestMetadata()
{
return {"DownloadBlob", "Download a blob.", [](Azure::Perf::TestOptions options) {
return std::make_unique<Azure::Storage::Blobs::Test::DownloadBlob>(options);
}};
}
};
}}}} // namespace Azure::Storage::Blobs::Test

View File

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/perf.hpp>
#include "azure/storage/blobs/test/download_blob.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::Perf::TestMetadata> tests{
Azure::Storage::Blobs::Test::DownloadBlob::GetTestMetadata()};
Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}

View File

@ -1,68 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Test the performance of downloading a block blob.
*
*/
#pragma once
#include <azure/performance_framework.hpp>
#include "azure/storage/blobs/test/performance/blob_base_test.hpp"
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Storage { namespace Blobs { namespace Test { namespace Performance {
/**
* @brief A test to measure downloading a blob.
*
*/
class DownloadBlob : public Azure::Storage::Blobs::Test::Performance::BlobsTest {
public:
/**
* @brief Construct a new DownloadBlob test.
*
* @param options The test options.
*/
DownloadBlob(Azure::PerformanceStress::TestOptions options) : BlobsTest(options) {}
/**
* @brief Define the test
*
* @param ctx The cancellation token.
*/
void Run(Azure::Core::Context const&) override { auto blob = m_blobClient->Download(); }
/**
* @brief Define the test options for the test.
*
* @return The list of test options.
*/
std::vector<Azure::PerformanceStress::TestOption> GetTestOptions() override
{
return Azure::Storage::Blobs::Test::Performance::BlobsTest::GetTestOptions();
}
/**
* @brief Get the static Test Metadata for the test.
*
* @return Azure::PerformanceStress::TestMetadata describing the test.
*/
static Azure::PerformanceStress::TestMetadata GetTestMetadata()
{
return {
"DownloadBlob", "Download a blob.", [](Azure::PerformanceStress::TestOptions options) {
return std::make_unique<Azure::Storage::Blobs::Test::Performance::DownloadBlob>(
options);
}};
}
};
}}}}} // namespace Azure::Storage::Blobs::Test::Performance

View File

@ -1,18 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/performance_framework.hpp>
#include "azure/storage/blobs/test/performance/download_blob.hpp"
int main(int argc, char** argv)
{
// Create the test list
std::vector<Azure::PerformanceStress::TestMetadata> tests{
Azure::Storage::Blobs::Test::Performance::DownloadBlob::GetTestMetadata()};
Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv);
return 0;
}