(&self)
| 150 | } |
| 151 | |
| 152 | async fn wait_until_ready(&self) -> Result<(), String> { |
| 153 | let container_id = self.container_id.clone(); |
| 154 | let engine = self.engine.clone(); |
| 155 | timeout(Duration::from_secs(60), async move { |
| 156 | let mut tick = interval(Duration::from_millis(500)); |
| 157 | loop { |
| 158 | tick.tick().await; |
| 159 | let output = engine |
| 160 | .command() |
| 161 | .args([ |
| 162 | "exec", |
| 163 | &container_id, |
| 164 | "python3", |
| 165 | "-c", |
| 166 | "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000', timeout=1).read()", |
| 167 | ]) |
| 168 | .output() |
| 169 | .ok(); |
| 170 | if output.is_some_and(|o| o.status.success()) { |
| 171 | return; |
| 172 | } |
| 173 | } |
| 174 | }) |
| 175 | .await |
| 176 | .map_err(|_| { |
| 177 | format!( |
| 178 | "{} test server did not become ready within 60s", |
| 179 | self.engine.name() |
| 180 | ) |
| 181 | }) |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | fn normalized_env(value: Option<&str>) -> Option<String> { |
no test coverage detected