#!/bin/bash
# AS4 Settlement Load Testing Script
# Basic load test using curl

set -e

BASE_URL="${AS4_BASE_URL:-http://localhost:3000}"
CONCURRENT="${AS4_LOAD_CONCURRENT:-10}"
REQUESTS="${AS4_LOAD_REQUESTS:-100}"

echo "========================================="
echo "AS4 Settlement Load Test"
echo "========================================="
echo "Base URL: $BASE_URL"
echo "Concurrent: $CONCURRENT"
echo "Total Requests: $REQUESTS"
echo ""

# Test health endpoint
echo "Testing health endpoint..."
time for i in $(seq 1 $REQUESTS); do
    curl -s "$BASE_URL/health" > /dev/null &
    if [ $((i % $CONCURRENT)) -eq 0 ]; then
        wait
    fi
done
wait

echo ""
echo "Load test complete!"
