added a stress test (multiple simultaneous download) + section in tests/dune

This commit is contained in:
craff 2023-01-14 17:25:38 -10:00
parent 915317438f
commit 177b004144
3 changed files with 69 additions and 3 deletions

16
tests/dl-stress.expect Normal file
View 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

View file

@ -1,3 +1,5 @@
; echo
;=====
(rule (rule
(targets echo1.out) (targets echo1.out)
@ -13,6 +15,9 @@
(enabled_if (= %{system} "linux")) (enabled_if (= %{system} "linux"))
(action (diff echo1.expect echo1.out))) (action (diff echo1.expect echo1.out)))
; sse
; ====
(rule (rule
(targets sse_count.out) (targets sse_count.out)
(deps (:bin ../examples/sse_server.exe)) (deps (:bin ../examples/sse_server.exe))
@ -27,6 +32,15 @@
(enabled_if (= %{system} "linux")) (enabled_if (= %{system} "linux"))
(action (diff sse_count.expect sse_count.out))) (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 (rule
(targets upload-out) (targets upload-out)
(deps (:bin ../src/bin/http_of_dir.exe) foo_50) (deps (:bin ../src/bin/http_of_dir.exe) foo_50)
@ -42,6 +56,7 @@
(enabled_if (= %{system} "linux")) (enabled_if (= %{system} "linux"))
(action (diff upload-out.expect upload-out))) (action (diff upload-out.expect upload-out)))
(rule (rule
(targets dl-out) (targets dl-out)
(deps (:bin ../src/bin/http_of_dir.exe) foo_50) (deps (:bin ../src/bin/http_of_dir.exe) foo_50)
@ -57,8 +72,20 @@
(enabled_if (= %{system} "linux")) (enabled_if (= %{system} "linux"))
(action (diff dl-out.expect dl-out))) (action (diff dl-out.expect dl-out)))
; stress
;=======
(rule (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")) (enabled_if (= %{system} "linux"))
(action (action (with-stdout-to %{targets}
(bash "dd if=/dev/zero of=%{targets} bs=1M count=50"))) (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
View 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