Skip to content

Commit cdd9dae

Browse files
fs: propagate iouring stress test failures (#8644)
1 parent 52ac781 commit cdd9dae

7 files changed

Lines changed: 22 additions & 28 deletions

File tree

‎.github/workflows/uring-kernel-version-test.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ jobs:
8080
mount -t proc proc /proc
8181
mount -t sysfs sysfs /sys
8282
mkdir -p /tmp && mount -t tmpfs -o mode=1777 tmpfs /tmp
83+
# The stress tests can open 10,000 files concurrently.
84+
ulimit -n 65536
8385
for f in /bin/tests/*; do RUST_BACKTRACE=1 "$f" ; done
8486
echo "ALL_TESTS_COMPLETED"
8587
EOF

‎tokio/Cargo.toml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ mockall = "0.13.0"
154154
async-stream = "0.3"
155155
futures-concurrency = "7.6.3"
156156

157-
[target.'cfg(not(target_os = "emscripten"))'.dev-dependencies]
158-
tokio-util = { version = "0.7", features = ["rt"] }
159-
160157
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
161158
socket2 = "0.6.0"
162159
proptest = "1"

‎tokio/tests/fs_uring.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use std::task::Poll;
1414
use std::time::Duration;
1515
use std::{future::poll_fn, path::PathBuf};
1616
use tempfile::NamedTempFile;
17+
use tokio::task::JoinSet;
1718
use tokio::{
1819
fs::OpenOptions,
1920
runtime::{Builder, Runtime},
2021
};
21-
use tokio_util::task::TaskTracker;
2222

2323
fn multi_rt(n: usize) -> Box<dyn Fn() -> Runtime> {
2424
Box::new(move || {
@@ -105,16 +105,15 @@ fn open_many_files() {
105105
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_files(NUM_FILES);
106106

107107
rt.block_on(async move {
108-
let tracker = TaskTracker::new();
108+
let mut tasks = JoinSet::new();
109109

110110
for i in 0..10_000 {
111111
let path = paths.get(i % NUM_FILES).unwrap().clone();
112-
tracker.spawn(async move {
112+
tasks.spawn(async move {
113113
let _file = OpenOptions::new().read(true).open(path).await.unwrap();
114114
});
115115
}
116-
tracker.close();
117-
tracker.wait().await;
116+
tasks.join_all().await;
118117
});
119118
}
120119

‎tokio/tests/fs_uring_file_read.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tempfile::NamedTempFile;
1818
use tokio::fs::File;
1919
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
2020
use tokio::runtime::{Builder, Runtime};
21-
use tokio_util::task::TaskTracker;
21+
use tokio::task::JoinSet;
2222

2323
fn multi_rt(n: usize) -> Box<dyn Fn() -> Runtime> {
2424
Box::new(move || {
@@ -255,21 +255,20 @@ async fn test_file_read_concurrent() {
255255
})
256256
.collect();
257257

258-
let tracker = TaskTracker::new();
258+
let mut tasks = JoinSet::new();
259259

260260
for (i, (_tmp, path)) in files.iter().enumerate() {
261261
let path = path.clone();
262262
let expected: Vec<u8> = (0..1024).map(|j| ((i as u16 + j) % 256) as u8).collect();
263-
tracker.spawn(async move {
263+
tasks.spawn(async move {
264264
let mut file = File::open(&path).await.unwrap();
265265
let mut buf = Vec::new();
266266
file.read_to_end(&mut buf).await.unwrap();
267267
assert_eq!(buf, expected);
268268
});
269269
}
270270

271-
tracker.close();
272-
tracker.wait().await;
271+
tasks.join_all().await;
273272
}
274273

275274
#[test]

‎tokio/tests/fs_uring_read.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::time::Duration;
1818
use tempfile::NamedTempFile;
1919
use tokio::fs::read;
2020
use tokio::runtime::{Builder, Runtime};
21+
use tokio::task::JoinSet;
2122
use tokio_test::assert_pending;
22-
use tokio_util::task::TaskTracker;
2323

2424
use crate::support::io_uring::uring_fs_op_in_use;
2525

@@ -107,17 +107,16 @@ fn read_many_files() {
107107
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_files(NUM_FILES);
108108

109109
rt.block_on(async move {
110-
let tracker = TaskTracker::new();
110+
let mut tasks = JoinSet::new();
111111

112112
for i in 0..10_000 {
113113
let path = paths.get(i % NUM_FILES).unwrap().clone();
114-
tracker.spawn(async move {
114+
tasks.spawn(async move {
115115
let bytes = read(path).await.unwrap();
116116
assert_eq!(bytes, vec![20; 1023]);
117117
});
118118
}
119-
tracker.close();
120-
tracker.wait().await;
119+
tasks.join_all().await;
121120
});
122121
}
123122

‎tokio/tests/fs_uring_rename.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use std::time::Duration;
1919
use tempfile::{tempdir, NamedTempFile};
2020
use tokio::fs::{rename, try_exists};
2121
use tokio::runtime::{Builder, Runtime};
22+
use tokio::task::JoinSet;
2223
use tokio_test::assert_pending;
23-
use tokio_util::task::TaskTracker;
2424

2525
use crate::support::io_uring::{io_uring_supported, uring_op_supported};
2626

@@ -107,22 +107,21 @@ fn rename_many_files() {
107107
let dir = tempdir().unwrap();
108108

109109
rt.block_on(async move {
110-
let tracker = TaskTracker::new();
110+
let mut tasks = JoinSet::new();
111111

112112
for i in 0..NUM_FILES {
113113
let src = dir.path().join(format!("src-{i}"));
114114
let dst = dir.path().join(format!("dst-{i}"));
115115
tokio::fs::write(&src, b"contents").await.unwrap();
116116

117-
tracker.spawn(async move {
117+
tasks.spawn(async move {
118118
rename(&src, &dst).await.unwrap();
119119

120120
assert!(!try_exists(&src).await.unwrap());
121121
assert!(try_exists(&dst).await.unwrap());
122122
});
123123
}
124-
tracker.close();
125-
tracker.wait().await;
124+
tasks.join_all().await;
126125
});
127126
}
128127

‎tokio/tests/fs_uring_statx.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use std::time::Duration;
2020
use tempfile::{tempdir, NamedTempFile};
2121
use tokio::fs::{create_dir, metadata, set_permissions, symlink, try_exists, write};
2222
use tokio::runtime::{Builder, Runtime};
23+
use tokio::task::JoinSet;
2324
use tokio_test::assert_pending;
24-
use tokio_util::task::TaskTracker;
2525

2626
use crate::support::io_uring::{io_uring_supported, uring_fs_op_in_use};
2727

@@ -108,17 +108,16 @@ fn stat_many_files() {
108108
let (_tmp_files, paths): (Vec<NamedTempFile>, Vec<PathBuf>) = create_tmp_files(NUM_FILES);
109109

110110
rt.block_on(async move {
111-
let tracker = TaskTracker::new();
111+
let mut tasks = JoinSet::new();
112112

113113
for i in 0..10_000 {
114114
let path = paths.get(i % NUM_FILES).unwrap().clone();
115-
tracker.spawn(async move {
115+
tasks.spawn(async move {
116116
let exists = try_exists(path).await.unwrap();
117117
assert!(exists);
118118
});
119119
}
120-
tracker.close();
121-
tracker.wait().await;
120+
tasks.join_all().await;
122121
});
123122
}
124123

0 commit comments

Comments
 (0)