Skip to content

Commit

Permalink
[TEST] Add test about batch processor with current_thread async runti…
Browse files Browse the repository at this point in the history
…me (#2123)

Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
ThomsonTan and cijothomas authored Sep 24, 2024
1 parent c93cf26 commit b244673
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,66 @@ mod tests {
assert_eq!(1, exporter.get_emitted_logs().unwrap().len())
}

#[tokio::test(flavor = "current_thread")]
#[ignore = "See issue https://github.com/open-telemetry/opentelemetry-rust/issues/1968"]
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_multi_thread() {
let exporter = InMemoryLogsExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
runtime::Tokio,
);

//
// deadloack happens in shutdown with tokio current_thread runtime
//
processor.shutdown().unwrap();
}

#[tokio::test(flavor = "current_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_current_thread() {
let exporter = InMemoryLogsExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
runtime::TokioCurrentThread,
);

processor.shutdown().unwrap();
}

#[tokio::test(flavor = "multi_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_multi_thread() {
let exporter = InMemoryLogsExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
runtime::Tokio,
);

processor.shutdown().unwrap();
}

#[tokio::test(flavor = "multi_thread")]
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_current_thread() {
let exporter = InMemoryLogsExporterBuilder::default()
.keep_records_on_shutdown()
.build();
let processor = BatchLogProcessor::new(
Box::new(exporter.clone()),
BatchConfig::default(),
runtime::TokioCurrentThread,
);

processor.shutdown().unwrap();
}

#[derive(Debug)]
struct FirstProcessor {
pub(crate) logs: Arc<Mutex<Vec<(LogRecord, InstrumentationLibrary)>>>,
Expand Down

0 comments on commit b244673

Please sign in to comment.