(
session,
url: str,
rng: random.Random,
results: list[Result],
test_start: float,
simple_ratio: float,
)
| 237 | |
| 238 | |
| 239 | async def _fire_one( |
| 240 | session, |
| 241 | url: str, |
| 242 | rng: random.Random, |
| 243 | results: list[Result], |
| 244 | test_start: float, |
| 245 | simple_ratio: float, |
| 246 | ) -> None: |
| 247 | if rng.random() < simple_ratio: |
| 248 | cmd = rng.choice(SIMPLE_CMDS) |
| 249 | else: |
| 250 | cmd = gen_bot_cmd(rng) |
| 251 | target = f"{url}/explain" |
| 252 | t0 = time.perf_counter() |
| 253 | try: |
| 254 | async with session.get(target, params={"cmd": cmd}, timeout=60) as resp: |
| 255 | body = await resp.read() |
| 256 | lat = (time.perf_counter() - t0) * 1000.0 |
| 257 | results.append( |
| 258 | Result( |
| 259 | ok=resp.status == 200, |
| 260 | status=resp.status, |
| 261 | latency_ms=lat, |
| 262 | bytes=len(body), |
| 263 | t_end_s=time.monotonic() - test_start, |
| 264 | ) |
| 265 | ) |
| 266 | except Exception as e: |
| 267 | lat = (time.perf_counter() - t0) * 1000.0 |
| 268 | results.append( |
| 269 | Result( |
| 270 | ok=False, |
| 271 | status=0, |
| 272 | latency_ms=lat, |
| 273 | bytes=0, |
| 274 | t_end_s=time.monotonic() - test_start, |
| 275 | err=str(e)[:80], |
| 276 | ) |
| 277 | ) |
| 278 | |
| 279 | |
| 280 | async def _closed_loop_worker( |
no test coverage detected