Skip to content

Commit ceff058

Browse files
authored
vortex-file: Spawn tasks via runtime instead of directly via tokio (#8711)
## Rationale for this change I upgraded to 0.78 and some automation we have that detects when dependencies use raw `tokio::spawn` got triggered. We need to control all spawn points, both for correctness testing and for instrumentation purposes. I realize that these spawns are in test code, but I thought since vortex already has the runtime abstractions, it wouldn't hurt to use them in the tests as well (admittedly our tooling is not crazily sophisticated so it can't distinguish whether it's testing code or not). ## What changes are included in this PR? Use `TokioRuntime` instead of raw `tokio::spawn` in tests. ## What APIs are changed? Are there any user-facing changes? n/a Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com>
1 parent a649d75 commit ceff058

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

vortex-file/src/segments/source.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,13 @@ mod tests {
468468
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
469469
async fn file_segment_source_panic_propagates_to_all_concurrent_readers() {
470470
let source = Arc::new(panicking_source());
471+
let handle = TokioRuntime::current();
471472
let reader_count = 8;
472473

473474
let readers: Vec<_> = (0..reader_count)
474475
.map(|_| {
475476
let source = Arc::clone(&source);
476-
tokio::spawn(async move {
477+
handle.spawn(async move {
477478
AssertUnwindSafe(source.request(SegmentId::from(0)))
478479
.catch_unwind()
479480
.await
@@ -488,7 +489,7 @@ mod tests {
488489

489490
let mut original_panics = 0;
490491
for reader in joined {
491-
match reader.expect("reader task panicked at the join boundary") {
492+
match reader {
492493
// The first reader to observe completion re-raises the original panic.
493494
Err(payload) => {
494495
assert!(
@@ -557,10 +558,11 @@ mod tests {
557558
RequestMetrics::new(&metrics, vec![]),
558559
));
559560

561+
let handle = TokioRuntime::current();
560562
let tasks: Vec<_> = (0..n)
561563
.map(|i| {
562564
let source = Arc::clone(&source);
563-
tokio::spawn(async move { source.request(SegmentId::from(i)).await })
565+
handle.spawn(async move { source.request(SegmentId::from(i)).await })
564566
})
565567
.collect();
566568

0 commit comments

Comments
 (0)