-
Notifications
You must be signed in to change notification settings - Fork 0
/
siege_test.sh
executable file
·94 lines (76 loc) · 2.74 KB
/
siege_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
#!/bin/bash
SIEGE_CGI_URLS_FILE="urls_cgi.txt"
SIEGE_GET_URLS_FILE="urls_get.txt"
SIEGE_LOG_FILE="siege.log"
TEST_DURATION=20s
TEST_FAILED=0
cat <<EOL > $SIEGE_CGI_URLS_FILE
http://${CONTAINER}:${PORT}/cgi/hello.py?name=Marvin
http://${CONTAINER}:${PORT}/cgi/hello.php?name=Marvin
http://${CONTAINER}:${PORT}/cgi/hello.js?name=Marvin
http://${CONTAINER}:${PORT}/cgi/post.py POST {"name": "Marvin"}
http://${CONTAINER}:${PORT}/cgi/post.php POST {"name": "Marvin"}
http://${CONTAINER}:${PORT}/cgi/post.js POST {"name": "Marvin"}
EOL
cat <<EOF > $SIEGE_GET_URLS_FILE
http://${CONTAINER}:${PORT}/
http://${CONTAINER}:8090/
http://${CONTAINER}:8091/
http://${CONTAINER}:8092/
http://${CONTAINER}:8093/
EOF
echo "CGI urls :"
cat $SIEGE_CGI_URLS_FILE > $SIEGE_LOG_FILE
printf "\n" >> $SIEGE_LOG_FILE
echo "GET urls :"
cat $SIEGE_GET_URLS_FILE >> $SIEGE_LOG_FILE
printf "\n" >> $SIEGE_LOG_FILE
siege > /dev/null 2>&1
echo "Running siege with no-cache for CGIs"
echo "Running siege with no-cache for CGIs" >> $SIEGE_LOG_FILE
siege -t ${TEST_DURATION} -c 250 -b -f $SIEGE_CGI_URLS_FILE -H "Cache-Control: no-cache" >> $SIEGE_LOG_FILE
if grep -q '"failed_transactions": *[1-9]' $SIEGE_LOG_FILE; then
echo "!!!KO!!!: Siege test failed with no-cache for CGIs."
TEST_FAILED=1
else
echo "OK: Siege test passed with no-cache for CGIs."
fi
printf "\n"
sleep 2
echo "Running siege with caching enabled for CGIs"
echo "Running siege with caching enabled for CGIs" >> $SIEGE_LOG_FILE
siege -t ${TEST_DURATION} -c 250 -b -f $SIEGE_CGI_URLS_FILE -H "Cookie: sessionid=marvin;" >> $SIEGE_LOG_FILE
if grep -q '"failed_transactions": *[1-9]' $SIEGE_LOG_FILE; then
echo "!!!KO!!!: Siege test failed with caching enabled for CGIs."
TEST_FAILED=1
else
echo "OK: Siege test passed with caching enabled for CGIs."
fi
printf "\n"
sleep 2
echo "Running siege for GET single"
echo "Running siege for GET single" >> $SIEGE_LOG_FILE
siege -t ${TEST_DURATION} -c 250 -b -H "Cookie: sessionid=marvin;" http://${CONTAINER}:${PORT} >> $SIEGE_LOG_FILE
if grep -q '"failed_transactions": *[1-9]' $SIEGE_LOG_FILE; then
echo "!!!KO!!!: Siege test failed for GET."
TEST_FAILED=1
else
echo "OK: Siege test passed for GET."
fi
printf "\n"
sleep 2
echo "Running siege for GET cross-servers"
echo "Running siege for GET cross-servers" >> $SIEGE_LOG_FILE
siege -t ${TEST_DURATION} -c 250 -b -f $SIEGE_GET_URLS_FILE -H "Cookie: sessionid=marvin;" >> $SIEGE_LOG_FILE
if grep -q '"failed_transactions": *[1-9]' $SIEGE_LOG_FILE; then
echo "!!!KO!!!: Siege test failed for GET cross-servers."
TEST_FAILED=1
else
echo "OK: Siege test passed for GET cross-servers."
fi
printf "\n"
if [ "$TEST_FAILED" -ne 0 ]; then
printf "\n!!!KO!!!: One or more tests failed.\n\n"
exit 1
fi
printf "\n"