Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1#!/bin/bash
2set -e
3
4API_KEY="$1"
5COUNT="${2:-5000}"
6BASE_URL="${3:-http://localhost:3000}"
7
8if [ -z "$API_KEY" ]; then
9 echo "Usage: bash load_test_reports.sh API_KEY [COUNT] [BASE_URL]"
10 echo " COUNT defaults to 5000, BASE_URL defaults to http://localhost:3000"
11 exit 1
12fi
13
14echo "=== Submitting $COUNT reports to $BASE_URL ==="
15
16for i in $(seq 1 "$COUNT"); do
17 GUID=$(uuidgen | tr '[:upper:]' '[:lower:]')
18 REPORTER_ID="usr$(openssl rand -hex 4)"
19 OWNER_ID="own$(openssl rand -hex 4)"
20
21 curl -s -o /dev/null -w "Report $i: %{http_code}\n" \
22 -X POST "$BASE_URL/api/v1/report" \
23 -H "Content-Type: application/json" \
24 -H "x-api-key: $API_KEY" \
25 -d "{\"reporter\":{\"kind\":\"user\",\"id\":\"$REPORTER_ID\",\"typeId\":\"502ec98c7e\"},\"reportedAt\":\"2026-03-24T12:00:00Z\",\"reportedItem\":{\"id\":\"$GUID\",\"typeId\":\"a8481310e8c\",\"data\":{\"text\":\"Load test post $i\",\"images\":[],\"owner_id\":{\"id\":\"$OWNER_ID\",\"typeId\":\"502ec98c7e\"},\"num_likes\":$((RANDOM % 100)),\"num_comments\":$((RANDOM % 50)),\"num_user_reports\":$((RANDOM % 20))}}}" &
26
27 if (( i % 10 == 0 )); then wait; echo " ... $i/$COUNT sent"; fi
28done
29wait
30echo "=== Done — $COUNT reports submitted ==="