| 1 | #!/bin/sh |
| 2 | # Steady traffic through the gateway, until Ctrl+C, so the dashboards have |
| 3 | # something to show: a new user checks their balance twice a second, just |
| 4 | # under the gateway's limit. Episode 15 load-tests properly, with k6. |
| 5 | set -eu |
| 6 | api=http://localhost:8080 |
| 7 | user="{\"email\": \"load-$(date +%s)@example.com\", \"password\": \"a load test password\"}" |
| 8 | curl -sf "$api/v1/auth/register" -d "$user" >/dev/null |
| 9 | token=$(curl -sf "$api/v1/auth/login" -d "$user" | jq -r .access_token) |
| 10 | wallet=$(curl -sf "$api/v1/wallets" -H "Authorization: Bearer $token" -d '{"currency": "USD"}' | jq -r .id) |
| 11 | echo "checking the balance of wallet $wallet twice a second, until Ctrl+C" |
| 12 | while true; do |
| 13 | curl -s -o /dev/null -H "Authorization: Bearer $token" "$api/v1/wallets/$wallet/balance" |
| 14 | sleep 0.5 |
| 15 | done |