Skip to content

Commit

Permalink
Add an uptime test
Browse files Browse the repository at this point in the history
  • Loading branch information
olix0r committed Dec 2, 2023
1 parent 52c9dd5 commit 9aa6841
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions linkerd/metrics/src/uptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@ impl prom::core::Collector for Uptime {
self.metric.collect()
}
}

#[cfg(test)]
mod tests {
use super::*;
use prom::core::Collector;
use tokio::time;

#[tokio::test(flavor = "current_thread", start_paused = true)]
async fn test_uptime() {
let uptime = Uptime::default();

time::sleep(time::Duration::from_secs(10)).await;

assert_eq!(
uptime.collect()[0].get_metric()[0].get_gauge().get_value(),
10.0,
"Uptime should increase over time"
);
}
}

0 comments on commit 9aa6841

Please sign in to comment.