Environments

Scale & operations

Promote the same plan from local to staging to prod by switching an environment: base URLs, headers and secrets come from the environment, not the flow.

Browse all 52 demos 12 categories
Run it
$ loadr run examples/13-environments.yaml
examples/13-environments.yaml
# One test, many environments: `loadr run -e staging examples/13-environments.yaml`
# deep-merges the env block over the file. Secrets come from the process
# environment and are never printed.
name: environments
description: per-environment overrides and secrets

defaults:
  http:
    base_url: https://prod.example.com
    timeout: 10s

env:
  staging:
    defaults:
      http:
        base_url: https://staging.example.com
        tls: { insecure_skip_verify: true }   # staging has a self-signed cert
    scenarios:
      api: { vus: 2 }                          # gentler load on staging
  ci:
    scenarios:
      api: { vus: 1, duration: 10s }
    thresholds:
      http_req_duration: [ "p(95)<5000" ]      # CI machines are slow

secrets:
  api_key: { env: EXAMPLE_API_KEY }

variables:
  tenant: acme

scenarios:
  api:
    executor: constant-vus
    vus: 10
    duration: 2m
    flow:
      - request:
          name: tenant info
          url: /api/tenants/${vars.tenant}
          headers:
            X-Api-Key: ${secrets.api_key}
          checks:
            - { type: status, equals: 200 }

thresholds:
  http_req_duration: [ "p(95)<400" ]

View raw: examples/13-environments.yaml

What it shows

  • Per-environment config
  • Env vars + secrets
  • Same plan everywhere