Skip to content

Commit b244673

Browse files
[TEST] Add test about batch processor with current_thread async runtime (#2123)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
1 parent c93cf26 commit b244673

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

opentelemetry-sdk/src/logs/log_processor.rs

+60
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,66 @@ mod tests {
812812
assert_eq!(1, exporter.get_emitted_logs().unwrap().len())
813813
}
814814

815+
#[tokio::test(flavor = "current_thread")]
816+
#[ignore = "See issue https://github.com/open-telemetry/opentelemetry-rust/issues/1968"]
817+
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_multi_thread() {
818+
let exporter = InMemoryLogsExporterBuilder::default()
819+
.keep_records_on_shutdown()
820+
.build();
821+
let processor = BatchLogProcessor::new(
822+
Box::new(exporter.clone()),
823+
BatchConfig::default(),
824+
runtime::Tokio,
825+
);
826+
827+
//
828+
// deadloack happens in shutdown with tokio current_thread runtime
829+
//
830+
processor.shutdown().unwrap();
831+
}
832+
833+
#[tokio::test(flavor = "current_thread")]
834+
async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_current_thread() {
835+
let exporter = InMemoryLogsExporterBuilder::default()
836+
.keep_records_on_shutdown()
837+
.build();
838+
let processor = BatchLogProcessor::new(
839+
Box::new(exporter.clone()),
840+
BatchConfig::default(),
841+
runtime::TokioCurrentThread,
842+
);
843+
844+
processor.shutdown().unwrap();
845+
}
846+
847+
#[tokio::test(flavor = "multi_thread")]
848+
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_multi_thread() {
849+
let exporter = InMemoryLogsExporterBuilder::default()
850+
.keep_records_on_shutdown()
851+
.build();
852+
let processor = BatchLogProcessor::new(
853+
Box::new(exporter.clone()),
854+
BatchConfig::default(),
855+
runtime::Tokio,
856+
);
857+
858+
processor.shutdown().unwrap();
859+
}
860+
861+
#[tokio::test(flavor = "multi_thread")]
862+
async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_current_thread() {
863+
let exporter = InMemoryLogsExporterBuilder::default()
864+
.keep_records_on_shutdown()
865+
.build();
866+
let processor = BatchLogProcessor::new(
867+
Box::new(exporter.clone()),
868+
BatchConfig::default(),
869+
runtime::TokioCurrentThread,
870+
);
871+
872+
processor.shutdown().unwrap();
873+
}
874+
815875
#[derive(Debug)]
816876
struct FirstProcessor {
817877
pub(crate) logs: Arc<Mutex<Vec<(LogRecord, InstrumentationLibrary)>>>,

0 commit comments

Comments
 (0)