-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_inside_container.sh
More file actions
executable file
·63 lines (53 loc) · 1.97 KB
/
test_inside_container.sh
File metadata and controls
executable file
·63 lines (53 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#
# Test from inside the container (bypasses ALL external layers)
# This gives you the TRUE performance of Django/Gunicorn
# Usage: ./test_inside_container.sh [CONTAINER_NAME] [REQUESTS] [CONCURRENCY]
#
CONTAINER_NAME=${1:-amplicon-prod}
REQUESTS=${2:-100}
CONCURRENCY=${3:-10}
echo "=================================================="
echo " Inside-Container Performance Test"
echo "=================================================="
echo "Container: $CONTAINER_NAME"
echo "Requests: $REQUESTS"
echo "Concurrency: $CONCURRENCY"
echo "=================================================="
echo ""
# Check if container is running
if ! docker ps | grep -q "$CONTAINER_NAME"; then
echo "Error: Container '$CONTAINER_NAME' is not running"
echo ""
echo "Available containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
exit 1
fi
echo "Installing test dependencies inside container..."
docker exec "$CONTAINER_NAME" /bin/bash -c "source /opt/venv/bin/activate && pip install requests 2>/dev/null" || true
echo ""
echo "Copying test script to container..."
docker cp performance_test.py "$CONTAINER_NAME:/tmp/performance_test.py"
echo ""
echo "Running test from INSIDE the container..."
echo "This bypasses load balancers, CloudFront, SSL, etc."
echo "Testing: http://localhost:8000/"
echo ""
docker exec "$CONTAINER_NAME" /bin/bash -c "
source /opt/venv/bin/activate
cd /tmp
python performance_test.py \
--url http://localhost:8000/ \
--requests $REQUESTS \
--concurrency $CONCURRENCY
"
echo ""
echo "=================================================="
echo "Gunicorn Process Information"
echo "=================================================="
docker exec "$CONTAINER_NAME" ps aux | grep -E 'gunicorn|PID' || echo "No gunicorn processes found"
echo ""
echo "=================================================="
echo "Container Resource Usage"
echo "=================================================="
docker stats "$CONTAINER_NAME" --no-stream