From b7de24483a8cb838484e6a1d2d2dbe895e582f04 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Tue, 23 Feb 2021 05:55:12 +0000 Subject: [PATCH] Rename and structure unit test and perf tests (#1706) * Rename and structure unit test and perf tests --- CMakeLists.txt | 18 +--- cmake-modules/DownloadJsonTestData.cmake | 2 +- sdk/core/CMakeLists.txt | 2 +- sdk/core/azure-core/CMakeLists.txt | 17 ++- .../test/nlohmann-json-test/CMakeLists.txt | 4 + .../test/{performance => perf}/CMakeLists.txt | 14 +-- .../inc/azure/core/test}/nullable.hpp | 19 ++-- sdk/core/azure-core/test/perf/src/main.cpp | 19 ++++ .../azure-core/test/performance/src/main.cpp | 20 ---- sdk/core/azure-core/test/ut/CMakeLists.txt | 3 +- sdk/core/azure-core/test/ut/base64.cpp | 2 +- sdk/core/azure-core/test/ut/bodystream.cpp | 2 +- sdk/core/azure-core/test/ut/curl_session.hpp | 17 +++ .../azure-core/test/ut/curl_session_test.cpp | 6 +- .../azure-core/test/ut/operation_test.hpp | 4 +- .../azure-core/test/ut/simplified_header.cpp | 17 +++ .../test/ut/transport_adapter_base.cpp | 4 +- sdk/core/azure-core/test/ut/url.cpp | 1 - sdk/core/azure-core/test/ut/uuid.cpp | 4 +- sdk/core/perf/CMakeLists.txt | 49 +++++++++ .../{performance-stress => perf}/NOTICE.txt | 2 +- .../{performance-stress => perf}/README.md | 87 +++++++-------- sdk/core/perf/cgmanifest.json | 14 +++ sdk/core/perf/inc/azure/perf.hpp | 19 ++++ .../inc/azure/perf}/argagg.hpp | 1 - .../inc/azure/perf}/base_test.hpp | 10 +- .../inc/azure/perf}/dynamic_test_options.hpp | 6 +- .../inc/azure/perf}/options.hpp | 20 ++-- .../inc/azure/perf}/program.hpp | 15 ++- .../inc/azure/perf}/test.hpp | 18 ++-- .../inc/azure/perf}/test_metadata.hpp | 12 +-- .../inc/azure/perf}/test_options.hpp | 4 +- .../src/arg_parser.cpp | 14 +-- .../src/options.cpp | 9 +- .../src/program.cpp | 39 ++++--- sdk/core/perf/test/CMakeLists.txt | 42 ++++++++ .../perf}/test/curl_http_client_get_test.hpp | 21 ++-- .../test/inc/azure/perf}/test/delay_test.hpp | 21 ++-- .../inc/azure/perf}/test/exception_test.hpp | 18 ++-- .../perf}/test/extended_options_test.hpp | 21 ++-- .../azure/perf}/test/http_client_get_test.hpp | 12 +-- .../test/inc/azure/perf}/test/no_op_test.hpp | 19 ++-- .../perf}/test/win_http_client_get_test.hpp | 20 ++-- sdk/core/perf/test/src/main.cpp | 40 +++++++ sdk/core/performance-stress/CHANGELOG.md | 5 - sdk/core/performance-stress/CMakeLists.txt | 49 --------- sdk/core/performance-stress/LICENSE | 21 ---- sdk/core/performance-stress/cgmanifest.json | 4 - .../inc/azure/performance_framework.hpp | 19 ---- .../performance-stress/test/CMakeLists.txt | 42 -------- sdk/core/performance-stress/test/src/main.cpp | 40 ------- sdk/identity/azure-identity/CMakeLists.txt | 19 ++++ .../test/{performance => perf}/CMakeLists.txt | 14 +-- .../identity/test}/secret_credential.hpp | 25 ++--- .../azure-identity/test/perf/src/main.cpp | 18 ++++ .../test/performance/src/main.cpp | 18 ---- .../test/{ => ut}/CMakeLists.txt | 6 +- .../azure-identity/test/{ => ut}/main.cpp | 0 .../test/{ => ut}/simplified_header.cpp | 0 .../CMakeLists.txt | 7 +- .../test/{ => ut}/CMakeLists.txt | 0 .../test/{ => ut}/main.cpp | 0 .../test/{ => ut}/pipeline_test.cpp | 0 .../CMakeLists.txt | 12 ++- .../test/{performance => perf}/CMakeLists.txt | 14 +-- .../inc/azure/keyvault/keys/test/get_key.hpp | 96 +++++++++++++++++ .../test/perf/src/main.cpp | 18 ++++ .../keys/test/performance/get_key.hpp | 100 ------------------ .../test/performance/src/main.cpp | 18 ---- .../test/{ => ut}/CMakeLists.txt | 4 - .../test/{ => ut}/key_client_base_test.hpp | 0 .../test/{ => ut}/key_client_test.cpp | 0 .../test/{ => ut}/key_client_test_live.cpp | 0 .../test/{ => ut}/main.cpp | 0 .../mocked_transport_adapter_test.hpp | 0 .../test/{ => ut}/telemetry_header_test.cpp | 0 sdk/storage/CMakeLists.txt | 6 ++ .../azure-storage-blobs/CMakeLists.txt | 24 ++--- .../test/{performance => perf}/CMakeLists.txt | 15 +-- .../storage/blobs/test}/blob_base_test.hpp | 12 +-- .../storage/blobs/test/download_blob.hpp | 65 ++++++++++++ .../test/perf/src/main.cpp | 18 ++++ .../blobs/test/performance/download_blob.hpp | 68 ------------ .../test/performance/src/main.cpp | 18 ---- .../test/{ => ut}/append_blob_client_test.cpp | 0 .../test/{ => ut}/append_blob_client_test.hpp | 0 .../{ => ut}/blob_container_client_test.cpp | 0 .../{ => ut}/blob_container_client_test.hpp | 0 .../test/{ => ut}/blob_sas_test.cpp | 0 .../{ => ut}/blob_service_client_test.cpp | 0 .../test/{ => ut}/block_blob_client_test.cpp | 0 .../test/{ => ut}/block_blob_client_test.hpp | 0 .../test/{ => ut}/page_blob_client_test.cpp | 0 .../test/{ => ut}/page_blob_client_test.hpp | 0 .../{ => ut}/storage_retry_policy_test.cpp | 0 95 files changed, 749 insertions(+), 734 deletions(-) rename sdk/core/azure-core/test/{performance => perf}/CMakeLists.txt (60%) rename sdk/core/azure-core/test/{performance/inc/azure/core/test/performance => perf/inc/azure/core/test}/nullable.hpp (59%) create mode 100644 sdk/core/azure-core/test/perf/src/main.cpp delete mode 100644 sdk/core/azure-core/test/performance/src/main.cpp create mode 100644 sdk/core/perf/CMakeLists.txt rename sdk/core/{performance-stress => perf}/NOTICE.txt (99%) rename sdk/core/{performance-stress => perf}/README.md (74%) create mode 100644 sdk/core/perf/cgmanifest.json create mode 100644 sdk/core/perf/inc/azure/perf.hpp rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/argagg.hpp (99%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/base_test.hpp (86%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/dynamic_test_options.hpp (93%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/options.hpp (76%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/program.hpp (66%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/test.hpp (50%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/test_metadata.hpp (66%) rename sdk/core/{performance-stress/inc/azure/performance-stress => perf/inc/azure/perf}/test_options.hpp (92%) rename sdk/core/{performance-stress => perf}/src/arg_parser.cpp (80%) rename sdk/core/{performance-stress => perf}/src/options.cpp (91%) rename sdk/core/{performance-stress => perf}/src/program.cpp (87%) create mode 100644 sdk/core/perf/test/CMakeLists.txt rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/curl_http_client_get_test.hpp (60%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/delay_test.hpp (77%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/exception_test.hpp (61%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/extended_options_test.hpp (61%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/http_client_get_test.hpp (80%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/no_op_test.hpp (53%) rename sdk/core/{performance-stress/test/inc/azure/performance-stress => perf/test/inc/azure/perf}/test/win_http_client_get_test.hpp (56%) create mode 100644 sdk/core/perf/test/src/main.cpp delete mode 100644 sdk/core/performance-stress/CHANGELOG.md delete mode 100644 sdk/core/performance-stress/CMakeLists.txt delete mode 100644 sdk/core/performance-stress/LICENSE delete mode 100644 sdk/core/performance-stress/cgmanifest.json delete mode 100644 sdk/core/performance-stress/inc/azure/performance_framework.hpp delete mode 100644 sdk/core/performance-stress/test/CMakeLists.txt delete mode 100644 sdk/core/performance-stress/test/src/main.cpp rename sdk/identity/azure-identity/test/{performance => perf}/CMakeLists.txt (59%) rename sdk/identity/azure-identity/test/{performance/inc/azure/identity/test/performance => perf/inc/azure/identity/test}/secret_credential.hpp (72%) create mode 100644 sdk/identity/azure-identity/test/perf/src/main.cpp delete mode 100644 sdk/identity/azure-identity/test/performance/src/main.cpp rename sdk/identity/azure-identity/test/{ => ut}/CMakeLists.txt (95%) rename sdk/identity/azure-identity/test/{ => ut}/main.cpp (100%) rename sdk/identity/azure-identity/test/{ => ut}/simplified_header.cpp (100%) rename sdk/keyvault/azure-security-keyvault-common/test/{ => ut}/CMakeLists.txt (100%) rename sdk/keyvault/azure-security-keyvault-common/test/{ => ut}/main.cpp (100%) rename sdk/keyvault/azure-security-keyvault-common/test/{ => ut}/pipeline_test.cpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{performance => perf}/CMakeLists.txt (55%) create mode 100644 sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key.hpp create mode 100644 sdk/keyvault/azure-security-keyvault-keys/test/perf/src/main.cpp delete mode 100644 sdk/keyvault/azure-security-keyvault-keys/test/performance/inc/azure/keyvault/keys/test/performance/get_key.hpp delete mode 100644 sdk/keyvault/azure-security-keyvault-keys/test/performance/src/main.cpp rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/CMakeLists.txt (96%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/key_client_base_test.hpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/key_client_test.cpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/key_client_test_live.cpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/main.cpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/mocked_transport_adapter_test.hpp (100%) rename sdk/keyvault/azure-security-keyvault-keys/test/{ => ut}/telemetry_header_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{performance => perf}/CMakeLists.txt (58%) rename sdk/storage/azure-storage-blobs/test/{performance/inc/azure/storage/blobs/test/performance => perf/inc/azure/storage/blobs/test}/blob_base_test.hpp (84%) create mode 100644 sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob.hpp create mode 100644 sdk/storage/azure-storage-blobs/test/perf/src/main.cpp delete mode 100644 sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/download_blob.hpp delete mode 100644 sdk/storage/azure-storage-blobs/test/performance/src/main.cpp rename sdk/storage/azure-storage-blobs/test/{ => ut}/append_blob_client_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/append_blob_client_test.hpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/blob_container_client_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/blob_container_client_test.hpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/blob_sas_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/blob_service_client_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/block_blob_client_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/block_blob_client_test.hpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/page_blob_client_test.cpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/page_blob_client_test.hpp (100%) rename sdk/storage/azure-storage-blobs/test/{ => ut}/storage_retry_policy_test.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 741654fef6..d284cfa8d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake-modules/DownloadJsonTestData.cmake b/cmake-modules/DownloadJsonTestData.cmake index e1d070a8a7..bf0fd3acb1 100644 --- a/cmake-modules/DownloadJsonTestData.cmake +++ b/cmake-modules/DownloadJsonTestData.cmake @@ -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() diff --git a/sdk/core/CMakeLists.txt b/sdk/core/CMakeLists.txt index 34cd6d43d6..87163e5699 100644 --- a/sdk/core/CMakeLists.txt +++ b/sdk/core/CMakeLists.txt @@ -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() diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index 825b6aa787..fe070834e6 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -142,6 +142,21 @@ az_vcpkg_export( "azure/core/dll_import_export.hpp" ) +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/performance) + add_subdirectory(test/perf) endif() diff --git a/sdk/core/azure-core/test/nlohmann-json-test/CMakeLists.txt b/sdk/core/azure-core/test/nlohmann-json-test/CMakeLists.txt index 88f4c85f05..a5c7d01a23 100644 --- a/sdk/core/azure-core/test/nlohmann-json-test/CMakeLists.txt +++ b/sdk/core/azure-core/test/nlohmann-json-test/CMakeLists.txt @@ -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 "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" @@ -93,6 +95,8 @@ foreach(file ${files}) string(REGEX REPLACE "unit-([^$]+)" "json-test-\\1" testcase ${file_basename}) add_executable(${testcase} $ ${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 $<$:/EHsc;$<$:/Od>> diff --git a/sdk/core/azure-core/test/performance/CMakeLists.txt b/sdk/core/azure-core/test/perf/CMakeLists.txt similarity index 60% rename from sdk/core/azure-core/test/performance/CMakeLists.txt rename to sdk/core/azure-core/test/perf/CMakeLists.txt index f737a2c553..621036e129 100644 --- a/sdk/core/azure-core/test/performance/CMakeLists.txt +++ b/sdk/core/azure-core/test/perf/CMakeLists.txt @@ -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 $ ) -# 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") diff --git a/sdk/core/azure-core/test/performance/inc/azure/core/test/performance/nullable.hpp b/sdk/core/azure-core/test/perf/inc/azure/core/test/nullable.hpp similarity index 59% rename from sdk/core/azure-core/test/performance/inc/azure/core/test/performance/nullable.hpp rename to sdk/core/azure-core/test/perf/inc/azure/core/test/nullable.hpp index e68298cc44..7bc7ed85ee 100644 --- a/sdk/core/azure-core/test/performance/inc/azure/core/test/performance/nullable.hpp +++ b/sdk/core/azure-core/test/perf/inc/azure/core/test/nullable.hpp @@ -9,29 +9,28 @@ #pragma once -#include +#include #include -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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}}} // namespace Azure::Core::Test::Performance +}}} // namespace Azure::Core::Test diff --git a/sdk/core/azure-core/test/perf/src/main.cpp b/sdk/core/azure-core/test/perf/src/main.cpp new file mode 100644 index 0000000000..8a952b6902 --- /dev/null +++ b/sdk/core/azure-core/test/perf/src/main.cpp @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include + +#include "azure/core/test/nullable.hpp" + +#include + +int main(int argc, char** argv) +{ + + // Create the test list + std::vector tests{Azure::Core::Test::NullableTest::GetTestMetadata()}; + + Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); + + return 0; +} diff --git a/sdk/core/azure-core/test/performance/src/main.cpp b/sdk/core/azure-core/test/performance/src/main.cpp deleted file mode 100644 index 6e9433f585..0000000000 --- a/sdk/core/azure-core/test/performance/src/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include - -#include "azure/core/test/performance/nullable.hpp" - -#include - -int main(int argc, char** argv) -{ - - // Create the test list - std::vector tests{ - Azure::Core::Test::Performance::NullableTest::GetTestMetadata()}; - - Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); - - return 0; -} diff --git a/sdk/core/azure-core/test/ut/CMakeLists.txt b/sdk/core/azure-core/test/ut/CMakeLists.txt index 8134d9db63..fa53dbb74c 100644 --- a/sdk/core/azure-core/test/ut/CMakeLists.txt +++ b/sdk/core/azure-core/test/ut/CMakeLists.txt @@ -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. diff --git a/sdk/core/azure-core/test/ut/base64.cpp b/sdk/core/azure-core/test/ut/base64.cpp index ae1ed9f9a6..cb04b6e23a 100644 --- a/sdk/core/azure-core/test/ut/base64.cpp +++ b/sdk/core/azure-core/test/ut/base64.cpp @@ -14,7 +14,7 @@ TEST(Base64, Basic) int maxLength = 7; std::vector data; - for (int i = 0; i < maxLength; i++) + for (uint8_t i = 0; i < maxLength; i++) { data.push_back(i + 1); } diff --git a/sdk/core/azure-core/test/ut/bodystream.cpp b/sdk/core/azure-core/test/ut/bodystream.cpp index 144a781623..2b30111c86 100644 --- a/sdk/core/azure-core/test/ut/bodystream.cpp +++ b/sdk/core/azure-core/test/ut/bodystream.cpp @@ -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; } }; diff --git a/sdk/core/azure-core/test/ut/curl_session.hpp b/sdk/core/azure-core/test/ut/curl_session.hpp index 2e30536f19..b15951e919 100644 --- a/sdk/core/azure-core/test/ut/curl_session.hpp +++ b/sdk/core/azure-core/test/ut/curl_session.hpp @@ -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 #include #include @@ -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 diff --git a/sdk/core/azure-core/test/ut/curl_session_test.cpp b/sdk/core/azure-core/test/ut/curl_session_test.cpp index 5b8138a175..045dc32679 100644 --- a/sdk/core/azure-core/test/ut/curl_session_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_session_test.cpp @@ -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( diff --git a/sdk/core/azure-core/test/ut/operation_test.hpp b/sdk/core/azure-core/test/ut/operation_test.hpp index a562e1cadc..2e092d6fe8 100644 --- a/sdk/core/azure-core/test/ut/operation_test.hpp +++ b/sdk/core/azure-core/test/ut/operation_test.hpp @@ -27,7 +27,7 @@ namespace Azure { namespace Core { namespace Test { int m_count = 0; private: - std::unique_ptr PollInternal(Context& context) override + std::unique_ptr 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; } diff --git a/sdk/core/azure-core/test/ut/simplified_header.cpp b/sdk/core/azure-core/test/ut/simplified_header.cpp index 972ea153c8..8d5a2f8a2c 100644 --- a/sdk/core/azure-core/test/ut/simplified_header.cpp +++ b/sdk/core/azure-core/test/ut/simplified_header.cpp @@ -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 #include @@ -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 diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp index ba2e6871a7..cbed0019b3 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp @@ -429,7 +429,7 @@ namespace Azure { namespace Core { namespace Test { // if ref can't be cast, it throws EXPECT_NO_THROW((void)dynamic_cast(err)); EXPECT_NO_THROW((void)dynamic_cast(err)); - EXPECT_THROW(dynamic_cast(err), std::bad_cast); + EXPECT_THROW((void)dynamic_cast(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)); } if (expectedBody.size() > 0) diff --git a/sdk/core/azure-core/test/ut/url.cpp b/sdk/core/azure-core/test/ut/url.cpp index 3dbe9eeb40..17aff0ed36 100644 --- a/sdk/core/azure-core/test/ut/url.cpp +++ b/sdk/core/azure-core/test/ut/url.cpp @@ -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"))); diff --git a/sdk/core/azure-core/test/ut/uuid.cpp b/sdk/core/azure-core/test/ut/uuid.cpp index 0e17dbb5bc..d1da8dfcf6 100644 --- a/sdk/core/azure-core/test/ut/uuid.cpp +++ b/sdk/core/azure-core/test/ut/uuid.cpp @@ -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] == '-') { diff --git a/sdk/core/perf/CMakeLists.txt b/sdk/core/perf/CMakeLists.txt new file mode 100644 index 0000000000..811cb1bce6 --- /dev/null +++ b/sdk/core/perf/CMakeLists.txt @@ -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 + $ + $ +) + +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) diff --git a/sdk/core/performance-stress/NOTICE.txt b/sdk/core/perf/NOTICE.txt similarity index 99% rename from sdk/core/performance-stress/NOTICE.txt rename to sdk/core/perf/NOTICE.txt index 0baa374198..20924ff580 100644 --- a/sdk/core/performance-stress/NOTICE.txt +++ b/sdk/core/perf/NOTICE.txt @@ -1,4 +1,4 @@ -performance-stress +Azure Perf NOTICES AND INFORMATION Do Not Translate or Localize diff --git a/sdk/core/performance-stress/README.md b/sdk/core/perf/README.md similarity index 74% rename from sdk/core/performance-stress/README.md rename to sdk/core/perf/README.md index 83b21f674e..16ddce6e19 100644 --- a/sdk/core/performance-stress/README.md +++ b/sdk/core/perf/README.md @@ -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( $ ) -# 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 -#include +#include +#include // 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 @@ -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( - Azure::PerformanceStress::TestOptions)>> + std::function( + Azure::Perf::TestOptions)>> tests{ {"noOp", // Test Name - [](Azure::PerformanceStress::TestOptions options) { + [](Azure::Perf::TestOptions options) { // No Op test - return std::make_unique(options); + return std::make_unique(options); }}, {"extendedOptions", // Test Name - [](Azure::PerformanceStress::TestOptions options) { + [](Azure::Perf::TestOptions options) { // Extended options test - return std::make_unique(options); + return std::make_unique(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 -#include +#include +#include // 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 -#include -#include +#include +#include +#include // Utilities #include -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 GetTestOptions() override + std::vector 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. - - -[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. diff --git a/sdk/core/perf/cgmanifest.json b/sdk/core/perf/cgmanifest.json new file mode 100644 index 0000000000..244dcec184 --- /dev/null +++ b/sdk/core/perf/cgmanifest.json @@ -0,0 +1,14 @@ +{ + "Registrations": [ + { + "Component": { + "Type": "git", + "git": { + "RepositoryUrl": "https://github.com/vietjtnguyen/argagg", + "CommitHash": "b259b76c51751e5b4dbd070968e60dce108bbc88" + } + }, + "DevelopmentDependency": true + } + ] +} diff --git a/sdk/core/perf/inc/azure/perf.hpp b/sdk/core/perf/inc/azure/perf.hpp new file mode 100644 index 0000000000..a4acbf734f --- /dev/null +++ b/sdk/core/perf/inc/azure/perf.hpp @@ -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" diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/argagg.hpp b/sdk/core/perf/inc/azure/perf/argagg.hpp similarity index 99% rename from sdk/core/performance-stress/inc/azure/performance-stress/argagg.hpp rename to sdk/core/perf/inc/azure/perf/argagg.hpp index 5c6eb7d773..62192b6550 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/argagg.hpp +++ b/sdk/core/perf/inc/azure/perf/argagg.hpp @@ -169,7 +169,6 @@ namespace convert { * provides that extension point. The default, generic implementation of * argagg::convert::arg() calls converter::convert(). * - * @see * @ref argagg::csv */ template struct converter diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/base_test.hpp b/sdk/core/perf/inc/azure/perf/base_test.hpp similarity index 86% rename from sdk/core/performance-stress/inc/azure/performance-stress/base_test.hpp rename to sdk/core/perf/inc/azure/perf/base_test.hpp index 6b584ea5f6..05d91725cc 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/base_test.hpp +++ b/sdk/core/perf/inc/azure/perf/base_test.hpp @@ -11,12 +11,12 @@ #include -#include "azure/performance-stress/test_options.hpp" +#include "azure/perf/test_options.hpp" #include #include -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 GetTestOptions() + virtual std::vector GetTestOptions() { - return std::vector(); + return std::vector(); }; /** @@ -78,4 +78,4 @@ namespace Azure { namespace PerformanceStress { */ virtual void GlobalCleanup(){}; }; -}} // namespace Azure::PerformanceStress +}} // namespace Azure::Perf diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/dynamic_test_options.hpp b/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp similarity index 93% rename from sdk/core/performance-stress/inc/azure/performance-stress/dynamic_test_options.hpp rename to sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp index 9f5dd3b423..010ca7dfab 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/dynamic_test_options.hpp +++ b/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp @@ -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(); } }; -}} // namespace Azure::PerformanceStress +}} // namespace Azure::Perf diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/options.hpp b/sdk/core/perf/inc/azure/perf/options.hpp similarity index 76% rename from sdk/core/performance-stress/inc/azure/performance-stress/options.hpp rename to sdk/core/perf/inc/azure/perf/options.hpp index e9e18ef508..479b6ae848 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/options.hpp +++ b/sdk/core/perf/inc/azure/perf/options.hpp @@ -12,16 +12,16 @@ #include #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 #include #include -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 GetOptionMetadata(); + static std::vector 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 diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/program.hpp b/sdk/core/perf/inc/azure/perf/program.hpp similarity index 66% rename from sdk/core/performance-stress/inc/azure/performance-stress/program.hpp rename to sdk/core/perf/inc/azure/perf/program.hpp index daecab40c1..0185f3f01d 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/program.hpp +++ b/sdk/core/perf/inc/azure/perf/program.hpp @@ -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 -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 const& testOptions); + std::vector 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 const& tests, + std::vector const& tests, int argc, char** argv); }; -}} // namespace Azure::PerformanceStress +}} // namespace Azure::Perf diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/test.hpp b/sdk/core/perf/inc/azure/perf/test.hpp similarity index 50% rename from sdk/core/performance-stress/inc/azure/performance-stress/test.hpp rename to sdk/core/perf/inc/azure/perf/test.hpp index eedd762fcb..7418b9a9b2 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/test.hpp +++ b/sdk/core/perf/inc/azure/perf/test.hpp @@ -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 -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 diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/test_metadata.hpp b/sdk/core/perf/inc/azure/perf/test_metadata.hpp similarity index 66% rename from sdk/core/performance-stress/inc/azure/performance-stress/test_metadata.hpp rename to sdk/core/perf/inc/azure/perf/test_metadata.hpp index 207dfa9439..336463dc79 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/test_metadata.hpp +++ b/sdk/core/perf/inc/azure/perf/test_metadata.hpp @@ -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 #include #include -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( - Azure::PerformanceStress::TestOptions)> - Factory; + std::function(Azure::Perf::TestOptions)> Factory; }; -}} // namespace Azure::PerformanceStress +}} // namespace Azure::Perf diff --git a/sdk/core/performance-stress/inc/azure/performance-stress/test_options.hpp b/sdk/core/perf/inc/azure/perf/test_options.hpp similarity index 92% rename from sdk/core/performance-stress/inc/azure/performance-stress/test_options.hpp rename to sdk/core/perf/inc/azure/perf/test_options.hpp index cc88c1db4e..f76f3e0a1c 100644 --- a/sdk/core/performance-stress/inc/azure/performance-stress/test_options.hpp +++ b/sdk/core/perf/inc/azure/perf/test_options.hpp @@ -14,7 +14,7 @@ #include #include -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 diff --git a/sdk/core/performance-stress/src/arg_parser.cpp b/sdk/core/perf/src/arg_parser.cpp similarity index 80% rename from sdk/core/performance-stress/src/arg_parser.cpp rename to sdk/core/perf/src/arg_parser.cpp index 21074fe66f..cdcf999a52 100644 --- a/sdk/core/performance-stress/src/arg_parser.cpp +++ b/sdk/core/perf/src/arg_parser.cpp @@ -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 #include #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 const& testOptions) + std::vector 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"]; diff --git a/sdk/core/performance-stress/src/options.cpp b/sdk/core/perf/src/options.cpp similarity index 91% rename from sdk/core/performance-stress/src/options.cpp rename to sdk/core/perf/src/options.cpp index 2596b49b9f..cd8bc5d3b5 100644 --- a/sdk/core/performance-stress/src/options.cpp +++ b/sdk/core/perf/src/options.cpp @@ -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 -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::GlobalTestOptions::GetOptionMetadata() +std::vector Azure::Perf::GlobalTestOptions::GetOptionMetadata() { /* [Option('d', "duration", Default = 10, HelpText = "Duration of test in seconds")] diff --git a/sdk/core/performance-stress/src/program.cpp b/sdk/core/perf/src/program.cpp similarity index 87% rename from sdk/core/performance-stress/src/program.cpp rename to sdk/core/perf/src/program.cpp index 5ff55892c7..0a82b5a643 100644 --- a/sdk/core/performance-stress/src/program.cpp +++ b/sdk/core/perf/src/program.cpp @@ -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 #include @@ -13,8 +13,8 @@ namespace { -inline std::unique_ptr PrintAvailableTests( - std::vector const& tests) +inline std::unique_ptr PrintAvailableTests( + std::vector 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 PrintAvailable return nullptr; } -inline Azure::PerformanceStress::TestMetadata const* GetTestMetadata( - std::vector const& tests, +inline Azure::Perf::TestMetadata const* GetTestMetadata( + std::vector const& tests, int argc, char** argv) { @@ -64,8 +64,8 @@ inline std::string ReplaceAll( } inline void PrintOptions( - Azure::PerformanceStress::GlobalTestOptions const& options, - std::vector const& testOptions, + Azure::Perf::GlobalTestOptions const& options, + std::vector 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 ZipAvg( inline void RunTests( Azure::Core::Context const& context, - std::vector> const& tests, - Azure::PerformanceStress::GlobalTestOptions const& options, + std::vector> 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 const& tests, + std::vector 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> parallelTest( - parallelTasks); + std::vector> 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 ******************************/ diff --git a/sdk/core/perf/test/CMakeLists.txt b/sdk/core/perf/test/CMakeLists.txt new file mode 100644 index 0000000000..67ccf4bbd0 --- /dev/null +++ b/sdk/core/perf/test/CMakeLists.txt @@ -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 + $ +) + +# 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") diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/curl_http_client_get_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/curl_http_client_get_test.hpp similarity index 60% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/curl_http_client_get_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/curl_http_client_get_test.hpp index 5e13d51f33..d9834133ec 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/curl_http_client_get_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/curl_http_client_get_test.hpp @@ -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 #include -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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/delay_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/delay_test.hpp similarity index 77% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/delay_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/delay_test.hpp index 361e2b7720..e9432e78d3 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/delay_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/delay_test.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include @@ -17,7 +17,7 @@ #include #include -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 GetTestOptions() override + std::vector 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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/exception_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/exception_test.hpp similarity index 61% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/exception_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/exception_test.hpp index a50efb4884..72361db261 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/exception_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/exception_test.hpp @@ -10,25 +10,25 @@ #pragma once -#include +#include #include -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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/extended_options_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/extended_options_test.hpp similarity index 61% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/extended_options_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/extended_options_test.hpp index 6a9de8949e..ccfb2cd170 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/extended_options_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/extended_options_test.hpp @@ -9,30 +9,29 @@ #pragma once -#include +#include #include #include -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 GetTestOptions() override + std::vector 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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/http_client_get_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp similarity index 80% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/http_client_get_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp index c3b1f404b0..3c66c784f5 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/http_client_get_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/http_client_get_test.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include @@ -18,7 +18,7 @@ #include #include -namespace Azure { namespace PerformanceStress { namespace Test { +namespace Azure { namespace Perf { namespace Test { namespace Details { static std::unique_ptr 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 GetTestOptions() override + std::vector GetTestOptions() override { return {{"url", {"--url"}, "Url to send the http request. *Required parameter.", 1, true}}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/no_op_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/no_op_test.hpp similarity index 53% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/no_op_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/no_op_test.hpp index 23452d92ac..1910ec3cf2 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/no_op_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/no_op_test.hpp @@ -9,46 +9,45 @@ #pragma once -#include +#include #include -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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/win_http_client_get_test.hpp b/sdk/core/perf/test/inc/azure/perf/test/win_http_client_get_test.hpp similarity index 56% rename from sdk/core/performance-stress/test/inc/azure/performance-stress/test/win_http_client_get_test.hpp rename to sdk/core/perf/test/inc/azure/perf/test/win_http_client_get_test.hpp index dc0f709289..0cbac3e346 100644 --- a/sdk/core/performance-stress/test/inc/azure/performance-stress/test/win_http_client_get_test.hpp +++ b/sdk/core/perf/test/inc/azure/perf/test/win_http_client_get_test.hpp @@ -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 -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(options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}} // namespace Azure::PerformanceStress::Test +}}} // namespace Azure::Perf::Test diff --git a/sdk/core/perf/test/src/main.cpp b/sdk/core/perf/test/src/main.cpp new file mode 100644 index 0000000000..70846e189d --- /dev/null +++ b/sdk/core/perf/test/src/main.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include + +#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 + +int main(int argc, char** argv) +{ + + // Create the test list + std::vector 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; +} diff --git a/sdk/core/performance-stress/CHANGELOG.md b/sdk/core/performance-stress/CHANGELOG.md deleted file mode 100644 index 2fea025bc8..0000000000 --- a/sdk/core/performance-stress/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Release History - -## 1.0.0-preview.1 (Unreleased) - -* Testing. Validating automation. diff --git a/sdk/core/performance-stress/CMakeLists.txt b/sdk/core/performance-stress/CMakeLists.txt deleted file mode 100644 index e406719e8e..0000000000 --- a/sdk/core/performance-stress/CMakeLists.txt +++ /dev/null @@ -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 - $ - $ -) - -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) diff --git a/sdk/core/performance-stress/LICENSE b/sdk/core/performance-stress/LICENSE deleted file mode 100644 index 51b6a76e54..0000000000 --- a/sdk/core/performance-stress/LICENSE +++ /dev/null @@ -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. diff --git a/sdk/core/performance-stress/cgmanifest.json b/sdk/core/performance-stress/cgmanifest.json deleted file mode 100644 index 819cdc37e6..0000000000 --- a/sdk/core/performance-stress/cgmanifest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Registrations": [ - ] -} diff --git a/sdk/core/performance-stress/inc/azure/performance_framework.hpp b/sdk/core/performance-stress/inc/azure/performance_framework.hpp deleted file mode 100644 index 91ee3f80dc..0000000000 --- a/sdk/core/performance-stress/inc/azure/performance_framework.hpp +++ /dev/null @@ -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" diff --git a/sdk/core/performance-stress/test/CMakeLists.txt b/sdk/core/performance-stress/test/CMakeLists.txt deleted file mode 100644 index 67b13e4426..0000000000 --- a/sdk/core/performance-stress/test/CMakeLists.txt +++ /dev/null @@ -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 - $ -) - -# 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") diff --git a/sdk/core/performance-stress/test/src/main.cpp b/sdk/core/performance-stress/test/src/main.cpp deleted file mode 100644 index e1033715b4..0000000000 --- a/sdk/core/performance-stress/test/src/main.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include - -#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 - -int main(int argc, char** argv) -{ - - // Create the test list - std::vector 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; -} diff --git a/sdk/identity/azure-identity/CMakeLists.txt b/sdk/identity/azure-identity/CMakeLists.txt index ac2331baec..91f8bd311b 100644 --- a/sdk/identity/azure-identity/CMakeLists.txt +++ b/sdk/identity/azure-identity/CMakeLists.txt @@ -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() diff --git a/sdk/identity/azure-identity/test/performance/CMakeLists.txt b/sdk/identity/azure-identity/test/perf/CMakeLists.txt similarity index 59% rename from sdk/identity/azure-identity/test/performance/CMakeLists.txt rename to sdk/identity/azure-identity/test/perf/CMakeLists.txt index 1bcef5ccf2..e992c454fd 100644 --- a/sdk/identity/azure-identity/test/performance/CMakeLists.txt +++ b/sdk/identity/azure-identity/test/perf/CMakeLists.txt @@ -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 $ ) -# 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") diff --git a/sdk/identity/azure-identity/test/performance/inc/azure/identity/test/performance/secret_credential.hpp b/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential.hpp similarity index 72% rename from sdk/identity/azure-identity/test/performance/inc/azure/identity/test/performance/secret_credential.hpp rename to sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential.hpp index 57b84dbdc9..accafa2a08 100644 --- a/sdk/identity/azure-identity/test/performance/inc/azure/identity/test/performance/secret_credential.hpp +++ b/sdk/identity/azure-identity/test/perf/inc/azure/identity/test/secret_credential.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include @@ -17,13 +17,13 @@ #include #include -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 GetTestOptions() override + std::vector 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( - options); + [](Azure::Perf::TestOptions options) { + return std::make_unique(options); }}; } }; -}}}} // namespace Azure::Identity::Test::Performance +}}} // namespace Azure::Identity::Test diff --git a/sdk/identity/azure-identity/test/perf/src/main.cpp b/sdk/identity/azure-identity/test/perf/src/main.cpp new file mode 100644 index 0000000000..10e0397152 --- /dev/null +++ b/sdk/identity/azure-identity/test/perf/src/main.cpp @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include + +#include "azure/identity/test/secret_credential.hpp" + +int main(int argc, char** argv) +{ + + // Create the test list + std::vector tests{ + Azure::Identity::Test::SecretCredentialTest::GetTestMetadata()}; + + Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); + + return 0; +} diff --git a/sdk/identity/azure-identity/test/performance/src/main.cpp b/sdk/identity/azure-identity/test/performance/src/main.cpp deleted file mode 100644 index a821c24c20..0000000000 --- a/sdk/identity/azure-identity/test/performance/src/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include - -#include "azure/identity/test/performance/secret_credential.hpp" - -int main(int argc, char** argv) -{ - - // Create the test list - std::vector tests{ - Azure::Identity::Test::Performance::SecretCredentialTest::GetTestMetadata()}; - - Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); - - return 0; -} diff --git a/sdk/identity/azure-identity/test/CMakeLists.txt b/sdk/identity/azure-identity/test/ut/CMakeLists.txt similarity index 95% rename from sdk/identity/azure-identity/test/CMakeLists.txt rename to sdk/identity/azure-identity/test/ut/CMakeLists.txt index 13a8036aa4..6d6fe2d123 100644 --- a/sdk/identity/azure-identity/test/CMakeLists.txt +++ b/sdk/identity/azure-identity/test/ut/CMakeLists.txt @@ -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() diff --git a/sdk/identity/azure-identity/test/main.cpp b/sdk/identity/azure-identity/test/ut/main.cpp similarity index 100% rename from sdk/identity/azure-identity/test/main.cpp rename to sdk/identity/azure-identity/test/ut/main.cpp diff --git a/sdk/identity/azure-identity/test/simplified_header.cpp b/sdk/identity/azure-identity/test/ut/simplified_header.cpp similarity index 100% rename from sdk/identity/azure-identity/test/simplified_header.cpp rename to sdk/identity/azure-identity/test/ut/simplified_header.cpp diff --git a/sdk/keyvault/azure-security-keyvault-common/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-common/CMakeLists.txt index 2427790e57..4b5a897831 100644 --- a/sdk/keyvault/azure-security-keyvault-common/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-common/CMakeLists.txt @@ -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( diff --git a/sdk/keyvault/azure-security-keyvault-common/test/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-common/test/ut/CMakeLists.txt similarity index 100% rename from sdk/keyvault/azure-security-keyvault-common/test/CMakeLists.txt rename to sdk/keyvault/azure-security-keyvault-common/test/ut/CMakeLists.txt diff --git a/sdk/keyvault/azure-security-keyvault-common/test/main.cpp b/sdk/keyvault/azure-security-keyvault-common/test/ut/main.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-common/test/main.cpp rename to sdk/keyvault/azure-security-keyvault-common/test/ut/main.cpp diff --git a/sdk/keyvault/azure-security-keyvault-common/test/pipeline_test.cpp b/sdk/keyvault/azure-security-keyvault-common/test/ut/pipeline_test.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-common/test/pipeline_test.cpp rename to sdk/keyvault/azure-security-keyvault-common/test/ut/pipeline_test.cpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt index 1706a8b204..dccaaa539c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt @@ -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) diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/performance/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-keys/test/perf/CMakeLists.txt similarity index 55% rename from sdk/keyvault/azure-security-keyvault-keys/test/performance/CMakeLists.txt rename to sdk/keyvault/azure-security-keyvault-keys/test/perf/CMakeLists.txt index ea492da40c..178e9b6cee 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/performance/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-keys/test/perf/CMakeLists.txt @@ -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 $ ) -# 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") diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key.hpp new file mode 100644 index 0000000000..1c9b8969df --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/test/perf/inc/azure/keyvault/keys/test/get_key.hpp @@ -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 + +#include +#include + +#include +#include +#include + +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 m_credentail; + std::unique_ptr m_client; + + public: + /** + * @brief Get the Ids and secret + * + */ + void Setup() override + { + m_vaultUrl = m_options.GetMandatoryOption("vaultUrl"); + m_keyName = m_options.GetMandatoryOption("keyName"); + m_tenantId = m_options.GetMandatoryOption("TenantId"); + m_clientId = m_options.GetMandatoryOption("ClientId"); + m_secret = m_options.GetMandatoryOption("Secret"); + m_credentail = std::make_shared( + m_tenantId, m_clientId, m_secret); + m_client + = std::make_unique(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 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(options); + }}; + } + }; + +}}}}} // namespace Azure::Security::KeyVault::Keys::Test diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/main.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/main.cpp new file mode 100644 index 0000000000..81d016cf25 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/test/perf/src/main.cpp @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include + +#include "azure/keyvault/keys/test/get_key.hpp" + +int main(int argc, char** argv) +{ + + // Create the test list + std::vector tests{ + Azure::Security::KeyVault::Keys::Test::GetKey::GetTestMetadata()}; + + Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); + + return 0; +} diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/performance/inc/azure/keyvault/keys/test/performance/get_key.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/performance/inc/azure/keyvault/keys/test/performance/get_key.hpp deleted file mode 100644 index fd93645fc5..0000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/test/performance/inc/azure/keyvault/keys/test/performance/get_key.hpp +++ /dev/null @@ -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 - -#include -#include - -#include -#include -#include - -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 m_credentail; - std::unique_ptr m_client; - - public: - /** - * @brief Get the Ids and secret - * - */ - void Setup() override - { - m_vaultUrl = m_options.GetMandatoryOption("vaultUrl"); - m_keyName = m_options.GetMandatoryOption("keyName"); - m_tenantId = m_options.GetMandatoryOption("TenantId"); - m_clientId = m_options.GetMandatoryOption("ClientId"); - m_secret = m_options.GetMandatoryOption("Secret"); - m_credentail = std::make_shared( - m_tenantId, m_clientId, m_secret); - m_client = std::make_unique( - 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 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( - options); - }}; - } - }; - -}}}}}} // namespace Azure::Security::KeyVault::Keys::Test::Performance diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/performance/src/main.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/performance/src/main.cpp deleted file mode 100644 index b92f6d06f8..0000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/test/performance/src/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include - -#include "azure/keyvault/keys/test/performance/get_key.hpp" - -int main(int argc, char** argv) -{ - - // Create the test list - std::vector tests{ - Azure::Security::KeyVault::Keys::Test::Performance::GetKey::GetTestMetadata()}; - - Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); - - return 0; -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/CMakeLists.txt b/sdk/keyvault/azure-security-keyvault-keys/test/ut/CMakeLists.txt similarity index 96% rename from sdk/keyvault/azure-security-keyvault-keys/test/CMakeLists.txt rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/CMakeLists.txt index 24749a62c8..d8bed34c9c 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/test/CMakeLists.txt +++ b/sdk/keyvault/azure-security-keyvault-keys/test/ut/CMakeLists.txt @@ -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() diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/key_client_base_test.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/key_client_base_test.hpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_base_test.hpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/key_client_test.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/key_client_test.cpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test.cpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/key_client_test_live.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test_live.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/key_client_test_live.cpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/key_client_test_live.cpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/main.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/main.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/main.cpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/main.cpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/mocked_transport_adapter_test.hpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/mocked_transport_adapter_test.hpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/mocked_transport_adapter_test.hpp diff --git a/sdk/keyvault/azure-security-keyvault-keys/test/telemetry_header_test.cpp b/sdk/keyvault/azure-security-keyvault-keys/test/ut/telemetry_header_test.cpp similarity index 100% rename from sdk/keyvault/azure-security-keyvault-keys/test/telemetry_header_test.cpp rename to sdk/keyvault/azure-security-keyvault-keys/test/ut/telemetry_header_test.cpp diff --git a/sdk/storage/CMakeLists.txt b/sdk/storage/CMakeLists.txt index c6628928ba..5c8f029093 100644 --- a/sdk/storage/CMakeLists.txt +++ b/sdk/storage/CMakeLists.txt @@ -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() diff --git a/sdk/storage/azure-storage-blobs/CMakeLists.txt b/sdk/storage/azure-storage-blobs/CMakeLists.txt index e2ecce8dc6..417dab0560 100644 --- a/sdk/storage/azure-storage-blobs/CMakeLists.txt +++ b/sdk/storage/azure-storage-blobs/CMakeLists.txt @@ -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() diff --git a/sdk/storage/azure-storage-blobs/test/performance/CMakeLists.txt b/sdk/storage/azure-storage-blobs/test/perf/CMakeLists.txt similarity index 58% rename from sdk/storage/azure-storage-blobs/test/performance/CMakeLists.txt rename to sdk/storage/azure-storage-blobs/test/perf/CMakeLists.txt index 5985075df3..9687e4057d 100644 --- a/sdk/storage/azure-storage-blobs/test/performance/CMakeLists.txt +++ b/sdk/storage/azure-storage-blobs/test/perf/CMakeLists.txt @@ -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 $ ) -# 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") diff --git a/sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/blob_base_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp similarity index 84% rename from sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/blob_base_test.hpp rename to sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp index 5764a024fd..86960c60ca 100644 --- a/sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/blob_base_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include @@ -17,13 +17,13 @@ #include #include -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 GetTestOptions() override + std::vector 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 diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob.hpp new file mode 100644 index 0000000000..96ed554800 --- /dev/null +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob.hpp @@ -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 + +#include "azure/storage/blobs/test/blob_base_test.hpp" + +#include +#include +#include + +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 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(options); + }}; + } + }; + +}}}} // namespace Azure::Storage::Blobs::Test diff --git a/sdk/storage/azure-storage-blobs/test/perf/src/main.cpp b/sdk/storage/azure-storage-blobs/test/perf/src/main.cpp new file mode 100644 index 0000000000..9682432390 --- /dev/null +++ b/sdk/storage/azure-storage-blobs/test/perf/src/main.cpp @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include + +#include "azure/storage/blobs/test/download_blob.hpp" + +int main(int argc, char** argv) +{ + + // Create the test list + std::vector tests{ + Azure::Storage::Blobs::Test::DownloadBlob::GetTestMetadata()}; + + Azure::Perf::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); + + return 0; +} diff --git a/sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/download_blob.hpp b/sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/download_blob.hpp deleted file mode 100644 index 6c1c5723e7..0000000000 --- a/sdk/storage/azure-storage-blobs/test/performance/inc/azure/storage/blobs/test/performance/download_blob.hpp +++ /dev/null @@ -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 - -#include "azure/storage/blobs/test/performance/blob_base_test.hpp" - -#include -#include -#include - -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 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( - options); - }}; - } - }; - -}}}}} // namespace Azure::Storage::Blobs::Test::Performance diff --git a/sdk/storage/azure-storage-blobs/test/performance/src/main.cpp b/sdk/storage/azure-storage-blobs/test/performance/src/main.cpp deleted file mode 100644 index 681b69a11c..0000000000 --- a/sdk/storage/azure-storage-blobs/test/performance/src/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include - -#include "azure/storage/blobs/test/performance/download_blob.hpp" - -int main(int argc, char** argv) -{ - - // Create the test list - std::vector tests{ - Azure::Storage::Blobs::Test::Performance::DownloadBlob::GetTestMetadata()}; - - Azure::PerformanceStress::Program::Run(Azure::Core::GetApplicationContext(), tests, argc, argv); - - return 0; -} diff --git a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/append_blob_client_test.hpp rename to sdk/storage/azure-storage-blobs/test/ut/append_blob_client_test.hpp diff --git a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/blob_container_client_test.hpp rename to sdk/storage/azure-storage-blobs/test/ut/blob_container_client_test.hpp diff --git a/sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/blob_sas_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/blob_service_client_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/blob_service_client_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/block_blob_client_test.hpp rename to sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.hpp diff --git a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp diff --git a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.hpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/page_blob_client_test.hpp rename to sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.hpp diff --git a/sdk/storage/azure-storage-blobs/test/storage_retry_policy_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp similarity index 100% rename from sdk/storage/azure-storage-blobs/test/storage_retry_policy_test.cpp rename to sdk/storage/azure-storage-blobs/test/ut/storage_retry_policy_test.cpp