test: use different ports for each test, run some targets only on linux

This commit is contained in:
Simon Cruanes 2021-12-11 16:25:34 -05:00
parent bcce3e22dc
commit b468854626
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
10 changed files with 24 additions and 15 deletions

View file

@ -16,6 +16,6 @@ jobs:
- run: opam pin -n . - run: opam pin -n .
- run: opam depext -yt tiny_httpd tiny_httpd_camlzip - run: opam depext -yt tiny_httpd tiny_httpd_camlzip
- run: opam install -t . --deps-only - run: opam install -t . --deps-only
- run: opam exec -- dune build - run: opam exec -- dune build @install
- run: opam exec -- dune runtest - run: opam exec -- dune runtest
if: ${{ matrix.operating-system == 'unbuntu-latest' }} if: ${{ matrix.operating-system == 'unbuntu-latest' }}

View file

@ -1,2 +1,2 @@
serve directory . on http://127.0.0.1:8083 serve directory . on http://127.0.0.1:8084
0 0 52428800 data2 0 0 52428800 data2

View file

@ -1,11 +1,12 @@
#!/usr/bin/env sh #!/usr/bin/env sh
SERVER=$1 SERVER=$1
"$SERVER" . -p 8083 & PORT=8084
"$SERVER" . -p $PORT &
sleep 0.1 sleep 0.1
curl -N 'http://localhost:8083/foo_50' -o data2 \ curl -N "http://localhost:${PORT}/foo_50" -o data2 \
-H 'Tranfer-encoding: chunked' -H 'Tranfer-encoding: chunked'
kill %1 kill %1

View file

@ -3,6 +3,7 @@
(targets echo1.out) (targets echo1.out)
(deps (:bin ../examples/echo.exe)) (deps (:bin ../examples/echo.exe))
(locks /port) (locks /port)
(enabled_if (= %{system} "linux"))
(action (with-stdout-to %{targets} (run ./echo1.sh %{bin})))) (action (with-stdout-to %{targets} (run ./echo1.sh %{bin}))))
(rule (rule
@ -13,6 +14,7 @@
(targets sse_count.out) (targets sse_count.out)
(deps (:bin ../examples/sse_server.exe)) (deps (:bin ../examples/sse_server.exe))
(locks /port) (locks /port)
(enabled_if (= %{system} "linux"))
(action (with-stdout-to %{targets} (run ./sse_count.sh %{bin})))) (action (with-stdout-to %{targets} (run ./sse_count.sh %{bin}))))
(rule (rule
@ -23,6 +25,7 @@
(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)
(locks /port) (locks /port)
(enabled_if (= %{system} "linux"))
(action (with-stdout-to %{targets} (action (with-stdout-to %{targets}
(run ./upload_chunked.sh %{bin})))) (run ./upload_chunked.sh %{bin}))))
@ -34,6 +37,7 @@
(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)
(locks /port) (locks /port)
(enabled_if (= %{system} "linux"))
(action (with-stdout-to %{targets} (action (with-stdout-to %{targets}
(run ./download_chunked.sh %{bin})))) (run ./download_chunked.sh %{bin}))))

View file

@ -1,9 +1,9 @@
listening on http://127.0.0.1:8083 listening on http://127.0.0.1:8085
echo: echo:
{meth=GET; host=localhost:8083; {meth=GET; host=localhost:8085;
headers=[user-agent: test headers=[user-agent: test
accept: */* accept: */*
host: localhost:8083]; host: localhost:8085];
path="/echo/?a=b&c=d"; body=""; path_components=["echo"]; path="/echo/?a=b&c=d"; body=""; path_components=["echo"];
query=["c","d";"a","b"]} query=["c","d";"a","b"]}
(query: "c" = "d";"a" = "b") (query: "c" = "d";"a" = "b")

View file

@ -1,8 +1,9 @@
#!/usr/bin/env sh #!/usr/bin/env sh
ECHO=$1 ECHO=$1
PORT=8085
"$ECHO" -p 8083 & "$ECHO" -p $PORT &
sleep 0.1 sleep 0.1
curl -N 'http://localhost:8083/echo/?a=b&c=d' -H user-agent:test curl -N "http://localhost:${PORT}/echo/?a=b&c=d" -H user-agent:test
kill %1 kill %1

View file

@ -1,4 +1,4 @@
listening on http://localhost:8083/ listening on http://localhost:8086/
data: 0 data: 0
data: 1 data: 1

View file

@ -1,9 +1,10 @@
#!/usr/bin/env sh #!/usr/bin/env sh
SSE_SERVER=$1 SSE_SERVER=$1
PORT=8086
"$SSE_SERVER" -p 8083 & "$SSE_SERVER" -p $PORT &
sleep 0.1 sleep 0.1
curl -N 'http://localhost:8083/count/10' -H user-agent:test curl -N "http://localhost:${PORT}/count/10" -H user-agent:test
kill %1 kill %1

View file

@ -1,2 +1,2 @@
serve directory . on http://127.0.0.1:8083 serve directory . on http://127.0.0.1:8087
upload successful 0 0 52428800 data upload successful 0 0 52428800 data

View file

@ -3,11 +3,13 @@
rm data rm data
SERVER=$1 SERVER=$1
"$SERVER" . -p 8083 --upload --max-upload 100000000000 & PORT=8087
"$SERVER" . -p $PORT --upload --max-upload 100000000000 &
sleep 0.1 sleep 0.1
cat foo_50 | curl -N -X PUT http://localhost:8083/data --data-binary @- -H 'Transfer-Encoding: chunked' cat foo_50 | curl -N -X PUT http://localhost:$PORT/data --data-binary @- -H 'Transfer-Encoding: chunked'
kill %1 kill %1
wc data wc data