# Scenario lifecycle hooks + a custom summary report.
#
# Each VU logs in once via the scenario `on_start` hook, runs its `exec`
# function every iteration, then logs out once via `on_stop` when it retires.
# After the run, the exported handleSummary(data) function prints a custom
# end-of-run report instead of the default console summary (k6-compatible).
name: lifecycle-hooks
description: per-VU on_start/on_stop and a custom handleSummary report

defaults:
  http:
    base_url: https://api.example.com

js:
  file: scripts/lifecycle.js

scenarios:
  users:
    executor: constant-vus
    vus: 5
    duration: 30s
    on_start: login     # once per VU, before its first iteration
    exec: browse        # once per iteration
    on_stop: logout     # once per VU, when it retires

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