Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Tests: the slow-flush case measured against the same download without it (part of #518) (#526)

Ahmed Nefzaoui268383d313ad
diff --git a/ROADMAP.md b/ROADMAP.md
index 78cc59c5..c81db95e 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -520,6 +520,8 @@ These ship in a later version, when they're ready.
### Bugs being looked into
+- 🔄 Two tests that fail now and then on busy CI runners
+ ([#518](https://github.com/anefzaoui/misterdownloadmanager/issues/518)): the slow-flush one in review
- 🔄 The window not answering for a few seconds while Windows makes a snapshot of the disk
(a restore point or a backup) ([#513](https://github.com/anefzaoui/misterdownloadmanager/issues/513)):
the log and the RSS feeds are now written beside the window, as the list already was; fix in
diff --git a/crates/engine/tests/e2e.rs b/crates/engine/tests/e2e.rs
index 51369be6..eb94e34d 100644
--- a/crates/engine/tests/e2e.rs
+++ b/crates/engine/tests/e2e.rs
@@ -1629,6 +1629,28 @@ async fn a_one_time_link_is_read_from_the_kept_answer() {
async fn a_slow_flush_does_not_stop_the_transfer() {
let s = server("rate=20M").await; // 8 connections, about 160 MB/s together
let dir = tempfile::tempdir().unwrap();
+ // The same download with a disk that never stalls, on this machine at this moment: the
+ // yardstick the slow flush is measured against (#518: a fixed limit failed on busy runners).
+ let started = std::time::Instant::now();
+ Download::start(
+ Request {
+ url: s.url("/gen/160M/a.bin?seed=518").parse().unwrap(),
+ headers: Default::default(),
+ dest: Destination::Dir(dir.path().to_owned()),
+ },
+ Options {
+ save_interval: std::time::Duration::from_millis(100),
+ ..fast_opts()
+ },
+ )
+ .wait()
+ .await
+ .expect("the yardstick download succeeds");
+ let yardstick = started.elapsed();
+ tokio::time::timeout(SETTLE, s.settled())
+ .await
+ .expect("every request ends");
+ let before = s.log().len();
let opts = Options {
save_interval: std::time::Duration::from_millis(100),
slow_flush: Some(mdm_engine::download::SlowFlush {
@@ -1658,10 +1680,14 @@ async fn a_slow_flush_does_not_stop_the_transfer() {
tokio::time::timeout(SETTLE, s.settled())
.await
.expect("every request ends");
- let log = s.log();
- // Unobstructed: about a second, flush included, up to 4 s when the whole suite shares the
- // machine. Before the fix: every tick's flush stalled all writes for 1.5 s, 7.6 s measured.
- assert!(took < std::time::Duration::from_secs(6), "took {took:?}");
+ let log = s.log().split_off(before);
+ // At most one 1.5 s flush more than the yardstick, with room for a busy machine. Before the
+ // fix every tick's flush stalled all writes for 1.5 s: 7.6 s measured against about 1 s, and
+ // more ticks the slower the machine, so the gap only grows.
+ assert!(
+ took < yardstick + std::time::Duration::from_millis(4500),
+ "took {took:?}, the same download without the slow flush {yardstick:?}"
+ );
// No connection reconnected because of the disk's stall: the probe, seven more, and the
// planner's closing splits only.
assert!(log.len() < 48, "{} requests: {log:?}", log.len());