#!/usr/bin/env bash # Runs the whole module: the tests (which write cap/01..04), then the -Xmx64m streaming experiment (cap/05..06). # No Docker needed. Takes a couple of minutes. set -euo pipefail cd "$(dirname "$0")/.." mkdir -p cap mvn -q -B test mvn -q -B package -DskipTests JAR=$(ls target/file-transfer-*.jar | grep -v original | head -1) run_app() { # $1 = extra args; sets APP_PID java -Xmx64m -jar "$JAR" --server.port=18080 $1 > cap/app.log 2>&1 & APP_PID=$! for _ in $(seq 1 60); do curl -s -o /dev/null http://localhost:18080/stream/1 && break; sleep 0.5; done } OUT=cap/05-streaming.txt; : > "$OUT" run_app "" echo "JVM started with -Xmx64m" >> "$OUT" for kind in buffered stream; do R=$(curl -s -o /dev/null -w "status=%{http_code} downloaded=%{size_download} bytes in %{time_total}s" http://localhost:18080/$kind/200 || true) echo "GET /$kind/200 (200 MB) -> $R" >> "$OUT" done echo "GET /stream/1 afterwards -> $(curl -s -o /dev/null -w 'status=%{http_code}' http://localhost:18080/stream/1)" >> "$OUT" kill $APP_PID; wait $APP_PID 2>/dev/null || true OUT=cap/06-big-upload.txt; : > "$OUT" head -c 157286400 /dev/zero > /tmp/ft-150mb.bin run_app "--spring.servlet.multipart.max-file-size=-1 --spring.servlet.multipart.max-request-size=-1" echo "JVM started with -Xmx64m, multipart limits removed, uploading a 150 MB file" >> "$OUT" R=$(curl -s -o /dev/null -w "status=%{http_code} sent=%{size_upload} bytes in %{time_total}s" -F "file=@/tmp/ft-150mb.bin;type=application/octet-stream" http://localhost:18080/files || true) echo "multipart POST /files -> $R" >> "$OUT" R=$(curl -s -o /dev/null -w "status=%{http_code} sent=%{size_upload} bytes in %{time_total}s" -H "X-Filename: big.bin" --data-binary @/tmp/ft-150mb.bin -H "Content-Type: application/octet-stream" http://localhost:18080/files/raw || true) echo "raw POST /files/raw -> $R" >> "$OUT" kill $APP_PID; wait $APP_PID 2>/dev/null || true rm -f /tmp/ft-150mb.bin