-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathhealth_check.rs
More file actions
27 lines (26 loc) · 1.14 KB
/
health_check.rs
File metadata and controls
27 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::tests::utils::setup_test_app;
use test_harness::health_check;
use tokio::process::Command;
#[tokio::test]
async fn test_health_check() -> Result<(), Box<dyn std::error::Error>> {
let app = setup_test_app().await?;
eprintln!("App started");
let url = app.health_check_url();
assert!(health_check::wait_alive(&url, 10, 1).await);
assert!(health_check::wait_healthy(&url, 10, 1).await);
tokio::time::sleep(tokio::time::Duration::from_secs(20)).await;
assert!(health_check::wait_alive(&url, 10, 1).await);
assert!(health_check::wait_healthy(&url, 10, 1).await);
eprintln!("Pausing database");
let db_id = app
.db_docker_id()
.expect("Database Docker ID should be set");
Command::new("docker").args(["pause", &db_id]).spawn()?;
tokio::time::sleep(tokio::time::Duration::from_secs(15)).await;
assert!(!health_check::wait_healthy(&url, 10, 1).await);
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
eprintln!("Unpausing database");
Command::new("docker").args(["unpause", &db_id]).spawn()?;
assert!(health_check::wait_healthy(&url, 10, 1).await);
Ok(())
}