| 131 | } |
| 132 | |
| 133 | async function runIteration(index) { |
| 134 | const endpoints = [ |
| 135 | ["GET", "/api/health"], |
| 136 | ["GET", "/api/metrics"], |
| 137 | ["GET", "/api/simulators"], |
| 138 | ["GET", "/api/stream-quality"], |
| 139 | ]; |
| 140 | if (udid) { |
| 141 | endpoints.push(["GET", `/api/simulators/${encodeURIComponent(udid)}`]); |
| 142 | if (index % 5 === 0) { |
| 143 | endpoints.push([ |
| 144 | "POST", |
| 145 | `/api/simulators/${encodeURIComponent(udid)}/stream/refresh`, |
| 146 | {}, |
| 147 | ]); |
| 148 | } |
| 149 | if (mutating && index % 10 === 0) { |
| 150 | endpoints.push([ |
| 151 | "POST", |
| 152 | `/api/simulators/${encodeURIComponent(udid)}/action`, |
| 153 | { action: "touch", x: 0.5, y: 0.5, phase: "moved" }, |
| 154 | ]); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | const [method, path, body] = endpoints[index % endpoints.length]; |
| 159 | await request(method, path, body); |
| 160 | } |
| 161 | |
| 162 | async function assertHealthy() { |
| 163 | const health = await request("GET", "/api/health"); |