Skip to content

Commit 7e17930

Browse files
LarryOstermanCopilotheaths
authored
Finish readme text on pipeline provisioning; added keyvault secrets t… (Azure#3186)
…ests --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Heath Stewart <[email protected]>
1 parent da3deef commit 7e17930

File tree

17 files changed

+492
-281
lines changed

17 files changed

+492
-281
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Cargo.lock
1313
.proxy/
1414
tests/data/
1515
review/
16+
results.json
1617

1718
# Dependencies.
1819
vcpkg_installed/

sdk/core/azure_core/benches/http_transport_benchmarks.rs

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ use azure_identity::DeveloperToolsCredential;
1515
use criterion::{criterion_group, criterion_main, Criterion};
1616
use std::sync::Arc;
1717

18+
#[cfg_attr(target_os = "macos", allow(dead_code))]
19+
const HTTP_ENDPOINT: &str = "https://azuresdkforcpp.azurewebsites.net";
20+
//const HTTP_ENDPOINT: &str = "http://httpbin.org";
21+
1822
#[derive(Clone, SafeDebug)]
1923
pub struct TestServiceClientOptions {
2024
pub client_options: ClientOptions,
@@ -136,7 +140,7 @@ pub fn simple_http_transport_test(c: &mut Criterion) {
136140
{
137141
let rt = tokio::runtime::Runtime::new().unwrap();
138142

139-
let endpoint = "https://azuresdkforcpp.azurewebsites.net";
143+
let endpoint = HTTP_ENDPOINT;
140144
let credential = DeveloperToolsCredential::new(None).unwrap();
141145
let options = TestServiceClientOptions::default();
142146

@@ -163,7 +167,7 @@ pub fn disable_pooling_http_transport_test(c: &mut Criterion) {
163167
{
164168
let rt = tokio::runtime::Runtime::new().unwrap();
165169

166-
let endpoint = "https://azuresdkforcpp.azurewebsites.net";
170+
let endpoint = HTTP_ENDPOINT;
167171
let credential = DeveloperToolsCredential::new(None).unwrap();
168172
let transport = new_reqwest_client_disable_connection_pool();
169173
let options = TestServiceClientOptions {
@@ -196,21 +200,50 @@ pub fn baseline_http_transport_test(c: &mut Criterion) {
196200
#[cfg(not(target_os = "macos"))]
197201
{
198202
let rt = tokio::runtime::Runtime::new().unwrap();
199-
let endpoint = "https://azuresdkforcpp.azurewebsites.net";
203+
let endpoint = HTTP_ENDPOINT;
200204

201205
let http_client = new_default_reqwest_client();
202206

207+
let url = Url::parse(&format!("{}/get", endpoint)).unwrap();
208+
203209
// Benchmark GET and POST requests
204210
c.bench_function("baseline_http_pipeline_test", |b| {
211+
b.to_async(&rt).iter(|| {
212+
// Clone the Url for this iteration so the async block can take ownership.
213+
let url = url.clone();
214+
let http_client = http_client.clone();
215+
async move {
216+
let request = Request::new(url, Method::Get);
217+
let response = http_client.execute_request(&request).await;
218+
assert!(response.is_ok());
219+
let response = response.unwrap();
220+
assert_eq!(response.status(), azure_core::http::StatusCode::Ok);
221+
}
222+
});
223+
});
224+
}
225+
}
226+
227+
#[cfg_attr(target_os = "macos", allow(unused_variables))]
228+
pub fn raw_reqwest_http_transport_test(c: &mut Criterion) {
229+
#[cfg(target_os = "macos")]
230+
return;
231+
232+
#[cfg(not(target_os = "macos"))]
233+
{
234+
let rt = tokio::runtime::Runtime::new().unwrap();
235+
let endpoint = HTTP_ENDPOINT;
236+
237+
let client = ::reqwest::Client::new();
238+
239+
// Benchmark GET and POST requests
240+
c.bench_function("raw_http_pipeline_test", |b| {
205241
b.to_async(&rt).iter(|| async {
206-
let request = Request::new(
207-
Url::parse(&format!("{}/get", endpoint)).unwrap(),
208-
Method::Get,
209-
);
210-
let response = http_client.execute_request(&request).await;
242+
let request = client.get(format!("{}/get", endpoint));
243+
let response = request.send().await;
211244
assert!(response.is_ok());
212245
let response = response.unwrap();
213-
assert_eq!(response.status(), azure_core::http::StatusCode::Ok);
246+
assert_eq!(response.status(), reqwest::StatusCode::OK);
214247
});
215248
});
216249
}
@@ -219,10 +252,10 @@ pub fn baseline_http_transport_test(c: &mut Criterion) {
219252
// Main benchmark configuration
220253
criterion_group!(name=http_transport_benchmarks;
221254
config=Criterion::default()
222-
.sample_size(100)
255+
.sample_size(500)
223256
.warm_up_time(std::time::Duration::new(10, 0))
224-
.measurement_time(std::time::Duration::new(50, 0));
225-
targets=simple_http_transport_test, disable_pooling_http_transport_test, baseline_http_transport_test
257+
.measurement_time(std::time::Duration::new(60, 0));
258+
targets=simple_http_transport_test, disable_pooling_http_transport_test, baseline_http_transport_test, raw_reqwest_http_transport_test
226259
);
227260

228261
criterion_main!(http_transport_benchmarks);

sdk/core/azure_core_test/src/perf/README.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,22 @@ Before you can declare your test pipeline, you need to create some infrastructur
159159

160160
Test pipelines are defined using a [`perf.yml`](https://github.com/Azure/azure-sdk-for-rust/blob/main/sdk/storage/azure_storage_blob/perf.yml) file declared in the package directory.
161161

162-
For example, from the `storage/azure_storage_blob` package:
162+
For example (from the `storage/azure_storage_blob` package):
163163

164164
```yml
165+
trigger: none
166+
167+
pr: none
168+
169+
# Schedule the pipeline to run at UTC+7 Hours (Midnight Pacific time)
170+
schedules:
171+
- cron: "0 7 * * *"
172+
displayName: Daily midnight run.
173+
branches:
174+
include:
175+
- main
176+
always: true
177+
165178
parameters:
166179
- name: PackageVersions
167180
displayName: PackageVersions (regex of package versions to run)
@@ -199,9 +212,7 @@ extends:
199212
Profile: ${{ parameters.Profile }}
200213
```
201214
202-
***TODO Update this to include yml based triggers***
203-
204-
You'll want to configure the `ServiceDirectory` field to match the location of your package.
215+
You'll want to configure the `ServiceDirectory` field to match the location of your package, and tweak the default values for the variables to match your performance tests.
205216

206217
#### Performance Test Yaml Configuration
207218

@@ -251,7 +262,8 @@ And FINALLY, you need to create a pull request containing this file and find the
251262

252263
#### Creating the performance pipeline
253264

254-
Once the pull request
265+
Once the pull request you created above has been committed to the branch, you can start to create the performance pipelines (note: DO NOT ATTEMPT TO CREATE THE PIPELINE UNTIL THE `perf.yml` file mentioned above is in `main` - if you don't, you are highly likely to disrupt all operations in the repository).
266+
255267
Navigate to the `azure-sdk` Azure DevOps instance, and select the `internal` project.
256268

257269
Within the `internal` project, select `Pipelines`, select "All" from the right hand pane. This will show a tree structured hierarchy of pipelines.
@@ -268,4 +280,34 @@ Next select `Azure/azure-sdk-for-rust` to specify the Rust SDK and configure you
268280

269281
Select your pipeline file from the main branch of the repository and you're almost done.
270282

271-
The next thing you want to do is to "save" the new pipeline.
283+
The next thing you want to do is to "save" the new pipeline. This will cause your pipeline to be created. You can also attempt to `run` the pipeline at this point but it is likely to fail.
284+
285+
You now need to set the required variables or the pipeline. Performance pipelines require the `Secrets for Resource Provisioner` variable group added to the pipeline. To add this, select the newly created pipeline, and click on `Edit`. Navigate to the `...` menu and select `Triggers`. This brings up the `Yaml`, `Variables`, `Triggers` and `History` edit. Make sure that all the triggers (included scheduled triggers) are cleared from the `Triggers` - Rust performance pipeline triggers are managed by the pipeline yaml file, rather than in the Azure DevOps user interface.
286+
287+
Select `Variables`, which allows you to add variables to the pipeline. You want to select `Variable groups` in the left hand column and select `Link variable group` in the right hand column.
288+
289+
That will bring up a pane on the right with a number of variable groups. You want to select the `Secrets for Resource Provisioner` variable group and click the `Link` button.
290+
291+
Once you've saved these changes, your pipeline should be ready to run.
292+
293+
You may need to ask for help from the Azure SDK Engineering Systems team to enable access to test resources for your pipeline.
294+
295+
## Running the test automation locally
296+
297+
It is possible to run the performance test automation locally, that is often helpful when debugging performance tests.
298+
299+
Running the performance tests locally requires a clone of the `Azure/azure-sdk-tools` repo.
300+
301+
Start at the root of the `azure-sdk-tools` repo and navigate to the `tools/perf-automation/Azure.Sdk.Tools/PerfAutomation` directory:
302+
303+
```bash
304+
cd tools/perf-automation/Azure.Sdk.Tools/PerfAutomation
305+
```
306+
307+
Then run the perf automation tool, replacing your repo on the command line:
308+
309+
```bash
310+
dotnet run . -- -l rust --language-version N/A --tests-file {Path to perf-tests.yml file in your repo} --repo-root {Path to the root of your repo}
311+
```
312+
313+
This will run your performance tests and save the results in the `results` directory locally.

sdk/core/azure_core_test/src/perf/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl PerfRunner {
505505
.arg(
506506
clap::arg!(--"test-results" <FILE> "The file to write test results to")
507507
.required(false)
508-
.default_value("./tests/results.json")
508+
.default_value("./results.json")
509509
.global(false),
510510
)
511511
.arg(clap::arg!(--"no-cleanup" "Disable test cleanup")

sdk/keyvault/azure_security_keyvault_keys/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ rustc_version.workspace = true
4242
[lints]
4343
workspace = true
4444

45-
[[bench]]
46-
name = "benchmarks"
45+
[[test]]
46+
name = "perf"
47+
path = "perf/perf_tests.rs"
4748
harness = false

0 commit comments

Comments
 (0)