Skip to content

Commit 1a613fd

Browse files
Converted perf tests to benches so they don't conflict with cargo tests (Azure#3257)
The command line for cargo test is passed to all tests if you're not specific, but clap based tests (like perf tests) get upset when they encounter command line parameters that are unknown. To avoid this, instead of using `[[test]]` to declare perf tests, use `[[bench]]`.
1 parent 6889761 commit 1a613fd

File tree

9 files changed

+13
-11
lines changed

9 files changed

+13
-11
lines changed

sdk/core/azure_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ required-features = ["xml"]
105105
name = "http_transport_benchmarks"
106106
harness = false
107107

108-
[[test]]
108+
[[bench]]
109109
name = "perf"
110110
path = "perf/perf.rs"
111111
harness = false

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Performance tests are defined in a "perf" directory under the package root.
77
By convention, all performance tests are named "perf" and are invoked via:
88

99
```bash
10-
cargo test --package <package name> --test perf -- {perf test name} {perf test arguments}
10+
cargo bench --package <package name> --bench perf -- {perf test name} {perf test arguments}
1111
```
1212

1313
where `package name` is the name of the rust package, `perf test name` is the name of the test you want to run, and `perf test arguments` is the arguments to that test.
@@ -70,7 +70,7 @@ The process of authoring tests starts with the cargo.toml file for your package.
7070
Add the following to the `cargo.toml` file:
7171

7272
```toml
73-
[[test]]
73+
[[bench]]
7474
name = "perf"
7575
path = "perf/get_secret.rs"
7676
harness = false
@@ -81,13 +81,13 @@ This declares a test named `perf` (which is required for the perf automation tes
8181
After this, to invoke your perf test, you simply use:
8282

8383
```bash
84-
cargo test --package azure_storage_blob --test perf -- {performance test command line}
84+
cargo bench --package azure_storage_blob --bench perf -- {performance test command line}
8585
```
8686

8787
For example,
8888

8989
```bash
90-
cargo test --package azure_storage_blob --test perf -- list_blob --help
90+
cargo bench --package azure_storage_blob --bench perf -- list_blob --help
9191
```
9292

9393
returns the help text for the `list_blob`test:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ impl PerfRunner {
509509
.value_parser(clap::value_parser!(i64))
510510
.global(true),
511511
)
512+
// Cargo bench passes --bench to the test binary to instruct it to run benchmarks only.
513+
.arg(clap::arg!(--bench).required(false).global(true))
512514
.arg(
513515
clap::arg!(--"test-results" <FILE> "The file to write test results to")
514516
.required(false)

sdk/core/typespec_macros/tests/data/safe-debug-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ zerofrom = "0.1.5"
2121
[dev-dependencies]
2222
rustc_version = "0.4.1"
2323

24-
[[test]]
24+
[[bench]]
2525
name = "debug"
2626
path = "tests/debug.rs"
2727
required-features = ["debug"]

sdk/keyvault/azure_security_keyvault_keys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ rustc_version.workspace = true
4242
[lints]
4343
workspace = true
4444

45-
[[test]]
45+
[[bench]]
4646
name = "perf"
4747
path = "perf/perf_tests.rs"
4848
harness = false

sdk/keyvault/azure_security_keyvault_keys/perf/perf_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! To run the test, use the following command line arguments:
1212
//!
13-
//! cargo test --package azure_security_keyvault_keys --test perf -- --duration 10 --parallel 20 get_key -u https://<my_vault>.vault.azure.net/
13+
//! cargo bench --package azure_security_keyvault_keys --bench perf -- --duration 10 --parallel 20 get_key -u https://<my_vault>.vault.azure.net/
1414
//!
1515
1616
mod create_key;

sdk/keyvault/azure_security_keyvault_secrets/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rustc_version.workspace = true
4141
[lints]
4242
workspace = true
4343

44-
[[test]]
44+
[[bench]]
4545
name = "perf"
4646
path = "perf/get_secret.rs"
4747
harness = false

sdk/keyvault/azure_security_keyvault_secrets/perf/get_secret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! To run the test, use the following command line arguments:
1212
//!
13-
//! cargo test --package azure_security_keyvault_secrets --test perf -- --duration 10 --parallel 20 get_secret -u https://<my_vault>.vault.azure.net/
13+
//! cargo bench --package azure_security_keyvault_secrets --bench perf -- --duration 10 --parallel 20 get_secret -u https://<my_vault>.vault.azure.net/
1414
//!
1515
1616
use std::sync::{Arc, OnceLock};

sdk/storage/azure_storage_blob/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ futures.workspace = true
3838
tokio = { workspace = true, features = ["macros"] }
3939
tracing.workspace = true
4040

41-
[[test]]
41+
[[bench]]
4242
name = "perf"
4343
path = "perf/perf_tests.rs"
4444
harness = false

0 commit comments

Comments
 (0)