# Capacity sweep — `loadr sweep` runs ONE plan across a parameter matrix and
# tabulates p50/p95/p99, error rate and RPS side by side, one row per combo:
#
#   loadr sweep examples/45-sweep.yaml --var vus=10,25,50 --duration 30s
#
# Repeated --var axes multiply into a cartesian matrix. Every value is
# exported to the plan's environment as LOADR_SWEEP_<NAME> (and `vus` /
# `duration` additionally map onto the run overrides), so custom knobs are
# plain ${env.*} / __ENV reads:
#
#   loadr sweep examples/45-sweep.yaml \
#     --var vus=10,50 --var page_size=25,100 \
#     --out-dir sweep-results --markdown sweep.md
#
# Per-combo summary exports land in --out-dir (default: loadr-sweep/), so any
# two cells of the matrix can be diffed later with `loadr compare`.
name: sweep
description: one plan swept across a vus x page_size matrix to find the knee

defaults:
  http:
    base_url: https://httpbin.org
    timeout: 10s

scenarios:
  browse:
    executor: constant-vus
    vus: 10          # overridden per combo by --var vus=...
    duration: 1m     # overridden by --duration or --var duration=...
    flow:
      - request:
          name: search
          # The swept knob, with a fallback so the plan also runs standalone.
          url: "/get?page_size=${js: __ENV.LOADR_SWEEP_PAGE_SIZE || 25}"
          checks:
            - { type: status, equals: 200 }

thresholds:
  http_req_failed: [ "rate<0.01" ]
