Skip to content

Commit

Permalink
rt_basic_throttling: temp: display elapsed to investigate CI failure
Browse files Browse the repository at this point in the history
  • Loading branch information
fengalin committed Dec 23, 2019
1 parent 0088ab7 commit 1178fb9
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions tokio/tests/rt_basic_throttling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ use std::time::{Duration, Instant};

const MAX_THROTTLING: Duration = Duration::from_millis(100);

// One time frame duration
//
// Depending on when the `delay` is created, it might be fired either:
//
// - at the beginning of time frame tf2
//
// tf1 tf2 tf3
// |--:--|--:--|--:--|...
// ^---x
// <-dur->
//
//
// - or, at the beginning of tme frame tf3
//
// tf1 tf2 tf3
// |--:--|--:--|--:--|...
// ^-------x
// <-dur->

#[test]
fn delay_at_root_one_time_frame() {
let mut rt = rt();
Expand All @@ -27,7 +46,9 @@ fn delay_at_root_one_time_frame() {
assert!(elapsed + (MAX_THROTTLING / 2) >= dur);
// delay is created during the first time frame
// and must be fired at the beginning of the next time frame
assert!(elapsed < dur + MAX_THROTTLING);
// FIXME: temp.: display elapsed in CI, restore proper test afterward
//assert!(elapsed < dur + MAX_THROTTLING);
assert_eq!(elapsed, dur + MAX_THROTTLING);
}

#[test]
Expand All @@ -53,9 +74,29 @@ fn delay_in_spawn_one_time_frame() {
assert!(elapsed + (MAX_THROTTLING / 2) >= dur);
// delay is created during the first time frame
// and must be fired at the beginning of the next time frame
assert!(elapsed < dur + MAX_THROTTLING);
// FIXME: temp.: display elapsed in CI, restore proper test afterward
//assert!(elapsed < dur + MAX_THROTTLING);
assert_eq!(elapsed, dur + MAX_THROTTLING);
}

// Two time frames duration
//
// Depending on when the `delay` is created, it might be fired either:
//
// - at the beginning of time frame tf3
//
// tf1 tf2 tf3 tf4
// |--:--|--:--|--:--|--:--|...
// ^---------x
// <----dur---->
//
// - or, at the beginning of tme frame tf4
//
// tf1 tf2 tf3 tf4
// |--:--|--:--|--:--|--:--|...
// ^-------------x
// <----dur---->

#[test]
fn delay_at_root_two_time_frames() {
let mut rt = rt();
Expand All @@ -73,7 +114,9 @@ fn delay_at_root_two_time_frames() {
assert!(elapsed + (MAX_THROTTLING / 2) >= dur);
// delay is created during the first time frame
// and must be fired after the end of next time frame
assert!(elapsed < dur + MAX_THROTTLING);
// FIXME: temp.: display elapsed in CI, restore proper test afterward
//assert!(elapsed < dur + MAX_THROTTLING);
assert_eq!(elapsed, dur + MAX_THROTTLING);
}

#[test]
Expand All @@ -99,7 +142,9 @@ fn delay_in_spawn_two_time_frames() {
assert!(elapsed + (MAX_THROTTLING / 2) >= dur);
// delay is created during the first time frame
// and must be fired after the end of next time frame
assert!(elapsed < dur + MAX_THROTTLING);
// FIXME: temp.: display elapsed in CI, restore proper test afterward
//assert!(elapsed < dur + MAX_THROTTLING);
assert_eq!(elapsed, dur + MAX_THROTTLING);
}

fn rt() -> Runtime {
Expand Down

0 comments on commit 1178fb9

Please sign in to comment.