Skip to content

Commit 130a1b8

Browse files
committed
Allow individual tests to override vegeta opts
1 parent 7801a10 commit 130a1b8

File tree

4 files changed

+30
-69
lines changed

4 files changed

+30
-69
lines changed

test/stress/stress.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ if [[ -t 1 ]] && (( $terminfo[colors] >= 8 )); then
99
colors
1010
fi
1111

12-
which vegeta >/dev/null || error "Missing vegeta, unable to run stress tests"
13-
1412
typeset -g VEGETA_OPTS VERBOSE DURATION
1513

1614
# Output directories
@@ -24,6 +22,8 @@ source $STRESS_DIR/../utils.sh
2422
mkdir -p $TESTTMP $TESTROOT
2523
: >> $CONF
2624

25+
which vegeta >/dev/null || error "Missing vegeta, unable to run stress tests"
26+
2727
function help() {
2828
<<EOF
2929
Usage: stress.sh [OPTIONS] [file]
@@ -48,9 +48,9 @@ exit
4848

4949
function attack() {
5050
echo "GET http://127.0.0.1:$PORT/" | \
51-
vegeta attack -name=$1 "${=VEGETA_OPTS}" > $REPORT_DIR/$1.bin
51+
vegeta attack -name=${@[-1]} "${=VEGETA_OPTS}" ${@[1,-2]} > $REPORT_DIR/${@[-1]}.bin
5252

53-
(( VERBOSE )) && vegeta report $REPORT_DIR/$1.bin
53+
(( VERBOSE )) && vegeta report $REPORT_DIR/${@[-1]}.bin
5454

5555
return 0
5656
}
@@ -87,7 +87,7 @@ done
8787
: ${DURATION:="5s"}
8888
: ${VERBOSE:=0}
8989

90-
VEGETA_OPTS="-duration=$DURATION -http2=false -timeout=10s"
90+
VEGETA_OPTS="-duration=$DURATION -http2=false -timeout=10s -keepalive=false"
9191

9292
# Preserve TESTROOT across tests
9393
root=$TESTROOT
@@ -109,5 +109,3 @@ for i in ${1:-$STRESS_DIR/stress_*.sh}; do
109109
print "$fg_bold[magenta]${i:t}$fg_no_bold[white]"
110110
source $i
111111
done
112-
113-
vegeta plot $REPORT_DIR/*.bin > $HTML_DIR/full.html

test/stress/stress_directory.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ HTTP_CACHE=0
1212
HTML_CACHE=0
1313
EOF
1414

15-
stop_server
1615
TESTROOT=$root
17-
start_server
18-
heartbeat
16+
restart_server
1917

2018
# Default directory listing
2119
describe "Default directory serving"
22-
attack defaults_dir
20+
attack default_directory
2321

2422
# Cache
2523
<<EOF > $CONF
@@ -33,8 +31,8 @@ HTML_CACHE=1
3331
EOF
3432
reload_conf
3533

36-
describe "Directory listing with cache"
37-
attack cache_dir
34+
describe "Directory serving with caching"
35+
attack cache_directory
3836

3937
# Compress directory
4038
<<EOF > $CONF
@@ -57,8 +55,8 @@ source $SRC_DIR/modules/compress.sh
5755
EOF
5856
reload_conf
5957

60-
describe "Directory listing compression"
61-
attack compress_dir
58+
describe "Directory serving with compression"
59+
attack compress_directory
6260

6361
# Compress directory with cache
6462
<<EOF > $CONF
@@ -81,7 +79,7 @@ source $SRC_DIR/modules/compress.sh
8179
EOF
8280
reload_conf
8381

84-
describe "Directory listing compression+cache"
85-
attack compress_cache_dir
82+
describe "Directory serving compression+cache"
83+
attack compress+cache_directory
8684

87-
vegeta plot $REPORT_DIR/*_dir.bin > $HTML_DIR/directory_listing.html
85+
vegeta plot $REPORT_DIR/*_directory.bin > $HTML_DIR/directory_listing.html

test/stress/stress_file.sh

+7-10
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ HTTP_CACHE=0
1212
HTML_CACHE=0
1313
EOF
1414

15-
stop_server
1615
TESTROOT=$root/test.html
17-
start_server
18-
heartbeat
16+
restart_server
1917

20-
# Default file listing
21-
describe "Default file serving"
22-
attack defaults_file
18+
describe "Default file serving with HTTP keep-alive"
19+
attack -keepalive=true default_keep-alive_file
2320

2421
# Disable keep-alive
2522
<<EOF > $CONF
@@ -33,8 +30,8 @@ HTML_CACHE=0
3330
EOF
3431
reload_conf
3532

36-
describe "Disabled keep-alive"
37-
attack no_keep-alive_file
33+
describe "Default file serving without HTTP keep-alive"
34+
attack default_no_keep-alive_file
3835

3936
# Single file compress
4037
<<EOF > $CONF
@@ -80,7 +77,7 @@ EOF
8077
reload_conf
8178

8279
describe "Single file compression+cache"
83-
attack compress_cache_file
80+
attack compress+cache_file
8481

8582
# Finally
86-
vegeta plot $REPORT_DIR/*_file.bin > $HTML_DIR/file_listing.html
83+
vegeta plot $REPORT_DIR/*_file.bin > $HTML_DIR/file_serving.html

test/stress/stress_multiple.sh

+9-41
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,38 @@
22
# Stress test concurrent connections. Will be sourced by `test.sh` #
33
####################################################################
44

5-
VEGETA_OPTS+=" -rate=500/1s -keepalive=false"
6-
7-
<<EOF > $CONF
8-
MAX_CONN=1
9-
HTTP_KEEP_ALIVE=1
10-
HTTP_TIMEOUT=30
11-
HTTP_RECV_TIMEOUT=5
12-
HTTP_BODY_SIZE=16384
13-
HTTP_CACHE=0
14-
HTML_CACHE=0
15-
EOF
16-
17-
stop_server
18-
TESTROOT=$root/test.html
19-
start_server
20-
heartbeat
21-
22-
23-
# Single connection
24-
describe "Multiple connections with MAX_CONN = 1"
25-
attack single_multiple
26-
27-
vegeta plot $REPORT_DIR/single_multiple.bin > $HTML_DIR/single_multiple.html
28-
295
<<EOF > $CONF
306
MAX_CONN=12
31-
HTTP_KEEP_ALIVE=1
7+
HTTP_KEEP_ALIVE=0
328
HTTP_TIMEOUT=30
339
HTTP_RECV_TIMEOUT=5
3410
HTTP_BODY_SIZE=16384
3511
HTTP_CACHE=0
3612
HTML_CACHE=0
3713
EOF
3814

39-
# Clean testing env
40-
stop_server
41-
start_server
42-
heartbeat
15+
TESTROOT=$root/test.html
16+
restart_server
4317

4418
# Default number connections
4519
describe "Multiple connections with MAX_CONN = 12"
46-
attack default_multiple
47-
48-
vegeta plot $REPORT_DIR/default_multiple.bin > $HTML_DIR/default_multiple.html
20+
attack -rate="500/1s" default_max_conn
4921

5022
<<EOF > $CONF
51-
MAX_CONN=48
52-
HTTP_KEEP_ALIVE=1
23+
MAX_CONN=30
24+
HTTP_KEEP_ALIVE=0
5325
HTTP_TIMEOUT=30
5426
HTTP_RECV_TIMEOUT=5
5527
HTTP_BODY_SIZE=16384
5628
HTTP_CACHE=0
5729
HTML_CACHE=0
5830
EOF
5931

60-
stop_server
61-
start_server
62-
heartbeat
32+
restart_server
6333

6434
# Increased number connections
6535
describe "Multiple connections with MAX_CONN = 30"
66-
attack max_multiple
67-
68-
vegeta plot $REPORT_DIR/max_multiple.bin > $HTML_DIR/max_multiple.html
36+
attack -rate="500/1s" 30_max_conn
6937

7038
# Finally
71-
vegeta plot $REPORT_DIR/*_multiple.bin > $HTML_DIR/multiple.html
39+
vegeta plot $REPORT_DIR/*_conn.bin > $HTML_DIR/max_conn.html

0 commit comments

Comments
 (0)