mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
added a stress test (multiple simultaneous download) + section in tests/dune
This commit is contained in:
parent
915317438f
commit
177b004144
3 changed files with 69 additions and 3 deletions
16
tests/dl-stress.expect
Normal file
16
tests/dl-stress.expect
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
serve directory . on http://127.0.0.1:8088
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
52428800
|
||||
33
tests/dune
33
tests/dune
|
|
@ -1,3 +1,5 @@
|
|||
; echo
|
||||
;=====
|
||||
|
||||
(rule
|
||||
(targets echo1.out)
|
||||
|
|
@ -13,6 +15,9 @@
|
|||
(enabled_if (= %{system} "linux"))
|
||||
(action (diff echo1.expect echo1.out)))
|
||||
|
||||
; sse
|
||||
; ====
|
||||
|
||||
(rule
|
||||
(targets sse_count.out)
|
||||
(deps (:bin ../examples/sse_server.exe))
|
||||
|
|
@ -27,6 +32,15 @@
|
|||
(enabled_if (= %{system} "linux"))
|
||||
(action (diff sse_count.expect sse_count.out)))
|
||||
|
||||
; chunked
|
||||
;========
|
||||
|
||||
(rule
|
||||
(targets foo_50)
|
||||
(enabled_if (= %{system} "linux"))
|
||||
(action
|
||||
(bash "dd if=/dev/zero of=%{targets} bs=1M count=50")))
|
||||
|
||||
(rule
|
||||
(targets upload-out)
|
||||
(deps (:bin ../src/bin/http_of_dir.exe) foo_50)
|
||||
|
|
@ -42,6 +56,7 @@
|
|||
(enabled_if (= %{system} "linux"))
|
||||
(action (diff upload-out.expect upload-out)))
|
||||
|
||||
|
||||
(rule
|
||||
(targets dl-out)
|
||||
(deps (:bin ../src/bin/http_of_dir.exe) foo_50)
|
||||
|
|
@ -57,8 +72,20 @@
|
|||
(enabled_if (= %{system} "linux"))
|
||||
(action (diff dl-out.expect dl-out)))
|
||||
|
||||
; stress
|
||||
;=======
|
||||
|
||||
(rule
|
||||
(targets foo_50)
|
||||
(targets dl-stress)
|
||||
(deps (:bin ../src/bin/http_of_dir.exe) foo_50)
|
||||
(locks /port)
|
||||
(package tiny_httpd)
|
||||
(enabled_if (= %{system} "linux"))
|
||||
(action
|
||||
(bash "dd if=/dev/zero of=%{targets} bs=1M count=50")))
|
||||
(action (with-stdout-to %{targets}
|
||||
(run ./stress.sh %{bin} 15))))
|
||||
|
||||
(rule
|
||||
(alias runtest)
|
||||
(package tiny_httpd)
|
||||
(enabled_if (= %{system} "linux"))
|
||||
(action (diff dl-stress.expect dl-stress)))
|
||||
|
|
|
|||
23
tests/stress.sh
Executable file
23
tests/stress.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
SERVER=$1
|
||||
PORT=8088
|
||||
"$SERVER" . -p $PORT &
|
||||
PID=$!
|
||||
|
||||
url=http://localhost:${PORT}/foo_50
|
||||
nb=$2
|
||||
sleep_time=0
|
||||
|
||||
for (( c=1; c<=$nb; c++ )); do
|
||||
f=$(mktemp)
|
||||
(curl -s $url > $f; stat -c %s $f; rm $f) &
|
||||
PIDS[$c]=$!
|
||||
|
||||
sleep $sleep_time
|
||||
done
|
||||
|
||||
#echo ${PIDS[@]}
|
||||
wait ${PIDS[@]}
|
||||
|
||||
kill $PID
|
||||
Loading…
Add table
Reference in a new issue