mirror of
https://github.com/lahfir/agent-desktop.git
synced 2026-07-27 01:22:16 +00:00
test: make deadline metrics scheduler-independent
This commit is contained in:
parent
80866d5021
commit
aedb0c0be5
3 changed files with 22 additions and 8 deletions
|
|
@ -47,11 +47,13 @@ fn changing_inventory_retries_until_two_consecutive_captures_match() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn persistent_window_churn_times_out_with_attempt_metrics() {
|
||||
fn persistent_window_churn_times_out_with_exact_attempt_metrics() {
|
||||
let mut visible = false;
|
||||
let mut attempts = 0_u64;
|
||||
let error = stabilize_records_until(
|
||||
Instant::now() + std::time::Duration::from_millis(20),
|
||||
|| {
|
||||
attempts += 1;
|
||||
visible = !visible;
|
||||
Ok(records_fixture(visible))
|
||||
},
|
||||
|
|
@ -60,8 +62,12 @@ fn persistent_window_churn_times_out_with_attempt_metrics() {
|
|||
|
||||
assert_eq!(error.code, ErrorCode::Timeout);
|
||||
let details = error.details.unwrap();
|
||||
assert!(details["attempts"].as_u64().unwrap() >= 2);
|
||||
assert!(details["churn_events"].as_u64().unwrap() >= 1);
|
||||
assert!(attempts >= 1);
|
||||
assert_eq!(details["attempts"].as_u64(), Some(attempts));
|
||||
assert_eq!(
|
||||
details["churn_events"].as_u64(),
|
||||
Some(attempts.saturating_sub(1))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::*;
|
||||
|
||||
const PROCESS_TIMEOUT: Duration = Duration::from_millis(300);
|
||||
const PROCESS_TEST_LIMIT: Duration = Duration::from_secs(1);
|
||||
const PROCESS_TIMEOUT: Duration = Duration::from_secs(1);
|
||||
const PROCESS_TEST_LIMIT: Duration = Duration::from_secs(2);
|
||||
|
||||
fn process_exists(process: i32) -> bool {
|
||||
unsafe extern "C" {
|
||||
|
|
|
|||
|
|
@ -264,15 +264,23 @@ fn stabilization_retries_churn_and_preserves_strict_failures() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn persistent_owner_churn_times_out_with_attempt_metrics() {
|
||||
fn persistent_owner_churn_times_out_with_exact_attempt_metrics() {
|
||||
let mut attempts = 0_u64;
|
||||
let error = stabilize_global_with(
|
||||
Instant::now() + std::time::Duration::from_millis(20),
|
||||
|| Err(owner_churn_error(None, "test")),
|
||||
|| {
|
||||
attempts += 1;
|
||||
Err(owner_churn_error(None, "test"))
|
||||
},
|
||||
)
|
||||
.unwrap_err();
|
||||
|
||||
assert_eq!(error.code, ErrorCode::Timeout);
|
||||
assert!(error.details.unwrap()["attempts"].as_u64().unwrap() >= 2);
|
||||
let details = error.details.unwrap();
|
||||
assert!(attempts >= 1);
|
||||
assert_eq!(details["attempts"].as_u64(), Some(attempts));
|
||||
assert_eq!(details["last_code"], "APP_UNRESPONSIVE");
|
||||
assert_eq!(details["last_kind"], "global_window_owner_churn");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue