( vm: VmHandle, port: number, attempts = 60, )
| 30 | * is up, not just the browser endpoint. On a cold guest the page appears a good |
| 31 | * bit after the port opens, so gating on this makes the scenario deterministic. */ |
| 32 | export const waitGuestPageTarget = async ( |
| 33 | vm: VmHandle, |
| 34 | port: number, |
| 35 | attempts = 60, |
| 36 | ): Promise<boolean> => { |
| 37 | for (let i = 0; i < attempts; i++) { |
| 38 | const r = await vm.ssh( |
| 39 | `curl -s --max-time 5 http://127.0.0.1:${port}/json/list 2>/dev/null | grep -c '"type": "page"' || echo 0`, |
| 40 | ); |
| 41 | if (Number(r.stdout.trim() || "0") > 0) return true; |
| 42 | await sleep(2000); |
| 43 | } |
| 44 | return false; |
| 45 | }; |
| 46 | |
| 47 | export interface ProvisionedGuest { |
| 48 | readonly ip: string; |
no test coverage detected