Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sdk/core/perf/inc/azure/perf/base_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ namespace Azure { namespace Perf {
*
* @param proxy A test-proxy server url.
*/
void SetTestProxy(std::string const& proxy) { m_proxy = proxy; }
void SetTestProxy(std::string const& proxy)
{
if (!proxy.empty())
{
m_isInsecureEnabled = true;
m_proxy = proxy;
}
}

/**
* @brief Set the performance test to run insecure.
Expand Down
8 changes: 7 additions & 1 deletion sdk/core/perf/inc/azure/perf/dynamic_test_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ namespace Azure { namespace Perf {
class TestOptions {
private:
argagg::parser_results m_results;
bool m_skipInitial = true;

public:
/**
* @brief Create the test options component from the command line parsed results.
*
* @param results The command line parsed results.
*/
explicit TestOptions(argagg::parser_results results) : m_results(results) {}
explicit TestOptions(argagg::parser_results results, bool skipInitial = true)
: m_results(results), m_skipInitial(skipInitial)
{
}

/**
* @brief Get the option value from the option name. If the option is not found, it returns \p
Expand Down Expand Up @@ -72,5 +76,7 @@ namespace Azure { namespace Perf {
{
return m_results[optionName].as<T>();
}

bool ShouldSkipInitial() { return m_skipInitial; }
};
}} // namespace Azure::Perf
9 changes: 5 additions & 4 deletions sdk/core/perf/src/base_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ namespace Azure { namespace Perf {

void BaseTest::PostSetUp()
{

if (!m_proxy.empty())
{
Azure::Core::_internal::ClientOptions clientOp;
Expand All @@ -148,10 +147,13 @@ namespace Azure { namespace Perf {
Azure::Core::Http::_internal::HttpPipeline pipeline(
clientOp, "PerfFw", "na", std::move(policiesRe), std::move(policiesOp));
Azure::Core::Context ctx;

// Make one call to Run() before starting recording, to avoid capturing one-time setup
// like authorization requests.
this->Run(ctx);
if (!m_options.ShouldSkipInitial())
{
this->Run(ctx);
}

// Send start-record call
{
Expand Down Expand Up @@ -192,7 +194,6 @@ namespace Azure { namespace Perf {
Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Post, startPlayback);
request.SetHeader("x-recording-id", m_recordId);
auto response = pipeline.Send(request, ctx);

auto const& headers = response->GetHeaders();
auto findHeader = std::find_if(
headers.begin(),
Expand Down
9 changes: 6 additions & 3 deletions sdk/core/perf/src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ std::vector<Azure::Perf::TestOption> Azure::Perf::GlobalTestOptions::GetOptionMe
{"-d", "--duration"},
"Duration of the test in seconds. Default to 10 seconds.",
1},
{"help", {"-h", "--help"}, "Display help information.", 0},
{"Host", {"--host"}, "Host to redirect HTTP requests. No redirection by default.", 1},
{"Insecure", {"--insecure"}, "Allow untrusted SSL certs. Default to false.", 0},
{"Iterations",
Expand All @@ -83,8 +84,10 @@ std::vector<Azure::Perf::TestOption> Azure::Perf::GlobalTestOptions::GetOptionMe
1},
{"Port", {"--port"}, "Port to redirect HTTP requests. Default to no redirection.", 1},
{"Rate", {"-r", "--rate"}, "Target throughput (ops/sec). Default to no throughput.", 1},
{"Warmup", {"-w", "--warmup"}, "Duration of warmup in seconds. Default to 5 seconds.", 1},

{"Sync", {"-y", "--sync"}, "Runs sync version of test, not implemented", 0},
{"TestProxies", {"-x", "--test-proxies"}, "URIs of TestProxy Servers (separated by ';')", 1},
{"help", {"-h", "--help"}, "Display help information.", 0},
{"Sync", {"-y", "--sync"}, "Runs sync version of test, not implemented", 0}};
{"Warmup", {"-w", "--warmup"}, "Duration of warmup in seconds. Default to 5 seconds.", 1},
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespace Azure { namespace Identity { namespace Test {
m_clientId = m_options.GetMandatoryOption<std::string>("ClientId");
m_secret = m_options.GetMandatoryOption<std::string>("Secret");
m_tokenRequestContext.Scopes.push_back(m_options.GetMandatoryOption<std::string>("Scope"));
if (m_options.GetOptionOrDefault<bool>("Cache", false) == false)
{
m_tokenRequestContext.MinimumExpiration = std::chrono::hours(1000000);
}
m_credential = std::make_unique<Azure::Identity::ClientSecretCredential>(
m_tenantId,
m_clientId,
Expand Down Expand Up @@ -76,7 +80,8 @@ namespace Azure { namespace Identity { namespace Test {
{"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},
{"Scope", {"--scope"}, "One scope to request access to.", 1, true}};
{"Scope", {"--scope"}, "One scope to request access to.", 1, true},
{"Cache", {"--cache"}, "Use credential cache.", 1, false}};
}

/**
Expand Down