diff --git a/sdk/core/perf/inc/azure/perf/argagg.hpp b/sdk/core/perf/inc/azure/perf/argagg.hpp index 11bdaeb69..82c224bf4 100644 --- a/sdk/core/perf/inc/azure/perf/argagg.hpp +++ b/sdk/core/perf/inc/azure/perf/argagg.hpp @@ -393,7 +393,7 @@ struct parser_results * Returns the name of the program from the original arguments list. This is * always the first argument. */ - const char* program; + const char* program = nullptr; /** * @brief diff --git a/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp b/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp index df7e62fb9..501bd7889 100644 --- a/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp +++ b/sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp @@ -60,6 +60,28 @@ namespace Azure { namespace Perf { return defaultValue; } + /** + * @brief Check if the option was parsed from command line. + * + * @param optionName The name of the option. + * @return true if the option was parsed from command line. + * @return false if the option was not parsed from command line. + */ + bool HasOption(std::string const& optionName) const + { + if (m_results.has_option(optionName)) + { + // If there are results for this option , but the first result has a nullptr arg, it's a + // boolean parameter with no arguments so return true. + if (m_results[optionName].count() != 0) + { + // No args were passed for this option, it is present. + return true; + } + } + return false; + } + /** * @brief Get the option value from the option name. * diff --git a/sdk/core/perf/src/program.cpp b/sdk/core/perf/src/program.cpp index c9379915e..fac6dec3f 100644 --- a/sdk/core/perf/src/program.cpp +++ b/sdk/core/perf/src/program.cpp @@ -88,16 +88,47 @@ inline void PrintOptions( { try { - auto optionName{option.Name}; - optionsAsJson[optionName] - = option.SensitiveData ? "***" : parsedArgs[optionName].as(); + if (parsedArgs.has_option(option.Name)) + { + auto optionName{option.Name}; + if (option.ExpectedArgs != 0) + { + optionsAsJson[optionName] + = (option.SensitiveData ? "***" : parsedArgs[optionName].as()); + } + else + { + optionsAsJson[optionName] = true; + } + } + else + { + if (option.Required) + { + // re-throw + throw std::invalid_argument("Missing mandatory parameter: " + option.Name); + } + else + { + if (option.ExpectedArgs == 0) + { + // arg was not parsed + optionsAsJson[option.Name] = false; + } + else + { + // arg was not parsed + optionsAsJson[option.Name] = nullptr; + } + } + } } catch (std::out_of_range const&) { if (!option.Required) { // arg was not parsed - optionsAsJson[option.Name] = "default value"; + optionsAsJson[option.Name] = nullptr; } else { diff --git a/sdk/storage/azure-storage-blobs/perf-tests.yml b/sdk/storage/azure-storage-blobs/perf-tests.yml index 31329e1ab..0fd2a358b 100644 --- a/sdk/storage/azure-storage-blobs/perf-tests.yml +++ b/sdk/storage/azure-storage-blobs/perf-tests.yml @@ -5,8 +5,6 @@ Project: azure-storage-blobs-perf PrimaryPackage: azure-storage-blobs-cpp PackageVersions: -- azure-storage-blobs-cpp: 12.6.2 - azure-core-cpp: 1.7.2 - azure-storage-blobs-cpp: source azure-core-cpp: source @@ -18,6 +16,10 @@ Tests: - --size 10485760 --parallel 32 - --size 1073741824 --parallel 1 --warmup 60 --duration 60 - --size 1073741824 --parallel 8 --warmup 60 --duration 60 + - --size 10240 --parallel 64 --token-credential + - --size 10485760 --parallel 32 --token-credential + - --size 1073741824 --parallel 1 --warmup 60 --duration 60 --token-credential + - --size 1073741824 --parallel 8 --warmup 60 --duration 60 --token-credential - Test: upload Class: UploadBlob @@ -26,6 +28,10 @@ Tests: - --size 10485760 --parallel 32 - --size 1073741824 --parallel 1 --warmup 60 --duration 60 - --size 1073741824 --parallel 8 --warmup 60 --duration 60 + - --size 10240 --parallel 64 --token-credential + - --size 10485760 --parallel 32 --token-credential + - --size 1073741824 --parallel 1 --warmup 60 --duration 60 --token-credential + - --size 1073741824 --parallel 8 --warmup 60 --duration 60 --token-credential - Test: list-blobs Class: ListBlob @@ -33,3 +39,6 @@ Tests: - --count 5 --parallel 64 - --count 500 --parallel 32 - --count 50000 --parallel 32 --warmup 60 --duration 60 + - --count 5 --parallel 64 --token-credential + - --count 500 --parallel 32 --token-credential + - --count 50000 --parallel 32 --warmup 60 --duration 60 --token-credential diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp index 187eaf8e1..4a19a72f3 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/blob_base_test.hpp @@ -64,6 +64,9 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { // Get connection string from env const static std::string envConnectionString = Azure::Core::_internal::Environment::GetVariable("STORAGE_CONNECTION_STRING"); + + const static std::string hostName + = Azure::Core::_internal::Environment::GetVariable("AZURE_STORAGE_ACCOUNT_NAME"); m_connectionString = envConnectionString; // Generate random container and blob names. @@ -71,9 +74,19 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { m_blobName = "blob" + Azure::Core::Uuid::CreateUuid().ToString(); // Create client, container and blobClient - m_serviceClient = std::make_unique( - Azure::Storage::Blobs::BlobServiceClient::CreateFromConnectionString( - m_connectionString, InitClientOptions())); + if (!m_options.HasOption("TokenCredential")) + { + m_serviceClient = std::make_unique( + Azure::Storage::Blobs::BlobServiceClient::CreateFromConnectionString( + m_connectionString, InitClientOptions())); + } + else + { + m_serviceClient = std::make_unique( + "https://" + hostName + ".blob.core.windows.net", + GetTestCredential(), + InitClientOptions()); + } m_containerClient = std::make_unique( m_serviceClient->GetBlobContainerClient(m_containerName)); m_containerClient->CreateIfNotExists(); @@ -99,5 +112,4 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { */ std::vector GetTestOptions() override { return {}; } }; - }}}} // namespace Azure::Storage::Blobs::Test diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp index 19b00c07a..e1871135b 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/download_blob_test.hpp @@ -71,7 +71,13 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { std::vector GetTestOptions() override { // TODO: Merge with base options - return {{"Size", {"--size"}, "Size of payload (in bytes)", 1, true}}; + + return { + {"TokenCredential", + {"--token-credential"}, + "Use a token credential to run the test. By default, a connection string is used.", + 0}, + {"Size", {"--size"}, "Size of payload (in bytes)", 1, true}}; } /** diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp index 4b42d5d0d..99172b79a 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/list_blob_test.hpp @@ -82,7 +82,12 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { std::vector GetTestOptions() override { // TODO: Merge with base options - return {{"Count", {"--count"}, "Number of blobs to list", 1, true}}; + return { + {"TokenCredential", + {"--token-credential"}, + "Use a token credential to run the test. By default, a connection string is used.", + 0}, + {"Count", {"--count"}, "Number of blobs to list", 1, true}}; } /** diff --git a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp index 7869e3298..b313ff69d 100644 --- a/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp +++ b/sdk/storage/azure-storage-blobs/test/perf/inc/azure/storage/blobs/test/upload_blob_test.hpp @@ -68,7 +68,12 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Test { std::vector GetTestOptions() override { // TODO: Merge with base options - return {{"Size", {"--size", "-s"}, "Size of payload (in bytes)", 1, true}}; + return { + {"TokenCredential", + {"--token-credential"}, + "Use a token credential to run the test. By default, a connection string is used.", + 0}, + {"Size", {"--size", "-s"}, "Size of payload (in bytes)", 1, true}}; } /**