#!/bin/bash
echo "=== Stress Testing ==="
echo "1. Rapid Fire (50 requests)"
time for i in {1..50}; do
curl -s http://localhost:9100/rpa/status > /dev/null
done
echo
echo "2. Large Loop (1000 iterations)"
time curl -s -X POST http://localhost:9100/advanced/execute -H "Content-Type: application/json" -d "{\"steps\":[{\"action\":\"loop\",\"times\":1000,\"steps\":[{\"action\":\"set-var\",\"name\":\"i\",\"value\":\"1\"}]}]}" | head -10
echo
echo "3. Deep Nesting (loop in loop)"
curl -s -X POST http://localhost:9100/advanced/execute -H "Content-Type: application/json" -d "{\"steps\":[{\"action\":\"loop\",\"times\":5,\"steps\":[{\"action\":\"loop\",\"times\":5,\"steps\":[{\"action\":\"set-var\",\"name\":\"x\",\"value\":\"1\"}]}]}]}"
echo
echo "4. Memory After Stress"
ps aux | grep "rpa-service" | grep -v grep | awk "{print \"Memory: \" \$6/1024 \"MB | CPU: \" \$3\"%\"}"