-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
106 lines (81 loc) · 3.88 KB
/
test.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
### CONFIG ###
workers=1 # Number of web servers workers
n=1000 # Apache2 bench: Requests count per test
c=10 # Apache2 bench: Concurrency requests
r=3 # Repeat count number
##############
docker stop fastapi_098 >/dev/null 2>&1
docker rm fastapi_098 >/dev/null 2>&1
docker stop fastapi_100 >/dev/null 2>&1
docker rm fastapi_100 >/dev/null 2>&1
echo "Build...."
docker build -t fastapi_098-test -f app098/Dockerfile .>/dev/null 2>&1
docker build -t fastapi_100-test -f app100/Dockerfile .>/dev/null 2>&1
docker build -t apache2_ab -f Dockerfile_test_client .>/dev/null 2>&1
echo "Testing fastapi_098..."
docker compose up -d fastapi_test_db fastapi_098 >/dev/null 2>&1
fastapi_098_mu=$(docker stats fastapi_098 --no-stream --format "{{.MemUsage}}" | cut -d '/' -f 1)
echo "Run ${n} Requests per iteration with concurrency ${c}...."
printf "before requests %15s\n" $fastapi_098_mu
printf "requests/second WRITE %13s \n" "fastapi_098"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_098_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -p test_post.json -T application/json -c 10 -n 1000 http://fastapi_098:8000/posts | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_098_rs_l
done
printf "requests/second READ DB %14s \n" "fastapi_098"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_098_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -n ${n} -c ${c} http://fastapi_098:8000/posts?per_page=100 | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_098_rs_l
done
printf "requests/second READ synthetic %14s \n" "fastapi_098"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_098_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -n ${n} -c ${c} http://fastapi_098:8000/posts_synthetic?per_page=100 | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_098_rs_l
done
echo "sleeping 1"
sleep 1
fastapi_098_mu=$(docker stats fastapi_098 --no-stream --format "{{.MemUsage}}" | cut -d '/' -f 1)
printf "after requests %15s\n" $fastapi_098_mu
# #####################################################
echo "Cleaning before another test..."
docker compose down -v >/dev/null 2>&1
# #####################################################
echo "Testing fastapi_100..."
docker compose up -d fastapi_test_db fastapi_100 >/dev/null 2>&1
fastapi_100_mu=$(docker stats fastapi_100 --no-stream --format "{{.MemUsage}}" | cut -d '/' -f 1)
echo "Run ${n} Requests per iteration with concurrency ${c}...."
printf "before requests %15s\n" $fastapi_100_mu
printf "requests/second WRITE %13s \n" "fastapi_100"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_100_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -p test_post.json -T application/json -c 10 -n 1000 http://fastapi_100:8000/posts | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_100_rs_l
done
printf "requests/second READ %14s \n" "fastapi_100"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_100_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -n ${n} -c ${c} http://fastapi_100:8000/posts?per_page=100 | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_100_rs_l
done
printf "requests/second READ synthetic %14s \n" "fastapi_098"
for i in $(seq 1 $r)
do
sleep 0.2
fastapi_100_rs_l=$(docker run --network=fastapi_test apache2_ab sh -c "ab -q -n ${n} -c ${c} http://fastapi_100:8000/posts_synthetic?per_page=100 | grep 'Requests per second' | tr -dc '0-9.0-9'")
printf "#%s %15s\n" $i $fastapi_100_rs_l
done
echo "sleeping 1"
sleep 1
fastapi_100_mu=$(docker stats fastapi_100 --no-stream --format "{{.MemUsage}}" | cut -d '/' -f 1)
printf "after requests %15s\n" $fastapi_100_mu
echo "Cleanup...."
docker compose down -v >/dev/null 2>&1