(repository: &std::path::Path, child: &mut Child)
| 115 | } |
| 116 | |
| 117 | fn wait_for_ping(repository: &std::path::Path, child: &mut Child) -> Value { |
| 118 | let deadline = Instant::now() + Duration::from_secs(5); |
| 119 | loop { |
| 120 | let output = run_owner(repository, "ping"); |
| 121 | if output.status.success() { |
| 122 | return serde_json::from_slice(&output.stdout).expect("parse ping response"); |
| 123 | } |
| 124 | if let Some(status) = child.try_wait().expect("inspect owner process") { |
| 125 | let mut stderr = String::new(); |
| 126 | child |
| 127 | .stderr |
| 128 | .take() |
| 129 | .expect("owner stderr") |
| 130 | .read_to_string(&mut stderr) |
| 131 | .expect("read owner stderr"); |
| 132 | panic!("database owner exited with {status}: {stderr}"); |
| 133 | } |
| 134 | assert!( |
| 135 | Instant::now() < deadline, |
| 136 | "database owner did not become healthy: {}", |
| 137 | String::from_utf8_lossy(&output.stderr) |
| 138 | ); |
| 139 | thread::sleep(Duration::from_millis(25)); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | fn reserve(repository: &std::path::Path) -> Value { |
| 144 | let output = command_output( |
no test coverage detected