Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement recorded::test macro for recorded tests #1926

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Replace test_e2e feature with recorded attribute macro
heaths committed Nov 22, 2024
commit 91412996f219361d084289b765ea7b0af46e9945
5 changes: 2 additions & 3 deletions sdk/eventhubs/azure_messaging_eventhubs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -32,12 +32,11 @@ rustc_version.workspace = true

[dev-dependencies]
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] }
azure_core_macros.workspace = true
azure_core_test.workspace = true
azure_identity.workspace = true
tokio = { workspace = true, default-features = false, features = [
"rt-multi-thread",
"macros",
"time",
] }

[features]
test_e2e = []
17 changes: 8 additions & 9 deletions sdk/eventhubs/azure_messaging_eventhubs/tests/consumer.rs
Original file line number Diff line number Diff line change
@@ -3,9 +3,8 @@

//cspell: words eventdata

#![cfg(all(test, feature = "test_e2e"))] // to run this, do: `cargo test --features test_e2e`

use async_std::future::timeout;
use azure_core_macros::recorded;
use azure_identity::DefaultAzureCredential;
use azure_messaging_eventhubs::consumer::{
ConsumerClient, ConsumerClientOptions, ReceiveOptions, StartPosition,
@@ -16,7 +15,7 @@ use tracing::{info, trace};

mod common;

#[tokio::test]
#[recorded(live)]
async fn test_new() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -33,7 +32,7 @@ async fn test_new() {
);
}

#[tokio::test]
#[recorded(live)]
async fn test_new_with_error() {
common::setup();
trace!("test_new_with_error");
@@ -53,7 +52,7 @@ async fn test_new_with_error() {
info!("Error: {:?}", result);
}

#[tokio::test]
#[recorded(live)]
async fn test_open() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -70,7 +69,7 @@ async fn test_open() {
);
client.open().await.unwrap();
}
#[tokio::test]
#[recorded(live)]
async fn test_close() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -89,7 +88,7 @@ async fn test_close() {
client.close().await.unwrap();
}

#[tokio::test]
#[recorded(live)]
async fn test_get_properties() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -113,7 +112,7 @@ async fn test_get_properties() {
assert_eq!(properties.name, eventhub);
}

#[tokio::test]
#[recorded(live)]
async fn test_get_partition_properties() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -144,7 +143,7 @@ async fn test_get_partition_properties() {
}
}

#[tokio::test]
#[recorded(live)]
async fn receive_lots_of_events() {
common::setup();

25 changes: 12 additions & 13 deletions sdk/eventhubs/azure_messaging_eventhubs/tests/producer.rs
Original file line number Diff line number Diff line change
@@ -3,12 +3,11 @@

//cspell: words eventdata amqp

#![cfg(all(test, feature = "test_e2e"))] // to run this, do: `cargo test --features test_e2e`

use azure_core_amqp::{
messaging::{AmqpMessage, AmqpMessageBody},
value::{AmqpList, AmqpValue},
};
use azure_core_macros::recorded;
use azure_identity::DefaultAzureCredential;
use azure_messaging_eventhubs::producer::{
batch::EventDataBatchOptions, ProducerClient, ProducerClientOptions,
@@ -18,7 +17,7 @@ use tracing::{info, trace};

mod common;

#[tokio::test]
#[recorded(live)]
async fn test_new() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -34,7 +33,7 @@ async fn test_new() {
);
}

#[tokio::test]
#[recorded(live)]
async fn test_new_with_error() {
common::setup();
let eventhub = env::var("EVENTHUB_NAME").unwrap();
@@ -52,7 +51,7 @@ async fn test_new_with_error() {
info!("Error: {:?}", result);
}

#[tokio::test]
#[recorded(live)]
async fn test_open() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -68,7 +67,7 @@ async fn test_open() {
);
client.open().await.unwrap();
}
#[tokio::test]
#[recorded(live)]
async fn test_close() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -86,7 +85,7 @@ async fn test_close() {
client.close().await.unwrap();
}

#[tokio::test]
#[recorded(live)]
async fn test_get_properties() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -109,7 +108,7 @@ async fn test_get_properties() {
assert_eq!(properties.name, eventhub);
}

#[tokio::test]
#[recorded(live)]
async fn test_get_partition_properties() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -139,7 +138,7 @@ async fn test_get_partition_properties() {
}
}

#[test]
#[recorded(live)]
fn test_create_eventdata() {
common::setup();
let data = b"hello world";
@@ -163,7 +162,7 @@ fn test_create_eventdata() {
.build();
}

#[tokio::test]
#[recorded(live)]
async fn test_create_batch() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -187,7 +186,7 @@ async fn test_create_batch() {
}
}

#[tokio::test]
#[recorded(live)]
async fn test_create_and_send_batch() {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -239,7 +238,7 @@ async fn test_create_and_send_batch() {
}
}

#[tokio::test]
#[recorded(live)]
async fn test_add_amqp_messages_to_batch() -> Result<(), Box<dyn std::error::Error>> {
common::setup();
let host = env::var("EVENTHUBS_HOST").unwrap();
@@ -316,7 +315,7 @@ async fn test_add_amqp_messages_to_batch() -> Result<(), Box<dyn std::error::Err
Ok(())
}

#[tokio::test]
#[recorded(live)]
async fn test_overload_batch() {
common::setup();

5 changes: 2 additions & 3 deletions sdk/eventhubs/azure_messaging_eventhubs/tests/round_trip.rs
Original file line number Diff line number Diff line change
@@ -3,13 +3,12 @@

//cspell: words eventdata amqp

#![cfg(all(test, feature = "test_e2e"))] // to run this, do: `cargo test --features test_e2e`

use async_std::stream::StreamExt;
use azure_core_amqp::{
messaging::{AmqpMessage, AmqpMessageProperties},
value::{AmqpList, AmqpValue},
};
use azure_core_macros::recorded;
use azure_identity::DefaultAzureCredential;
use azure_messaging_eventhubs::{
consumer::{
@@ -24,7 +23,7 @@ use tracing::info;

mod common;

#[tokio::test]
#[recorded(live)]
async fn test_round_trip_batch() {
const EVENTHUB_PARTITION: &str = "1";
const TEST_NAME: &str = "test_round_trip_batch";