mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 00:07:50 +00:00
test(plugins): repeat the cancel until the call is running in the cancel test
running_calls_can_be_cancelled cancelled once, 100 ms after starting the call. On a slow runner (Windows CI) the instance was still starting, so the cancel found nothing running and the call ran into its 30 s timeout. The test now repeats the cancel until the call ends, within 5 s.
This commit is contained in:
@@ -493,12 +493,15 @@ fn running_calls_can_be_cancelled() {
|
||||
let f = f.clone();
|
||||
std::thread::spawn(move || f.run("misbehave", "spin", None))
|
||||
};
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
let started = Instant::now();
|
||||
f.host.cancel("misbehave");
|
||||
// A cancel before the call runs (the instance may still be starting) does nothing: repeat it.
|
||||
let until = Instant::now() + Duration::from_secs(5);
|
||||
while !spinning.is_finished() {
|
||||
assert!(Instant::now() < until, "the running call wasn't interrupted");
|
||||
f.host.cancel("misbehave");
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
}
|
||||
let err = spinning.join().unwrap().unwrap_err();
|
||||
assert!(err.contains("was cancelled"), "{err}");
|
||||
assert!(started.elapsed() < Duration::from_secs(1));
|
||||
assert_eq!(f.run("misbehave", "echo", Some("x")).unwrap().as_deref(), Some("x"), "no backoff");
|
||||
let stats = f.host.info_of("misbehave").unwrap().stats;
|
||||
assert_eq!((stats.crashes, stats.activations), (0, 2));
|
||||
|
||||
Reference in New Issue
Block a user