Try reducing flakiness of fs-event tests by bumping timeout to 4s on CI (#42960)
Release Notes: - N/A
This commit is contained in:
@@ -395,19 +395,19 @@ mod tests {
|
|||||||
thread::spawn(move || stream.run(move |events| tx.send(events.to_vec()).is_ok()));
|
thread::spawn(move || stream.run(move |events| tx.send(events.to_vec()).is_ok()));
|
||||||
|
|
||||||
fs::write(path.join("new-file"), "").unwrap();
|
fs::write(path.join("new-file"), "").unwrap();
|
||||||
let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();
|
let events = rx.recv_timeout(timeout()).unwrap();
|
||||||
let event = events.last().unwrap();
|
let event = events.last().unwrap();
|
||||||
assert_eq!(event.path, path.join("new-file"));
|
assert_eq!(event.path, path.join("new-file"));
|
||||||
assert!(event.flags.contains(StreamFlags::ITEM_CREATED));
|
assert!(event.flags.contains(StreamFlags::ITEM_CREATED));
|
||||||
|
|
||||||
fs::remove_file(path.join("existing-file-5")).unwrap();
|
fs::remove_file(path.join("existing-file-5")).unwrap();
|
||||||
let mut events = rx.recv_timeout(Duration::from_secs(2)).unwrap();
|
let mut events = rx.recv_timeout(timeout()).unwrap();
|
||||||
let mut event = events.last().unwrap();
|
let mut event = events.last().unwrap();
|
||||||
// we see this duplicate about 1/100 test runs.
|
// we see this duplicate about 1/100 test runs.
|
||||||
if event.path == path.join("new-file")
|
if event.path == path.join("new-file")
|
||||||
&& event.flags.contains(StreamFlags::ITEM_CREATED)
|
&& event.flags.contains(StreamFlags::ITEM_CREATED)
|
||||||
{
|
{
|
||||||
events = rx.recv_timeout(Duration::from_secs(2)).unwrap();
|
events = rx.recv_timeout(timeout()).unwrap();
|
||||||
event = events.last().unwrap();
|
event = events.last().unwrap();
|
||||||
}
|
}
|
||||||
assert_eq!(event.path, path.join("existing-file-5"));
|
assert_eq!(event.path, path.join("existing-file-5"));
|
||||||
@@ -440,13 +440,13 @@ mod tests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fs::write(path.join("new-file"), "").unwrap();
|
fs::write(path.join("new-file"), "").unwrap();
|
||||||
let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();
|
let events = rx.recv_timeout(timeout()).unwrap();
|
||||||
let event = events.last().unwrap();
|
let event = events.last().unwrap();
|
||||||
assert_eq!(event.path, path.join("new-file"));
|
assert_eq!(event.path, path.join("new-file"));
|
||||||
assert!(event.flags.contains(StreamFlags::ITEM_CREATED));
|
assert!(event.flags.contains(StreamFlags::ITEM_CREATED));
|
||||||
|
|
||||||
fs::remove_file(path.join("existing-file-5")).unwrap();
|
fs::remove_file(path.join("existing-file-5")).unwrap();
|
||||||
let events = rx.recv_timeout(Duration::from_secs(2)).unwrap();
|
let events = rx.recv_timeout(timeout()).unwrap();
|
||||||
let event = events.last().unwrap();
|
let event = events.last().unwrap();
|
||||||
assert_eq!(event.path, path.join("existing-file-5"));
|
assert_eq!(event.path, path.join("existing-file-5"));
|
||||||
assert!(event.flags.contains(StreamFlags::ITEM_REMOVED));
|
assert!(event.flags.contains(StreamFlags::ITEM_REMOVED));
|
||||||
@@ -477,11 +477,11 @@ mod tests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fs::write(path.join("new-file"), "").unwrap();
|
fs::write(path.join("new-file"), "").unwrap();
|
||||||
assert_eq!(rx.recv_timeout(Duration::from_secs(2)).unwrap(), "running");
|
assert_eq!(rx.recv_timeout(timeout()).unwrap(), "running");
|
||||||
|
|
||||||
// Dropping the handle causes `EventStream::run` to return.
|
// Dropping the handle causes `EventStream::run` to return.
|
||||||
drop(handle);
|
drop(handle);
|
||||||
assert_eq!(rx.recv_timeout(Duration::from_secs(2)).unwrap(), "stopped");
|
assert_eq!(rx.recv_timeout(timeout()).unwrap(), "stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -500,11 +500,14 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn flush_historical_events() {
|
fn flush_historical_events() {
|
||||||
let duration = if std::env::var("CI").is_ok() {
|
thread::sleep(timeout());
|
||||||
Duration::from_secs(2)
|
}
|
||||||
|
|
||||||
|
fn timeout() -> Duration {
|
||||||
|
if std::env::var("CI").is_ok() {
|
||||||
|
Duration::from_secs(4)
|
||||||
} else {
|
} else {
|
||||||
Duration::from_millis(500)
|
Duration::from_millis(500)
|
||||||
};
|
}
|
||||||
thread::sleep(duration);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user