#!/usr/bin/env bash
# Lab step 10: latency one call at a time, then a burst that meets the rate limit.
source /lab/env.sh
echo '{"actor":"lab-agent","action":"read_record","resource":{"customer":"42"},"confidence":0.99}' > /lab/read.json
AB="ab -q -p /lab/read.json -T application/json -H \"Authorization: Bearer $KEY\""
echo "#### 1,000 calls, one at a time"
eval $AB -n 1000 -c 1 $BASE/v1/agent/authorize | grep -E 'Complete|Non-2xx|Requests per second|Time per request|50%|95%|99%|100%'
echo "#### 10,000 calls, 50 at a time"
eval $AB -n 10000 -c 50 $BASE/v1/agent/authorize | grep -E 'Complete|Non-2xx|Requests per second|50%|95%|99%|100%'
